Jump to content

open and read video files in yuv format to calculate psnr

- - - - -

  • Please log in to reply
No replies to this topic

#1
kuvlu

kuvlu

    Newbie

  • Members
  • Pip
  • 1 posts
Hi there,
i am relatively new in c and c++, and i have been trying to use this as a tool in a project.
i find it difficult to open read and close two seperate video files for comparison sake. while open, i intend to calculate the diffrence in the Y, U and V parameters of the video
below i have attached part of the program to do this. even tough it compiles, i still cant get the program to effectively open the files needed for the computation ( it should be video file yuv format saved in the computer.
i would appreciate if any one can help me with this

Or alternatively if there is an easier way to open the file , save the pixels in memory and continue with the calculation, i would appreciate

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



                                  FILE *out = stdout;


                                  FILE *frame1 = stdin;


                                  FILE *frame2 = NULL;


                                  int i, j, c, r;



                                  char frame1_name[MAXPATHLEN] = "(stdin)";  // truncates length at arg desired for array


                                  char frame2_name[MAXPATHLEN] = "(none)";


                                  char output_name[MAXPATHLEN] = "(stdout)";


                                  int downsample = 2;


                                  int width = 352; // considering CIF


                                  int height = 288;


                                  unsigned char *y2, *u2, *v2, *y, *u, *v;  // yuv parameters of input and output video


                                  int ysize, usize, vsize;


                                  paris = argv[0];


                                  while ((c = getopt(argc, argv, "d:i:h?x:y:o:")) != EOF) {


                                                                                            switch (c) {


                                                                                                        case 'h':


                                                                                                        case '?':


                                                                                                        usage();


                                                                                                        break;


                                                                                                        case 'd':


                                                                                                        downsample = atoi(optarg);


                                                                                                        break;


                                                                                                        case 'i':


                                                                                                        if ((frame2 = fopen(optarg, "rb")) == NULL) {


                                                                                                                                                    fprintf(stderr, "%s: unable to open output file %s\n", paris, optarg);


                                                                                                                                                    exit(EXIT_FAILURE);


                                                                                                                                                    }


                                                                                                        strcpy(frame2_name, optarg);


                                                                                                        break;


                                                                                                        case 'x':


                                                                                                        width = atoi(optarg);


                                                                                                        break;


                                                                                                        case 'y':


                                                                                                        height = atoi(optarg);


                                                                                                        break;


                                                                                                        case 'o':


                                                                                                        if ((out = fopen(optarg, "wb")) == NULL) {


                                                                                                                                                  fprintf(stderr, "%s: unable to open output file %s\n", paris, optarg);


                                                                                                                                                  exit(EXIT_FAILURE);


                                                                                                                                                 }


                                                                                                        strcpy(output_name, optarg);


                                                                                                        break;


                                                                                                        }


                                                                                        }




                        argc -= optind;


                        argv += optind;


                        if (argc > 1) {


                                        usage();


                                        exit(1);


                                      }


                        if (frame2 == NULL) {


                                            fprintf(stderr, "%s: original image must be given, use -i name.YUV\n", paris);


                                            exit(EXIT_FAILURE);


                                            }



                       if (argc == 1 && *argv[0] != '-')


                       if ((frame1 = fopen(argv[0], "rb")) == NULL) {


                                                                     fprintf(stderr, "%s: unable to open input file %s\n", paris, argv[0]);


                                                                     exit(1);


                                                                    }


 				      else


                      strcpy(frame1_name, argv[0]);


                      ysize = width * height;


                      usize = (width / downsample) * (height / downsample);


                      vsize = (width / downsample) * (height / downsample);


				 }

Edited by WingedPanther, 04 May 2008 - 04:07 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users