// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %rax
movq %rdi, %rbx
leaq 0x20(%rdi), %r12
movq %r12, %rdi
callq 0x23e0
movq %rax, %r14
leaq 0x4(%rsp), %r15
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movl (%r15), %eax
movl %eax, 0x298(%rbx)
leaq 0x4(%rsp), %r15
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movl (%r15), %eax
movl %eax, 0x29c(%rbx)
leaq 0x4(%rsp), %r15
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movl (%r15), %eax
movl %eax, 0x2a0(%rbx)
leaq 0x4(%rsp), %r15
movl $0x2, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movzwl (%r15), %eax
movl %eax, 0x2a4(%rbx)
leaq 0x4(%rsp), %r15
movl $0x2, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movzwl (%r15), %eax
movl %eax, 0x2a8(%rbx)
leaq 0x2ac(%rbx), %r15
movl $0x4, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x22b0
movb $0x0, 0x2b0(%rbx)
leaq 0x4(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movl (%r13), %eax
movl %eax, 0x2b4(%rbx)
leaq 0x4(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movl (%r13), %eax
movl %eax, 0x2b8(%rbx)
leaq 0x4(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movl (%r13), %eax
movl %eax, 0x2bc(%rbx)
leaq 0x4(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movl (%r13), %eax
movl %eax, 0x2c0(%rbx)
leaq 0x4(%rsp), %r13
movl $0x4, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movslq (%r13), %r13
movl %r13d, 0x2c4(%rbx)
movq $0x0, 0x2c8(%rbx)
testq %r13, %r13
je 0x3f90
movq %r13, %rax
shlq $0x2, %rax
testl %r13d, %r13d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2040
movq %rax, 0x2c8(%rbx)
testl %r13d, %r13d
jle 0x3f90
xorl %ebp, %ebp
leaq 0x4(%rsp), %r13
movl $0x3, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movzbl 0x4(%rsp), %eax
movzwl 0x5(%rsp), %ecx
shll $0x8, %ecx
orl %eax, %ecx
movq 0x2c8(%rbx), %rax
movl %ecx, (%rax,%rbp,4)
incq %rbp
movslq 0x2c4(%rbx), %rax
cmpq %rax, %rbp
jl 0x3f58
movq 0x4019(%rip), %r12      # 0x7fb0
movq (%r12), %rdi
leaq 0x14a1(%rip), %rsi      # 0x5443
movq %r14, %rdx
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x298(%rbx), %edx
leaq 0x1575(%rip), %rsi      # 0x5532
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x29c(%rbx), %edx
leaq 0x1581(%rip), %rsi      # 0x5556
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a0(%rbx), %edx
leaq 0x158d(%rip), %rsi      # 0x557a
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a4(%rbx), %edx
leaq 0x1599(%rip), %rsi      # 0x559e
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a8(%rbx), %edx
leaq 0x15a5(%rip), %rsi      # 0x55c2
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
leaq 0x15b7(%rip), %rsi      # 0x55e6
movq %r15, %rdx
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2b4(%rbx), %edx
leaq 0x15c0(%rip), %rsi      # 0x560a
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2b8(%rbx), %edx
leaq 0x15cc(%rip), %rsi      # 0x562e
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2bc(%rbx), %edx
leaq 0x15d8(%rip), %rsi      # 0x5652
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2c0(%rbx), %edx
leaq 0x15e4(%rip), %rsi      # 0x5676
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2c4(%rbx), %edx
leaq 0x15f0(%rip), %rsi      # 0x569a
xorl %eax, %eax
callq 0x2340
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq