Пример #1
0
int main(int argc, char *argv[])
{
    char* filename1 = NULL;
    char* filename2 = NULL;
    const char* eachpsnr = "every_frame_psnr.txt";
    const char* psnrresult = "average_psnr.txt";
    int width=0,height=0;
    int standardpsnr = NORMAL_PSNR;
    char opt;
    while ((opt = getopt(argc, argv, "h:W:H:i:o:s:?")) != -1)
    {
        switch (opt) {
            case 'h':
            case '?':
                print_help(argv[0]);
                return false;
            case 'i':
                filename1 = optarg;
                break;
            case 'o':
                filename2 = optarg;
                break;
            case 'W':
                width = atoi(optarg);
                break;
            case 'H':
                height = atoi(optarg);;
                break;
            case 's':
                standardpsnr = atoi(optarg);;
                break;
            default:
                print_help(argv[0]);
                break;
        }
    }
    if(argc==1) {
        print_help(argv[0]);
        return -1;
    }

    if ( !filename1 || !filename2 ) {
        fprintf(stderr, "no comparison media file specified\n");
        return -1;
    }
    if ((width <= 0) ||(height <= 0) ||(width > MAX_WIDTH) || (height > MAX_HEIGHT)) {
        printf("input width and height is invalid\n");
        return -1;
    }
    printf(" filename1 %s\n filename2 %s\n result    %s \n",filename1,filename2,psnrresult);
    return psnr_calculate(filename1,filename2,eachpsnr,psnrresult,width,height,standardpsnr);
}
Пример #2
0
int main(int argc, char *argv[])
{
    char filename1[256] = {0};
    char filename2[256] = {0};
    char eachpsnr[256] = {0};
    char psnrresult[256] = {0};
    int width=0,height=0;
    char opt;
    char *path = NULL;
    while ((opt = getopt(argc, argv, "h:W:H:i:o:?")) != -1)
    {
        switch (opt) {
            case 'h':
            case '?':
                print_help (argv[0]);
                return false;
            case 'i':
                strcpy(filename1,optarg);
                break;
            case 'o':
                strcpy(filename2,optarg);
                strcat(eachpsnr,filename2);
                strcat(eachpsnr,".txt");
                if (path = strrchr (filename2, '/'))
                    path++;
                memcpy(psnrresult,filename2,path-filename2);
                strcat(psnrresult,"jpg_psnr.txt");
                break;
            case 'W':
                width = atoi(optarg);
                break;
            case 'H':
                height = atoi(optarg);;
                break;
            default:
                print_help(argv[0]);
                break;
        }
    }
    if(argc==1) {
        print_help(argv[0]);
        return -1;
    }

    if (!filename1) {
        fprintf(stderr, "no input media file specified\n");
        return -1;
    }
    printf(" filename1 %s\n filename2 %s\n result    %s \n",filename1,filename2,psnrresult);
    return psnr_calculate(filename1,filename2,eachpsnr,psnrresult,width,height);
}