// File: /workspace/github_c_makefile_star2_O1/akumrao[P]videoAnalyzer/encoder/set.c
// Function: x264_sps_init(x264_sps_t*, int, x264_param_t*)
void x264_sps_init(x264_sps_t *sps, int i_id, x264_param_t *param) {LOG_CALL;
    sps->i_id = i_id;
    sps->i_profile_idc = PROFILE_EXTENTED;
    sps->i_level_idc = 21; /* FIXME ? */
    sps->b_constraint_set0 = 0;
    sps->b_constraint_set1 = 0;
    sps->b_constraint_set2 = 0;

    sps->i_log2_max_frame_num = 8;
    sps->i_poc_type = 0;
    if (sps->i_poc_type == 0)
    {
        sps->i_log2_max_poc_lsb = 8;
    }
    else if (sps->i_poc_type == 1)
    {
        int i;

        /* FIXME */
        sps->b_delta_pic_order_always_zero = 1;
        sps->i_offset_for_non_ref_pic = 0;
        sps->i_offset_for_top_to_bottom_field = 0;
        sps->i_num_ref_frames_in_poc_cycle = 0;

        for (i = 0; i < sps->i_num_ref_frames_in_poc_cycle; i++)
        {
            sps->i_offset_for_ref_frame[i] = 0;
        }
    }

    sps->i_num_ref_frames = param->i_frame_reference + 1; /* +1 for 2 ref in B */
    sps->b_gaps_in_frame_num_value_allowed = 0;
    sps->i_mb_width = (param->i_width + 15) / 16;
    sps->i_mb_height = (param->i_height + 15) / 16;
    sps->b_frame_mbs_only = 1;
    sps->b_mb_adaptive_frame_field = 0;
    sps->b_direct8x8_inference = 0;
    if (sps->b_frame_mbs_only == 0)
    {
        sps->b_direct8x8_inference = 1;
    }

    if (param->i_width % 16 != 0 || param->i_height % 16 != 0)
    {
        sps->b_crop = 1;
        sps->crop.i_left = 0;
        sps->crop.i_right = (16 - param->i_width % 16) / 2;
        sps->crop.i_top = 0;
        sps->crop.i_bottom = (16 - param->i_height % 16) / 2;
    }
    else
    {
        sps->b_crop = 0;
        sps->crop.i_left = 0;
        sps->crop.i_right = 0;
        sps->crop.i_top = 0;
        sps->crop.i_bottom = 0;
    }

    if (param->vui.i_sar_width > 0 && param->vui.i_sar_height > 0)
    {
        int w = param->vui.i_sar_width;
        int h = param->vui.i_sar_height;
        int a = w, b = h;

        while (b != 0)
        {
            int t = a;

            a = b;
            b = t % b;
        }

        w /= a;
        h /= a;
        while (w > 65535 || h > 65535)
        {
            w /= 2;
            h /= 2;
        }

        if (w == 0 || h == 0)
        {
            fprintf(stderr, "x264: cannot create valid sample aspect ratio\n");
            sps->b_vui = 0;
        }
        else if (w == h)
        {
            fprintf(stderr, "x264: no need for a SAR\n");
            sps->b_vui = 0;
        }
        else
        {
            fprintf(stderr, "x264: using SAR=%d/%d\n", w, h);
            sps->b_vui = 1;
            sps->vui.i_sar_width = w;
            sps->vui.i_sar_height = h;
        }
    }
    else
    {
        sps->b_vui = 0;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
leaq 0x67b1(%rip), %rdi      # 0x251b4
leaq 0xdc46(%rip), %rsi      # 0x2c650
leaq 0xdc4d(%rip), %rdx      # 0x2c65e
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x4c22
movl %r15d, (%rbx)
movsd 0xdbea(%rip), %xmm0     # 0x2c610
movups %xmm0, 0x4(%rbx)
movaps 0xdbef(%rip), %xmm0     # 0x2c620
movups %xmm0, 0x14(%rbx)
movl 0x18(%r14), %eax
incl %eax
movl %eax, 0x434(%rbx)
movl %r12d, 0x438(%rbx)
movl 0x4(%r14), %esi
leal 0xf(%rsi), %ecx
leal 0x1e(%rsi), %eax
testl %ecx, %ecx
cmovnsl %ecx, %eax
sarl $0x4, %eax
movl %eax, 0x43c(%rbx)
movl 0x8(%r14), %edx
leal 0xf(%rdx), %eax
leal 0x1e(%rdx), %edi
testl %eax, %eax
cmovnsl %eax, %edi
sarl $0x4, %edi
movl %edi, 0x440(%rbx)
movq $0x1, 0x444(%rbx)
movl %r12d, 0x44c(%rbx)
movl %esi, %edi
orl %edx, %edi
testb $0xf, %dil
jne 0x1eaaa
leaq 0x450(%rbx), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
jmp 0x1eae9
movq $0x1, 0x450(%rbx)
testl %esi, %esi
cmovnsl %esi, %ecx
andl $-0x10, %ecx
subl %esi, %ecx
addl $0x10, %ecx
shrl %ecx
movl %ecx, 0x458(%rbx)
movl $0x0, 0x45c(%rbx)
testl %edx, %edx
cmovnsl %edx, %eax
andl $-0x10, %eax
subl %edx, %eax
addl $0x10, %eax
shrl %eax
movl %eax, 0x460(%rbx)
movl 0x10(%r14), %ecx
testl %ecx, %ecx
jle 0x1eaf9
movl 0xc(%r14), %esi
testl %esi, %esi
jg 0x1eb0c
movl $0x0, 0x464(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %edx
movl %ecx, %edi
movl %edi, %eax
movl %edx, %edi
xorl %edx, %edx
divl %edi
testl %edx, %edx
jne 0x1eb10
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %eax, %ecx
movl %esi, %eax
xorl %edx, %edx
divl %edi
movl $0x10000, %edx          # imm = 0x10000
cmpl %edx, %ecx
setl %sil
cmpl %edx, %eax
setl %dl
testb %dl, %sil
jne 0x1eb66
movl $0x20000, %edx          # imm = 0x20000
movl %ecx, %r14d
movl %eax, %r15d
shrl %r14d
shrl %r15d
cmpl %edx, %ecx
setae %cl
cmpl %edx, %eax
setae %al
orb %cl, %al
movl %r15d, %eax
movl %r14d, %ecx
jne 0x1eb4a
jmp 0x1eb6c
movl %ecx, %r14d
movl %eax, %r15d
testl %r14d, %r14d
sete %al
testl %r15d, %r15d
sete %cl
orb %al, %cl
leaq 0x464(%rbx), %r12
cmpb $0x1, %cl
jne 0x1eb93
movq %r12, %rdi
callq 0x3038
jmp 0x1eb03
movq 0x13436(%rip), %rax     # 0x31fd0
movq (%rax), %rcx
cmpl %r15d, %r14d
jne 0x1ebc5
leaq 0xdaf2(%rip), %rdi      # 0x2c69b
movl $0x18, %esi
movl $0x1, %edx
callq 0x21f0
movl $0x0, (%r12)
jmp 0x1eb03
leaq 0xdae8(%rip), %rsi      # 0x2c6b4
movq %rcx, %rdi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2180
movl $0x1, 0x464(%rbx)
movl %r14d, 0x468(%rbx)
movl %r15d, 0x46c(%rbx)
jmp 0x1eb03