From b5fe3f5d8974f5a4d65c57f2a2d24389f1eede6a Mon Sep 17 00:00:00 2001 From: Software Mechanic Date: Fri, 10 Apr 2015 00:06:15 +0530 Subject: [PATCH 1/4] Successful build of binary for taking a interval value. Still needs testing on running and memory leaks. --- src/film.cc | 20 ++++++++++++-------- src/film.h | 7 +++++++ src/main.cc | 7 ++++++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/film.cc b/src/film.cc index 5ab7da3..d310fd0 100644 --- a/src/film.cc +++ b/src/film.cc @@ -130,8 +130,8 @@ void film::CompareFrame (AVFrame * pFrame, AVFrame * pFramePrev) score = 0; // IDEA! Split image in slices and calculate score per-slice. - // This would allow to detect areas on the image which have stayed - // the same, and (a) increase score if all areas have changed + // This would allow to detect areas on the image which have stayed + // the same, and (a) increase score if all areas have changed // and (b) decrease score if some areas have changed less (ot not at all). for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { @@ -311,7 +311,7 @@ int film::process () * Register all formats and codecs */ av_register_all (); - pFormatCtx = avformat_alloc_context (); + pFormatCtx = avformat_alloc_context (); if (avformat_open_input (&pFormatCtx, input_path.c_str (), NULL, NULL) != 0) { string error_msg = "Could not open file "; error_msg += input_path; @@ -354,7 +354,7 @@ int film::process () */ if (audioStream != -1) { if (audio_set) { - + string xml_audio = graphpath + "/" + alphaid + "_audio.xml"; init_xml (xml_audio); } @@ -383,15 +383,19 @@ int film::process () return -1; // Could not open codec /* - * Allocate current and previous video frames + * Allocate current and previous video frames */ pFrame = avcodec_alloc_frame (); // RGB: pFrameRGB = avcodec_alloc_frame (); // current frame + for (int j=0;jinterval; j++){ + tempRGBprev = avcodec_alloc_frame(); + av_free(tempRGBprev); + } pFrameRGBprev = avcodec_alloc_frame (); // previous frame // YUV: pFrameYUV = avcodec_alloc_frame (); // current frame - + /* * Allocate memory for the pixels of a picture and setup the AVPicture fields for it */ @@ -457,7 +461,7 @@ int film::process () } } - /* + /* * Calling "sws_scale" is used to copy the data from "pFrame->data" to other * frame buffers for later processing. It is also used to convert between * different pix_fmts. @@ -554,7 +558,7 @@ int film::process () av_free (pFrameYUV); avcodec_close (pCodecCtx); } - + // Close the codec if (audioStream != -1) { /* Close the XML file */ diff --git a/src/film.h b/src/film.h index 26a9e7b..9588b73 100644 --- a/src/film.h +++ b/src/film.h @@ -91,6 +91,7 @@ class film // - RGB: AVFrame *pFrameRGB; AVFrame *pFrameRGBprev; + AVFrame *tempRGBprev; // - YUV: AVFrame *pFrameYUV; @@ -200,6 +201,9 @@ class film bool draw_hsv_graph; bool draw_yuv_graph; + /* Interval of frames to skip*/ + int interval; + xml *x; bool display; @@ -251,6 +255,9 @@ class film inline void set_year(int year) { this->year=year; }; + inline void set_interval(int interval) { + this->interval=interval; + } inline void set_alphaid(string alphaid) { this->alphaid = alphaid; }; diff --git a/src/main.cc b/src/main.cc index ee16e7b..a19b5e0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -57,6 +57,7 @@ void show_help (char **argv) { "-m : generate the thumbnail image\n" "-r : generate the images in native resolution\n" "-c : print timecode on x-axis in graph\n", + "-z : Interval to compare frames across(Default 1)\n", g_APP_VERSION, argv[0], DEFAULT_THRESHOLD @@ -82,7 +83,7 @@ int main (int argc, char **argv) { f.threshold=DEFAULT_THRESHOLD; for (;;) { - int c = getopt (argc, argv, "?hnt:y:i:o:a:x:s:flwvmrc"); + int c = getopt (argc, argv, "?hnt:y:i:o:a:x:s:flwvmrcz"); if (c < 0) { break; @@ -174,6 +175,10 @@ int main (int argc, char **argv) { gui = false; break; + /* Compare across this interval */ + case 'z': + interval = f.set_interval(optarg); + break; default: break; From 4cd790e9f8d46830d3a1fc2625b2d59cce2641a2 Mon Sep 17 00:00:00 2001 From: Software Mechanic Date: Sun, 12 Apr 2015 16:09:11 +0530 Subject: [PATCH 2/4] unneccessary call to av_free.since there's no alloc --- src/film.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/film.cc b/src/film.cc index d310fd0..64ed252 100644 --- a/src/film.cc +++ b/src/film.cc @@ -390,7 +390,6 @@ int film::process () pFrameRGB = avcodec_alloc_frame (); // current frame for (int j=0;jinterval; j++){ tempRGBprev = avcodec_alloc_frame(); - av_free(tempRGBprev); } pFrameRGBprev = avcodec_alloc_frame (); // previous frame // YUV: From e259766171b41f5d61f485c2fe4e9354912db6d4 Mon Sep 17 00:00:00 2001 From: Software Mechanic Date: Tue, 28 Apr 2015 00:22:04 +0530 Subject: [PATCH 3/4] fixing repeated options for timecode and title --- src/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index a19b5e0..107c809 100644 --- a/src/main.cc +++ b/src/main.cc @@ -132,7 +132,7 @@ int main (int argc, char **argv) { break; /* Embed timecode in graph */ - case 't': + case 'u': f.set_show_timecode(true); break; @@ -177,7 +177,7 @@ int main (int argc, char **argv) { /* Compare across this interval */ case 'z': - interval = f.set_interval(optarg); + f.set_interval(atoi(optarg)); break; default: From 931d313f20761f576ddc8619b5dd7aaa5708f572 Mon Sep 17 00:00:00 2001 From: Software Mechanic Date: Wed, 6 May 2015 00:17:15 +0530 Subject: [PATCH 4/4] fixing repeating switch cases error. --- src/main.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cc b/src/main.cc index 107c809..50d9286 100644 --- a/src/main.cc +++ b/src/main.cc @@ -132,7 +132,7 @@ int main (int argc, char **argv) { break; /* Embed timecode in graph */ - case 'u': + case 'c': f.set_show_timecode(true); break;