int main(int argc, char* argv[])

{

    FILE *f[2];

    uint8_t *buf[2], *plane[2][3];

    int *temp;

    uint64_t ssd[3] = {0,0,0};

    double ssim[3] = {0,0,0};

    int frame_size, w, h;

    int frames, seek;

    int i;



    if( argc<4 || 2 != sscanf(argv[3], "%dx%d", &w, &h) )

    {

        printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\n");

        return -1;

    }



    f[0] = fopen(argv[1], "rb");

    f[1] = fopen(argv[2], "rb");

    sscanf(argv[3], "%dx%d", &w, &h);

    frame_size = w*h*3/2;

    for( i=0; i<2; i++ )

    {

        buf[i] = malloc(frame_size);

        plane[i][0] = buf[i];

        plane[i][1] = plane[i][0] + w*h;

        plane[i][2] = plane[i][1] + w*h/4;

    }

    temp = malloc((2*w+12)*sizeof(*temp));

    seek = argc<5 ? 0 : atoi(argv[4]);

    fseek(f[seek<0], seek < 0 ? -seek : seek, SEEK_SET);



    for( frames=0;; frames++ )

    {

        uint64_t ssd_one[3];

        double ssim_one[3];

        if( fread(buf[0], frame_size, 1, f[0]) != 1) break;

        if( fread(buf[1], frame_size, 1, f[1]) != 1) break;

        for( i=0; i<3; i++ )

        {

            ssd_one[i]  = ssd_plane ( plane[0][i], plane[1][i], w*h>>2*!!i );

            ssim_one[i] = ssim_plane( plane[0][i], w>>!!i,

                                     plane[1][i], w>>!!i,

                                     w>>!!i, h>>!!i, temp, NULL );

            ssd[i] += ssd_one[i];

            ssim[i] += ssim_one[i];

        }



        printf("Frame %d | ", frames);

        print_results(ssd_one, ssim_one, 1, w, h);

        printf("                \r");

        fflush(stdout);

    }



    if( !frames ) return 0;



    printf("Total %d frames | ", frames);

    print_results(ssd, ssim, frames, w, h);

    printf("\n");



    return 0;

}

int main(int argc, char* argv[])

{

    FILE *f[2];

    uint8_t *buf[2], *plane[2][3];

    int *temp;

    uint64_t ssd[3] = {0,0,0};

    double ssim[3] = {0,0,0};

    int frame_size, w, h;

    int frames, seek;

    int i;



    if( argc<4 || 2 != sscanf(argv[3], "%dx%d", &w, &h) )

    {

        printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<seek>]\n");

        return -1;

    }



    f[0] = fopen(argv[1], "rb");

    f[1] = fopen(argv[2], "rb");

    sscanf(argv[3], "%dx%d", &w, &h);

    frame_size = w*h*3/2;

    for( i=0; i<2; i++ )

    {

        buf[i] = malloc(frame_size);

        plane[i][0] = buf[i];

        plane[i][1] = plane[i][0] + w*h;

        plane[i][2] = plane[i][1] + w*h/4;

    }

    temp = malloc((2*w+12)*sizeof(*temp));

    seek = argc<5 ? 0 : atoi(argv[4]);

    fseek(f[seek<0], seek < 0 ? -seek : seek, SEEK_SET);



    for( frames=0;; frames++ )

    {

        uint64_t ssd_one[3];

        double ssim_one[3];

        if( fread(buf[0], frame_size, 1, f[0]) != 1) break;

        if( fread(buf[1], frame_size, 1, f[1]) != 1) break;

        for( i=0; i<3; i++ )

        {

            ssd_one[i]  = ssd_plane ( plane[0][i], plane[1][i], w*h>>2*!!i );

            ssim_one[i] = ssim_plane( plane[0][i], w>>!!i,

                                     plane[1][i], w>>!!i,

                                     w>>!!i, h>>!!i, temp, NULL );

            ssd[i] += ssd_one[i];

            ssim[i] += ssim_one[i];

        }



        printf("Frame %d | ", frames);

        print_results(ssd_one, ssim_one, 1, w, h);

        printf("                \r");

        fflush(stdout);

    }



    if( !frames ) return 0;



    printf("Total %d frames | ", frames);

    print_results(ssd, ssim, frames, w, h);

    printf("\n");



    return 0;

}

    frame_size = w*h*3/2;
int FUNC_0(int VAR_0, char* VAR_1[])

{

    FILE *f[2];

    uint8_t *buf[2], *plane[2][3];

    int *VAR_2;

    uint64_t ssd[3] = {0,0,0};

    double VAR_3[3] = {0,0,0};

    int VAR_4, VAR_5, VAR_6;

    int VAR_7, VAR_8;

    int VAR_9;



    if( VAR_0<4 || 2 != sscanf(VAR_1[3], "%dx%d", &VAR_5, &VAR_6) )

    {

        printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<VAR_8>]\n");

        return -1;

    }



    f[0] = fopen(VAR_1[1], "rb");

    f[1] = fopen(VAR_1[2], "rb");

    sscanf(VAR_1[3], "%dx%d", &VAR_5, &VAR_6);

    VAR_4 = VAR_5*VAR_6*3/2;

    for( VAR_9=0; VAR_9<2; VAR_9++ )

    {

        buf[VAR_9] = malloc(VAR_4);

        plane[VAR_9][0] = buf[VAR_9];

        plane[VAR_9][1] = plane[VAR_9][0] + VAR_5*VAR_6;

        plane[VAR_9][2] = plane[VAR_9][1] + VAR_5*VAR_6/4;

    }

    VAR_2 = malloc((2*VAR_5+12)*sizeof(*VAR_2));

    VAR_8 = VAR_0<5 ? 0 : atoi(VAR_1[4]);

    fseek(f[VAR_8<0], VAR_8 < 0 ? -VAR_8 : VAR_8, SEEK_SET);



    for( VAR_7=0;; VAR_7++ )

    {

        uint64_t ssd_one[3];

        double VAR_10[3];

        if( fread(buf[0], VAR_4, 1, f[0]) != 1) break;

        if( fread(buf[1], VAR_4, 1, f[1]) != 1) break;

        for( VAR_9=0; VAR_9<3; VAR_9++ )

        {

            ssd_one[VAR_9]  = ssd_plane ( plane[0][VAR_9], plane[1][VAR_9], VAR_5*VAR_6>>2*!!VAR_9 );

            VAR_10[VAR_9] = ssim_plane( plane[0][VAR_9], VAR_5>>!!VAR_9,

                                     plane[1][VAR_9], VAR_5>>!!VAR_9,

                                     VAR_5>>!!VAR_9, VAR_6>>!!VAR_9, VAR_2, NULL );

            ssd[VAR_9] += ssd_one[VAR_9];

            VAR_3[VAR_9] += VAR_10[VAR_9];

        }



        printf("Frame %d | ", VAR_7);

        print_results(ssd_one, VAR_10, 1, VAR_5, VAR_6);

        printf("                \r");

        fflush(stdout);

    }



    if( !VAR_7 ) return 0;



    printf("Total %d VAR_7 | ", VAR_7);

    print_results(ssd, VAR_3, VAR_7, VAR_5, VAR_6);

    printf("\n");



    return 0;

}

int FUNC_0(int VAR_0, char* VAR_1[])
{ FILE *f[2]; uint8_t *buf[2], *plane[2][3]; int *VAR_2; uint64_t ssd[3] = {0,0,0}; double VAR_3[3] = {0,0,0}; int VAR_4, VAR_5, VAR_6; int VAR_7, VAR_8; int VAR_9; if( VAR_0<4 || 2 != sscanf(VAR_1[3], "%dx%d", &VAR_5, &VAR_6) )
{ printf("tiny_ssim <file1.yuv> <file2.yuv> <width>x<height> [<VAR_8>]\n"); return -1; } f[0] = fopen(VAR_1[1], "rb"); f[1] = fopen(VAR_1[2], "rb"); sscanf(VAR_1[3], "%dx%d", &VAR_5, &VAR_6); VAR_4 = VAR_5*VAR_6*3/2; for( VAR_9=0; VAR_9<2; VAR_9++ ) { buf[VAR_9] = malloc(VAR_4); plane[VAR_9][0] = buf[VAR_9]; plane[VAR_9][1] = plane[VAR_9][0] + VAR_5*VAR_6; plane[VAR_9][2] = plane[VAR_9][1] + VAR_5*VAR_6/4; } VAR_2 = malloc((2*VAR_5+12)*sizeof(*VAR_2)); VAR_8 = VAR_0<5 ? 0 : atoi(VAR_1[4]); fseek(f[VAR_8<0], VAR_8 < 0 ? -VAR_8 : VAR_8, SEEK_SET); for( VAR_7=0;; VAR_7++ ) { uint64_t ssd_one[3]; double VAR_10[3]; if( fread(buf[0], VAR_4, 1, f[0]) != 1) break; if( fread(buf[1], VAR_4, 1, f[1]) != 1) break; for( VAR_9=0; VAR_9<3; VAR_9++ ) { ssd_one[VAR_9]  = ssd_plane ( plane[0][VAR_9], plane[1][VAR_9], VAR_5*VAR_6>>2*!!VAR_9 ); VAR_10[VAR_9] = ssim_plane( plane[0][VAR_9], VAR_5>>!!VAR_9,
plane[1][VAR_9], VAR_5>>!!VAR_9,
VAR_5>>!!VAR_9, VAR_6>>!!VAR_9, VAR_2, NULL ); ssd[VAR_9] += ssd_one[VAR_9]; VAR_3[VAR_9] += VAR_10[VAR_9]; } printf("Frame %d | ", VAR_7); print_results(ssd_one, VAR_10, 1, VAR_5, VAR_6); printf("                \r"); fflush(stdout); } if( !VAR_7 ) return 0; printf("Total %d VAR_7 | ", VAR_7); print_results(ssd, VAR_3, VAR_7, VAR_5, VAR_6); printf("\n"); return 0; }