diff mbox

[FFmpeg-devel,v1,1/2] avfilter/vsrc_mptestsrc: add option to set the max number frames generated for each tests

Message ID 20190812112146.15922-1-lance.lmwang@gmail.com
State New
Headers show

Commit Message

Lance Wang Aug. 12, 2019, 11:21 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 doc/filters.texi             |  3 +++
 libavfilter/vsrc_mptestsrc.c | 27 +++++++++++++++------------
 2 files changed, 18 insertions(+), 12 deletions(-)

Comments

Moritz Barsnick Aug. 12, 2019, 1:05 p.m. UTC | #1
On Mon, Aug 12, 2019 at 19:21:45 +0800, lance.lmwang@gmail.com wrote:
> +Set the max number frames generated for each tests:

Grammar nit:
  Set the maximum number of frames generated for each test

(Note:
 - use the complete word maximum
 - "test", "not tests", when using "for each" singular
 - *of* frames.

> +    { "max_frames", "Set the max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },
> +    { "m",          " Set the max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },

Same here. Also note that you introduced an additional space in the
second string which doesn't belong there.

> +    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);
[...]
> +    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;
[...]

frame%test->max_frames could probably be assigned to a variable, that
might avoid a lot of code, unless compilers know how to optimize this.
(Might not belong into this functional patch though.)

Cheers,
Moritz
Lance Wang Aug. 12, 2019, 3:45 p.m. UTC | #2
On Mon, Aug 12, 2019 at 03:05:32PM +0200, Moritz Barsnick wrote:
> On Mon, Aug 12, 2019 at 19:21:45 +0800, lance.lmwang@gmail.com wrote:
> > +Set the max number frames generated for each tests:
> 
> Grammar nit:
>   Set the maximum number of frames generated for each test
> 
> (Note:
>  - use the complete word maximum
>  - "test", "not tests", when using "for each" singular
>  - *of* frames.

OK, fix it. It'll cause the subject change, so it'll start with new
thread:
https://patchwork.ffmpeg.org/patch/14439/

> 
> > +    { "max_frames", "Set the max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },
> > +    { "m",          " Set the max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },
> 
> Same here. Also note that you introduced an additional space in the
> second string which doesn't belong there.

OK, fix them and send v2 patch.

> 
> > +    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);
> [...]
> > +    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;
> [...]
> 
> frame%test->max_frames could probably be assigned to a variable, that
> might avoid a lot of code, unless compilers know how to optimize this.
> (Might not belong into this functional patch though.)
> 
Add patch#3 to simpilify it, change the type for frame and reuse it.

> Cheers,
> Moritz
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index e081cdc7bc..d3d468b445 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -20246,6 +20246,9 @@  Set the number or the name of the test to perform. Supported tests are:
 @item ring2
 @item all
 
+@item max_frames, m
+Set the max number frames generated for each tests:
+
 @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..f399e43b0b 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,8 @@  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 max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },
+    { "m",          " Set the max number frames generated for each tests", OFFSET(max_frames), AV_OPT_TYPE_INT, {.i64 = 30}, 1, INT64_MAX, FLAGS },
     { NULL }
 };
 
@@ -322,20 +325,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);