[FFmpeg-cvslog] avfilter/vsrc_mptestsrc: add options to set the maximum number of frames

Limin Wang git at videolan.org
Tue Oct 22 00:16:12 EEST 2019


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Mon Oct 21 18:12:11 2019 +0800| [6079bd5c63e5ef50d110f622d3fab02a48c3a2b0] | committer: Michael Niedermayer

avfilter/vsrc_mptestsrc: add options to set the maximum number of frames

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6079bd5c63e5ef50d110f622d3fab02a48c3a2b0
---

 doc/filters.texi             |  3 +++
 libavfilter/vsrc_mptestsrc.c | 29 +++++++++++++++++------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index bdc4136a22..7400e7dd31 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20940,6 +20940,9 @@ Set the number or the name of the test to perform. Supported tests are:
 @item ring2
 @item all
 
+ at item max_frames, m
+Set the maximum number of frames generated for each test, default value is 30.
+
 @end table
 
 Default value is "all", which will cycle through the list of all tests.
diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index c5fdea75dc..31c68939e4 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -54,6 +54,7 @@ typedef struct MPTestContext {
     const AVClass *class;
     AVRational frame_rate;
     int64_t pts, max_pts, duration;
+    int64_t max_frames;
     int hsub, vsub;
     int test;           ///< test_type
 } MPTestContext;
@@ -79,6 +80,10 @@ static const AVOption mptestsrc_options[]= {
         { "ring1",       "", 0, AV_OPT_TYPE_CONST, {.i64=TEST_RING1},       INT_MIN, INT_MAX, FLAGS, "test" },
         { "ring2",       "", 0, AV_OPT_TYPE_CONST, {.i64=TEST_RING2},       INT_MIN, INT_MAX, FLAGS, "test" },
         { "all",         "", 0, AV_OPT_TYPE_CONST, {.i64=TEST_ALL},         INT_MIN, INT_MAX, FLAGS, "test" },
+    { "max_frames", "Set the maximum number of frames generated for each test", OFFSET(max_frames),
+        AV_OPT_TYPE_INT64, {.i64 = 30}, 1, INT64_MAX, FLAGS },
+    { "m",          "Set the maximum number of frames generated for each test", OFFSET(max_frames),
+        AV_OPT_TYPE_INT64, {.i64 = 30}, 1, INT64_MAX, FLAGS },
     { NULL }
 };
 
@@ -322,20 +327,20 @@ static int request_frame(AVFilterLink *outlink)
         memset(picref->data[2] + i*picref->linesize[2], 128, cw);
     }
 
-    if (tt == TEST_ALL && frame%30) /* draw a black frame at the beginning of each test */
-        tt = (frame/30)%(TEST_NB-1);
+    if (tt == TEST_ALL && frame%test->max_frames) /* draw a black frame at the beginning of each test */
+        tt = (frame/test->max_frames)%(TEST_NB-1);
 
     switch (tt) {
-    case TEST_DC_LUMA:       dc_test(picref->data[0], picref->linesize[0], 256, 256, frame%30); break;
-    case TEST_DC_CHROMA:     dc_test(picref->data[1], picref->linesize[1], 256, 256, frame%30); break;
-    case TEST_FREQ_LUMA:   freq_test(picref->data[0], picref->linesize[0], frame%30); break;
-    case TEST_FREQ_CHROMA: freq_test(picref->data[1], picref->linesize[1], frame%30); break;
-    case TEST_AMP_LUMA:     amp_test(picref->data[0], picref->linesize[0], frame%30); break;
-    case TEST_AMP_CHROMA:   amp_test(picref->data[1], picref->linesize[1], frame%30); break;
-    case TEST_CBP:          cbp_test(picref->data   , picref->linesize   , frame%30); break;
-    case TEST_MV:            mv_test(picref->data[0], picref->linesize[0], frame%30); break;
-    case TEST_RING1:      ring1_test(picref->data[0], picref->linesize[0], frame%30); break;
-    case TEST_RING2:      ring2_test(picref->data[0], picref->linesize[0], frame%30); break;
+    case TEST_DC_LUMA:       dc_test(picref->data[0], picref->linesize[0], 256, 256, frame%test->max_frames); break;
+    case TEST_DC_CHROMA:     dc_test(picref->data[1], picref->linesize[1], 256, 256, frame%test->max_frames); break;
+    case TEST_FREQ_LUMA:   freq_test(picref->data[0], picref->linesize[0], frame%test->max_frames); break;
+    case TEST_FREQ_CHROMA: freq_test(picref->data[1], picref->linesize[1], frame%test->max_frames); break;
+    case TEST_AMP_LUMA:     amp_test(picref->data[0], picref->linesize[0], frame%test->max_frames); break;
+    case TEST_AMP_CHROMA:   amp_test(picref->data[1], picref->linesize[1], frame%test->max_frames); break;
+    case TEST_CBP:          cbp_test(picref->data   , picref->linesize   , frame%test->max_frames); break;
+    case TEST_MV:            mv_test(picref->data[0], picref->linesize[0], frame%test->max_frames); break;
+    case TEST_RING1:      ring1_test(picref->data[0], picref->linesize[0], frame%test->max_frames); break;
+    case TEST_RING2:      ring2_test(picref->data[0], picref->linesize[0], frame%test->max_frames); break;
     }
 
     return ff_filter_frame(outlink, picref);



More information about the ffmpeg-cvslog mailing list