// File: /workspace/github_c_makefile_star2_O3/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 0x7a41(%rip), %rdi      # 0x271b4
leaq 0xec16(%rip), %rsi      # 0x2e390
leaq 0xec1d(%rip), %rdx      # 0x2e39e
xorl %r12d, %r12d
xorl %eax, %eax
callq 0x4a56
movl %r15d, (%rbx)
movsd 0xebba(%rip), %xmm0     # 0x2e350
movups %xmm0, 0x4(%rbx)
movaps 0xebbf(%rip), %xmm0     # 0x2e360
movups %xmm0, 0x14(%rbx)
movl 0x18(%r14), %eax
incl %eax
movl %eax, 0x434(%rbx)
movl %r12d, 0x438(%rbx)
movl 0x4(%r14), %edx
leal 0xf(%rdx), %eax
leal 0x1e(%rdx), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x4, %ecx
movl %ecx, 0x43c(%rbx)
movl 0x8(%r14), %esi
leal 0xf(%rsi), %ecx
leal 0x1e(%rsi), %edi
testl %ecx, %ecx
cmovnsl %ecx, %edi
sarl $0x4, %edi
movl %edi, 0x440(%rbx)
movq $0x1, 0x444(%rbx)
movl %r12d, 0x44c(%rbx)
movl %edx, %r10d
orl %esi, %r10d
movl $0x0, %edi
movl $0x0, %r8d
movl $0x0, %r9d
testb $0xf, %r10b
je 0x1f840
testl %edx, %edx
cmovnsl %edx, %eax
andl $-0x10, %eax
subl %edx, %eax
addl $0x10, %eax
shrl %eax
testl %esi, %esi
cmovnsl %esi, %ecx
andl $-0x10, %ecx
subl %esi, %ecx
addl $0x10, %ecx
shrl %ecx
movl $0x1, %edi
movl %eax, %r8d
movl %ecx, %r9d
movl %edi, 0x450(%rbx)
movl %r12d, 0x454(%rbx)
movl %r8d, 0x458(%rbx)
movl %r12d, 0x45c(%rbx)
movl %r9d, 0x460(%rbx)
movl 0x10(%r14), %ecx
testl %ecx, %ecx
jle 0x1f872
movl 0xc(%r14), %esi
testl %esi, %esi
jg 0x1f885
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 0x1f889
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 0x1f8df
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 0x1f8c3
jmp 0x1f8e5
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 0x1f90c
movq %r12, %rdi
callq 0x2f1b
jmp 0x1f87c
movq 0x136bd(%rip), %rax     # 0x32fd0
movq (%rax), %rcx
cmpl %r15d, %r14d
jne 0x1f93e
leaq 0xeab9(%rip), %rdi      # 0x2e3db
movl $0x18, %esi
movl $0x1, %edx
callq 0x21e0
movl $0x0, (%r12)
jmp 0x1f87c
leaq 0xeaaf(%rip), %rsi      # 0x2e3f4
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 0x1f87c