// File: /workspace/github_cpp_makefile_star2_O3/zhangk145[P]video_envalue/Envaluer.cpp
// Function: Envaluer::compute_ssim(unsigned char*, int, unsigned char*, int, int, int)
float Envaluer::compute_ssim(uint8_t *pix1, int stride1,
                   uint8_t *pix2, int stride2,
                   int width, int height)
{
    int x, y, z;
    float ssim = 0.0;
    // printf("[%s:%d]==\n", __FUNCTION__, __LINE__);
    int (*sum0)[4] = (int (*)[4])x264_alloca(4 * (width/4+3) * sizeof(int));
    int (*sum1)[4] = (int (*)[4])x264_alloca(4 * (width/4+3) * sizeof(int));
    // void *sumTmp0 = (void *)sum0;
    // void *sumTmp1 = (void *)sum1;
    width >>= 2;
    height >>= 2;
    z = 0;
    // printf("[%s:%d]width:%d height:%d\n", __FUNCTION__, __LINE__, width, height);
    for( y = 1; y < height; y++ )
    {
        for( ; z <= y; z++ )
        {
            int (*t)[4] = sum0;
            sum0 = sum1;
            sum1 = t;
            // XCHG( , sum0, sum1 );
            for( x = 0; x < width; x+=2 )
                ssim_4x4x2_core( &pix1[4*(x+z*stride1)], stride1, &pix2[4*(x+z*stride2)], stride2, &sum0[x] );
        }
        for( x = 0; x < width-1; x += 4 ) {
            ssim += ssim_end4( sum0+x, sum1+x, X264_MIN(4,width-x-1) );
            // printf("[%s:%d]==ssim:%.3f\n", __FUNCTION__, __LINE__, ssim);
        }
    }
    // printf("[%s:%d]==\n", __FUNCTION__, __LINE__);
    return ssim / ((width-1) * (height-1));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, -0x90(%rbp)
movl %edx, %edi
movq %rsi, -0x88(%rbp)
movl 0x10(%rbp), %ecx
leal 0x3(%r9), %eax
testl %r9d, %r9d
cmovnsl %r9d, %eax
andl $-0x4, %eax
addl $0xc, %eax
cltq
leaq 0x1e(,%rax,4), %rax
andq $-0x10, %rax
movq %rsp, %rdx
subq %rax, %rdx
movq %rdx, -0x48(%rbp)
movq %rdx, %rsp
movq %rsp, %r13
subq %rax, %r13
movq %r13, %rsp
sarl $0x2, %r9d
sarl $0x2, %ecx
cmpl $0x1, %ecx
jle 0x3035
leal -0x1(%r9), %eax
movslq %r9d, %rdx
movq %rdx, -0xb8(%rbp)
movslq %edi, %rdx
movl %r8d, -0x58(%rbp)
movslq %r8d, %rsi
movl %eax, -0x3c(%rbp)
cltq
movq %rax, -0xa0(%rbp)
movl %ecx, -0x54(%rbp)
movl %ecx, %eax
movq %rax, -0x98(%rbp)
shlq $0x2, %rsi
movq %rsi, -0x68(%rbp)
shlq $0x2, %rdx
movq %rdx, -0x70(%rbp)
xorl %ecx, %ecx
xorps %xmm1, %xmm1
movl $0x1, %eax
movq %r9, -0x78(%rbp)
movl %edi, -0x5c(%rbp)
movq %rax, -0x80(%rbp)
movslq %ecx, %rdx
cmpq %rdx, %rax
jl 0x2fb6
movss %xmm1, -0x2c(%rbp)
movq -0x68(%rbp), %rax
imulq %rdx, %rax
addq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x70(%rbp), %rax
imulq %rdx, %rax
addq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %rdx, -0xb0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq %r13, -0x48(%rbp)
testl %r9d, %r9d
movl -0x58(%rbp), %r14d
jle 0x2f70
movq -0x48(%rbp), %r15
movq -0x50(%rbp), %r13
movq -0x38(%rbp), %rbx
xorl %r12d, %r12d
movq %r13, %rsi
movl -0x5c(%rbp), %edx
movq %rbx, %rcx
movl %r14d, %r8d
movq %r15, %r9
callq 0x2b84
movq -0xb8(%rbp), %rcx
addq $0x2, %r12
addq $0x8, %rbx
addq $0x8, %r13
addq $0x20, %r15
cmpq %rcx, %r12
jl 0x2f40
movq -0xb0(%rbp), %rax
leaq 0x1(%rax), %rcx
movq -0x38(%rbp), %rdx
addq -0x68(%rbp), %rdx
movq %rdx, -0x38(%rbp)
movq -0x50(%rbp), %rdx
addq -0x70(%rbp), %rdx
movq %rdx, -0x50(%rbp)
movq -0xa8(%rbp), %rsi
movq %rsi, %r13
cmpq -0x80(%rbp), %rax
movq %rcx, %rdx
movq -0x78(%rbp), %r9
jl 0x2f12
movq %rsi, %r13
movss -0x2c(%rbp), %xmm1
movq %rcx, -0x38(%rbp)
cmpl $0x2, %r9d
jl 0x300b
movl -0x3c(%rbp), %ebx
movq -0x48(%rbp), %r15
movq %r13, %r14
xorl %r12d, %r12d
movss %xmm1, -0x2c(%rbp)
cmpl $0x4, %ebx
movl $0x4, %ecx
cmovll %ebx, %ecx
movq %r15, %rsi
movq %r13, %rdx
callq 0x2d0c
movss -0x2c(%rbp), %xmm1
addss %xmm0, %xmm1
addq $0x4, %r12
addq $0x40, %r13
addq $0x40, %r15
addl $-0x4, %ebx
cmpq -0xa0(%rbp), %r12
jl 0x2fcd
jmp 0x300e
movq %r13, %r14
movq -0x80(%rbp), %rax
incq %rax
cmpq -0x98(%rbp), %rax
movq -0x78(%rbp), %r9
movq %r14, %r13
movq -0x38(%rbp), %rcx
jne 0x2ed7
movl -0x54(%rbp), %ecx
movl -0x3c(%rbp), %eax
jmp 0x303e
decl %r9d
xorps %xmm1, %xmm1
movl %r9d, %eax
decl %ecx
imull %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
divss %xmm0, %xmm1
movaps %xmm1, %xmm0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq