// File: /workspace/github_cpp_makefile_star2_O2/olegk0[P]readAVI/ReadAVI.cpp
// Function: ReadAVI::read_stream_format()
int ReadAVI::read_stream_format()
{
    int t, r, g, b;
#ifdef VERBOSE
    long offset = inFile.tellg();
#endif
    stream_format_vid.header_size = read_int();
    stream_format_vid.image_width = read_int();
    stream_format_vid.image_height = read_int();
    stream_format_vid.number_of_planes = read_word();
    stream_format_vid.bits_per_pixel = read_word();
    read_chars(stream_format_vid.compression_type, 4);
    //stream_format_vid.compression_type = read_int();
    stream_format_vid.image_size_in_bytes = read_int();
    stream_format_vid.x_pels_per_meter = read_int();
    stream_format_vid.y_pels_per_meter = read_int();
    stream_format_vid.colors_used = read_int();
    stream_format_vid.colors_important = read_int();
    stream_format_vid.palette = 0;

    if (stream_format_vid.colors_important != 0) {
	stream_format_vid.palette = new int[stream_format_vid.colors_important];
	for (t = 0; t < stream_format_vid.colors_important; t++) {
	    unsigned char buf[3];
	    read_chars_bin(buf, 3);
	    b = buf[0];
	    g = buf[1];
	    r = buf[2];
	    stream_format_vid.palette[t] = (r << 16) + (g << 8) + b;
	}
    }

    MSG_DBG(2, "            offset=0x%lx\n", offset);
    MSG_DBG(2, "                   header_size: %d\n", stream_format_vid.header_size);
    MSG_DBG(2, "                   image_width: %d\n", stream_format_vid.image_width);
    MSG_DBG(2, "                  image_height: %d\n", stream_format_vid.image_height);
    MSG_DBG(2, "              number_of_planes: %d\n", stream_format_vid.number_of_planes);
    MSG_DBG(2, "                bits_per_pixel: %d\n", stream_format_vid.bits_per_pixel);
    MSG_DBG(2, "              compression_type: %s\n", stream_format_vid.compression_type);
    /*    MSG_DBG(2, "              compression_type: %04x (%c%c%c%c)\n", stream_format_vid.compression_type,
     ((stream_format_vid.compression_type) & 255), ((stream_format_vid.compression_type >> 8) & 255),
     ((stream_format_vid.compression_type >> 16) & 255), ((stream_format_vid.compression_type >> 24) & 255));
     */
    MSG_DBG(2, "           image_size_in_bytes: %d\n", stream_format_vid.image_size_in_bytes);
    MSG_DBG(2, "              x_pels_per_meter: %d\n", stream_format_vid.x_pels_per_meter);
    MSG_DBG(2, "              y_pels_per_meter: %d\n", stream_format_vid.y_pels_per_meter);
    MSG_DBG(2, "                   colors_used: %d\n", stream_format_vid.colors_used);
    MSG_DBG(2, "              colors_important: %d\n", stream_format_vid.colors_important);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x20(%rdi), %r12
movq %r12, %rdi
callq 0x2410
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x298(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x29c(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2a0(%rbx)
movq %rbx, %rdi
callq 0x3c4e
movl %eax, 0x2a4(%rbx)
movq %rbx, %rdi
callq 0x3c4e
movl %eax, 0x2a8(%rbx)
leaq 0x2ac(%rbx), %rsi
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %rsi, 0x10(%rsp)
callq 0x3542
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2b4(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2b8(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2bc(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2c0(%rbx)
movq %rbx, %rdi
callq 0x3566
movl %eax, 0x2c4(%rbx)
andq $0x0, 0x2c8(%rbx)
testl %eax, %eax
je 0x3b23
movl %eax, %ebp
movl %eax, %eax
shlq $0x2, %rax
testl %ebp, %ebp
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0x2040
movq %rax, 0x2c8(%rbx)
xorl %r14d, %r14d
leaq 0x5(%rsp), %r13
pushq $0x3
popq %r15
movslq %ebp, %rax
cmpq %rax, %r14
jge 0x3b23
movq %r12, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x22f0
movzbl 0x5(%rsp), %eax
movzwl 0x6(%rsp), %ecx
shll $0x8, %ecx
orl %eax, %ecx
movq 0x2c8(%rbx), %rax
movl %ecx, (%rax,%r14,4)
incq %r14
movl 0x2c4(%rbx), %ebp
jmp 0x3ae8
movq 0x4486(%rip), %r15      # 0x7fb0
movq (%r15), %rdi
leaq 0x190f(%rip), %rsi      # 0x5443
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x298(%rbx), %edx
leaq 0x19e2(%rip), %rsi      # 0x5532
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x29c(%rbx), %edx
leaq 0x19ef(%rip), %rsi      # 0x5556
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2a0(%rbx), %edx
leaq 0x19fc(%rip), %rsi      # 0x557a
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2a4(%rbx), %edx
leaq 0x1a09(%rip), %rsi      # 0x559e
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2a8(%rbx), %edx
leaq 0x1a16(%rip), %rsi      # 0x55c2
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
leaq 0x1a29(%rip), %rsi      # 0x55e6
movq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2b4(%rbx), %edx
leaq 0x1a31(%rip), %rsi      # 0x560a
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2b8(%rbx), %edx
leaq 0x1a3e(%rip), %rsi      # 0x562e
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2bc(%rbx), %edx
leaq 0x1a4b(%rip), %rsi      # 0x5652
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2c0(%rbx), %edx
leaq 0x1a58(%rip), %rsi      # 0x5676
xorl %eax, %eax
callq 0x2380
movq (%r15), %rdi
movl 0x2c4(%rbx), %edx
leaq 0x1a65(%rip), %rsi      # 0x569a
xorl %eax, %eax
callq 0x2380
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop