// File: /workspace/github_cpp_makefile_star2_O1/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
movzwl (%r13), %ecx
movzbl 0x2(%r13), %eax
shll $0x10, %eax
orl %ecx, %eax
movzbl 0x3(%r13), %ecx
shll $0x18, %ecx
orl %ecx, %eax
movl %eax, 0x2c4(%rbx)
movq $0x0, 0x2c8(%rbx)
je 0x3fd9
cltq
shlq $0x2, %rax
testl %ecx, %ecx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2040
movq %rax, 0x2c8(%rbx)
cmpl $0x0, 0x2c4(%rbx)
jle 0x3fd9
xorl %ebp, %ebp
leaq 0x4(%rsp), %r13
movl $0x3, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x22b0
movzbl 0x6(%rsp), %eax
shll $0x10, %eax
movzwl 0x4(%rsp), %ecx
orl %eax, %ecx
movq 0x2c8(%rbx), %rax
movl %ecx, (%rax,%rbp,4)
incq %rbp
movslq 0x2c4(%rbx), %rax
cmpq %rax, %rbp
jl 0x3fa1
movq 0x3fd0(%rip), %r12      # 0x7fb0
movq (%r12), %rdi
leaq 0x1458(%rip), %rsi      # 0x5443
movq %r14, %rdx
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x298(%rbx), %edx
leaq 0x152c(%rip), %rsi      # 0x5532
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x29c(%rbx), %edx
leaq 0x1538(%rip), %rsi      # 0x5556
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a0(%rbx), %edx
leaq 0x1544(%rip), %rsi      # 0x557a
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a4(%rbx), %edx
leaq 0x1550(%rip), %rsi      # 0x559e
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2a8(%rbx), %edx
leaq 0x155c(%rip), %rsi      # 0x55c2
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
leaq 0x156e(%rip), %rsi      # 0x55e6
movq %r15, %rdx
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2b4(%rbx), %edx
leaq 0x1577(%rip), %rsi      # 0x560a
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2b8(%rbx), %edx
leaq 0x1583(%rip), %rsi      # 0x562e
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2bc(%rbx), %edx
leaq 0x158f(%rip), %rsi      # 0x5652
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2c0(%rbx), %edx
leaq 0x159b(%rip), %rsi      # 0x5676
xorl %eax, %eax
callq 0x2340
movq (%r12), %rdi
movl 0x2c4(%rbx), %edx
leaq 0x15a7(%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
nop