// File: /workspace/github_cpp_makefile_star2_O1/lukasz-wiecaszek[P]h264iframedecoder/h264_decoder.cpp
// Function: ymn::h264_decoder::parse()
void h264_decoder::parse()
{
    h264_parser_status_e status;

    do {
        status = m_parser.parse();

        switch (status) {
            case h264_parser_status_e::NAL_UNIT_SKIPPED:
                break;

            case h264_parser_status_e::NAL_UNIT_CORRUPTED:
                break;

            case h264_parser_status_e::AUD_PARSED:
            {
                const h264_structure* aud;

                aud = m_parser.get_structure(
                    h264_parser_structure_e::AUD,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (aud)
                    std::cout << aud->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;
                break;
            }

            case h264_parser_status_e::SPS_PARSED:
            {
                const h264_structure* sps;

                sps = m_parser.get_structure(
                    h264_parser_structure_e::SPS,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (sps)
                    std::cout << sps->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;
                break;
            }

            case h264_parser_status_e::PPS_PARSED:
            {
                const h264_structure* pps;

                pps = m_parser.get_structure(
                    h264_parser_structure_e::PPS,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (pps)
                    std::cout << pps->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;
                break;
            }

            case h264_parser_status_e::SEI_PARSED:
            {
                const h264_structure* sei;

                sei = m_parser.get_structure(
                    h264_parser_structure_e::SEI,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (sei)
                    std::cout << sei->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;
                break;
            }

            case h264_parser_status_e::SLICE_PARSED:
            {
                const h264_structure* slice_header;

                slice_header = m_parser.get_structure(
                    h264_parser_structure_e::SLICE_HEADER,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (slice_header)
                    std::cout << slice_header->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;

                const h264_structure* slice_data;

                slice_data = m_parser.get_structure(
                    h264_parser_structure_e::SLICE_DATA,
                    H264_PARSER_STRUCTURE_ID_RECENT);

                if (slice_data)
                    std::cout << slice_data->to_string();
                else
                    std::cout << "Parser returned '" << ymn::to_string(status) <<
                        "' but associated structure cannot be retrived" << std::endl;

                if (slice_header && slice_data)
                    decode_slice(
                        *reinterpret_cast<const h264::slice_header*>(slice_header),
                        *reinterpret_cast<const h264::slice_data*>(slice_data));
                break;
            }

            default:
                break;
       }
    } while (status != h264_parser_status_e::NEED_BYTES);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x14202(%rip), %rbp     # 0x1c350
movq 0x19e6b(%rip), %r14     # 0x21fc0
movq 0x108(%rbx), %rax
movq 0x110(%rbx), %rdi
addq %rbx, %rdi
testb $0x1, %al
je 0x8172
movq (%rdi), %rcx
movq -0x1(%rcx,%rax), %rax
callq *%rax
cmpl $0x7, %eax
ja 0x8155
movl %eax, %r12d
movl %eax, %eax
movslq (%rbp,%rax,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %rbx, %rdi
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
testq %rax, %rax
jne 0x8265
movl $0x11, %edx
movq %r14, %rdi
leaq 0x154d9(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x15b1b(%rip), %rsi     # 0x1dcde
jmp 0x832e
movq %rbx, %rdi
movl $0x3, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
testq %rax, %rax
jne 0x8265
movl $0x11, %edx
movq %r14, %rdi
leaq 0x15496(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x15af9(%rip), %rsi     # 0x1dcff
jmp 0x832e
movq %rbx, %rdi
movl $0x2, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
testq %rax, %rax
jne 0x8265
movl $0x11, %edx
movq %r14, %rdi
leaq 0x15457(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x15aaf(%rip), %rsi     # 0x1dcf4
jmp 0x832e
movq %rbx, %rdi
movl $0x1, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
testq %rax, %rax
je 0x830b
movq (%rax), %rcx
leaq 0x8(%rsp), %rdi
movq %rax, %rsi
callq *(%rcx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x84af
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x84af
movq %rbx, %rdi
movl $0x4, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
movq %rax, %r15
testq %rax, %rax
je 0x8373
movq (%r15), %rax
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
callq *(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x83d6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x83d6
movl $0x11, %edx
movq %r14, %rdi
leaq 0x1536e(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xa, %edx
movq %r14, %rdi
leaq 0x159bb(%rip), %rsi     # 0x1dce9
callq 0x21d0
movl $0x2d, %edx
movq %r14, %rdi
leaq 0x15358(%rip), %rsi     # 0x1d69a
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
jmp 0x84af
movl $0x11, %edx
movq %r14, %rdi
leaq 0x15306(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xc, %edx
movq %r14, %rdi
leaq 0x15974(%rip), %rsi     # 0x1dd0a
callq 0x21d0
movl $0x2d, %edx
movq %r14, %rdi
leaq 0x152f0(%rip), %rsi     # 0x1d69a
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
movq %rbx, %rdi
movl $0x5, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3b18
movq %rax, %r13
testq %rax, %rax
je 0x842e
movq (%r13), %rax
leaq 0x8(%rsp), %rdi
movq %r13, %rsi
callq *(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x21d0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x8491
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x8491
movl $0x11, %edx
movq %r14, %rdi
leaq 0x1524b(%rip), %rsi     # 0x1d688
callq 0x21d0
movl $0xc, %edx
movq %r14, %rdi
leaq 0x158b9(%rip), %rsi     # 0x1dd0a
callq 0x21d0
movl $0x2d, %edx
movq %r14, %rdi
leaq 0x15235(%rip), %rsi     # 0x1d69a
callq 0x21d0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
testq %r13, %r13
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
jne 0x84af
movq %rbx, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x8934
testl %r12d, %r12d
jne 0x8155
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop