// File: /workspace/github_cpp_makefile_star2_O1/lukasz-wiecaszek[P]h264iframedecoder/picture.cpp
// Function: ymn::h264::picture::init_coxtext_variables(ymn::h264::slice_header const&)
void picture::init_coxtext_variables(const h264::slice_header& sh)
{
    const sps* sps = m_decoder.m_active_sps;
    const pps* pps = m_decoder.m_active_pps;

    if (sps->frame_mbs_only_flag) {
        m_picture_structure = picture_structure_e::frame;
        m_context_variables.mb_aff_frame = false;
    }
    else {
        if (sh.field_pic_flag) {
            if (sh.bottom_field_flag)
                m_picture_structure = picture_structure_e::field_bottom;
            else
                m_picture_structure = picture_structure_e::field_top;
            m_context_variables.mb_aff_frame = false;
        }
        else {
            m_picture_structure = picture_structure_e::frame;
            m_context_variables.mb_aff_frame = sps->mb_adaptive_frame_field_flag;
        }
    }

    m_context_variables.mb_field_decoding_flag = m_picture_structure != picture_structure_e::frame;

    m_context_variables.mb_x = sh.first_mb_in_slice % m_decoder.m_dimensions.mb_width;
    m_context_variables.mb_y = sh.first_mb_in_slice / m_decoder.m_dimensions.mb_width;

    if (sh.field_pic_flag || m_context_variables.mb_aff_frame)
        m_context_variables.mb_y *= 2;

    if (m_picture_structure == picture_structure_e::field_bottom)
        m_context_variables.mb_y +=1;

    update_mb_pos();

    m_context_variables.lastQPdelta = 0;
    m_context_variables.QPy = pps->pic_init_qp_minus26 + 26 + sh.slice_qp_delta;
    m_context_variables.QPc[0] = m_decoder.m_chroma_qp_table[0][m_context_variables.QPy];
    m_context_variables.QPc[1] = m_decoder.m_chroma_qp_table[1][m_context_variables.QPy];

    m_context_variables.chroma_array_type = sps->chroma_format_idc;
    if (sps->chroma_format_idc == 3 && sps->separate_colour_plane_flag)
        m_context_variables.chroma_array_type = 0;

    m_context_variables.left_blocks = nullptr; // it will be evaluated in calculate_neighbours_part2()
    m_context_variables.left_blocks_nzc = nullptr; // it will be evaluated in calculate_neighbours_part2()

    //m_context_variables.intraNxN_pred_mode_cache - it will be initialized during processing of macroblock
    //m_context_variables.non_zero_count           - it will be initialized during processing of macroblock
    //m_context_variables.coeffs_ac                - it will be initialized during processing of macroblock
    //m_context_variables.coeffs_dc                - it will be initialized during processing of macroblock
}

// Assembly:
movq 0x8(%rdi), %r8
movq 0x88358(%r8), %rcx
movq 0x88360(%r8), %r9
cmpl $0x0, 0x6fc(%rcx)
je 0x16454
movl $0x0, 0x10(%rdi)
jmp 0x1646d
cmpl $0x0, 0x28(%rsi)
je 0x16533
cmpl $0x1, 0x2c(%rsi)
movl $0x2, %eax
sbbl $0x0, %eax
movl %eax, 0x10(%rdi)
movb $0x0, 0x18(%rdi)
movl 0x10(%rdi), %r11d
testl %r11d, %r11d
setne 0x19(%rdi)
movl 0x14(%rsi), %eax
movl 0x88340(%r8), %r10d
xorl %edx, %edx
divl %r10d
movl %edx, 0x1c(%rdi)
movl %eax, 0x20(%rdi)
cmpl $0x0, 0x28(%rsi)
jne 0x1649d
cmpb $0x1, 0x18(%rdi)
jne 0x164a2
addl %eax, %eax
movl %eax, 0x20(%rdi)
cmpl $0x2, %r11d
jne 0x164ab
incl 0x20(%rdi)
imull 0x20(%rdi), %r10d
addl %edx, %r10d
movl %r10d, 0x24(%rdi)
movslq %r10d, %rax
imulq $0xb0, %rax, %rdx
addq 0xdb8(%rdi), %rdx
xorl %r10d, %r10d
cmpl 0x88348(%r8), %eax
cmovlq %rdx, %r10
movq %r10, 0x28(%rdi)
movl $0x0, 0x30(%rdi)
movslq 0x438(%r9), %rax
movslq 0x95c(%rsi), %rdx
leaq (%rax,%rdx), %rsi
leaq 0x1a(%rax,%rdx), %rax
movl %eax, 0x34(%rdi)
movzbl 0xa63ea(%r8,%rsi), %eax
movl %eax, 0x38(%rdi)
movzbl 0xa642a(%r8,%rsi), %eax
movl %eax, 0x3c(%rdi)
movl 0x10(%rcx), %eax
movl %eax, 0x40(%rdi)
cmpl $0x3, %eax
jne 0x1652b
cmpl $0x0, 0x14(%rcx)
je 0x1652b
movl $0x0, 0x40(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rdi)
retq
movl $0x0, 0x10(%rdi)
cmpl $0x0, 0x700(%rcx)
setne 0x18(%rdi)
jmp 0x16471