// File: /workspace/github_c_makefile_star2_O2/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 0x58f5(%rip), %rdi      # 0x1b1b4
leaq 0xccda(%rip), %rsi      # 0x225a0
leaq 0xcce1(%rip), %rdx      # 0x225ae
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x39ba
movl %r15d, (%rbx)
movsd 0xcc7e(%rip), %xmm0     # 0x22560
movups %xmm0, 0x4(%rbx)
movaps 0xcc83(%rip), %xmm0     # 0x22570
movups %xmm0, 0x14(%rbx)
movl 0x18(%r14), %eax
incl %eax
movl %eax, 0x434(%rbx)
andl $0x0, 0x438(%rbx)
movl 0x4(%r14), %ecx
leal 0xf(%rcx), %eax
pushq $0x10
popq %rdi
cltd
idivl %edi
movl %eax, 0x43c(%rbx)
movl 0x8(%r14), %esi
leal 0xf(%rsi), %eax
cltd
idivl %edi
movl %eax, 0x440(%rbx)
movq $0x1, 0x444(%rbx)
andl $0x0, 0x44c(%rbx)
movl %ecx, %edx
orl %esi, %edx
movl $0x0, %r8d
movl $0x0, %eax
testb $0xf, %dl
je 0x1596a
movl %ecx, %eax
cltd
idivl %edi
movl %edi, %r8d
subl %edx, %r8d
shrl %r8d
movl %esi, %eax
cltd
idivl %edi
subl %edx, %edi
shrl %edi
pushq $0x1
popq %r12
movl %edi, %eax
movl %r12d, 0x450(%rbx)
andl $0x0, 0x454(%rbx)
movl %r8d, 0x458(%rbx)
andl $0x0, 0x45c(%rbx)
movl %eax, 0x460(%rbx)
movl 0x10(%r14), %esi
testl %esi, %esi
jle 0x1599c
movl 0xc(%r14), %ecx
testl %ecx, %ecx
jg 0x159ac
andl $0x0, 0x464(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %esi, %edi
movl %ecx, %r8d
testl %r8d, %r8d
je 0x159c5
movl %edi, %eax
xorl %edx, %edx
divl %r8d
movl %r8d, %edi
movl %edx, %r8d
jmp 0x159b1
movl %esi, %eax
xorl %edx, %edx
divl %edi
movl %eax, %r14d
movl %ecx, %eax
xorl %edx, %edx
divl %edi
movl %eax, %r15d
movl $0x10000, %eax          # imm = 0x10000
cmpl %eax, %r14d
setge %cl
cmpl %eax, %r15d
setge %dl
orb %cl, %dl
cmpb $0x1, %dl
jne 0x159f7
shrl %r14d
shrl %r15d
jmp 0x159dc
testl %r14d, %r14d
sete %al
testl %r15d, %r15d
sete %cl
orb %al, %cl
movq 0x125c4(%rip), %rax     # 0x27fd0
cmpb $0x1, %cl
jne 0x15a1f
movq (%rax), %rcx
leaq 0xcba1(%rip), %rdi      # 0x225bc
pushq $0x2e
jmp 0x15a30
movq (%rax), %rcx
cmpl %r15d, %r14d
jne 0x15a3e
leaq 0xcbbd(%rip), %rdi      # 0x225eb
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x21e0
jmp 0x1599c
leaq 0xcbbf(%rip), %rsi      # 0x22604
movq %rcx, %rdi
movl %r14d, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x2170
movl $0x1, 0x464(%rbx)
movl %r14d, 0x468(%rbx)
movl %r15d, 0x46c(%rbx)
jmp 0x159a3