[FFmpeg-devel] [PATCH v3 2/3] avfilter/vsrc_mptestsrc: simplify the code and change the type of frame

lance.lmwang at gmail.com lance.lmwang at gmail.com
Fri Aug 23 15:17:08 EEST 2019


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavfilter/vsrc_mptestsrc.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vsrc_mptestsrc.c b/libavfilter/vsrc_mptestsrc.c
index 4a2db18..4101690 100644
--- a/libavfilter/vsrc_mptestsrc.c
+++ b/libavfilter/vsrc_mptestsrc.c
@@ -308,7 +308,8 @@ static int request_frame(AVFilterLink *outlink)
     AVFrame *picref;
     int w = WIDTH, h = HEIGHT,
         cw = AV_CEIL_RSHIFT(w, test->hsub), ch = AV_CEIL_RSHIFT(h, test->vsub);
-    unsigned int frame = outlink->frame_count_in;
+    uint64_t frame = outlink->frame_count_in / test->max_frames;
+    uint64_t mod = outlink->frame_count_in % test->max_frames;
     enum test_type tt = test->test;
     int i;
 
@@ -327,20 +328,20 @@ static int request_frame(AVFilterLink *outlink)
         memset(picref->data[2] + i*picref->linesize[2], 128, cw);
     }
 
-    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);
+    if (tt == TEST_ALL && mod) /* draw a black frame at the beginning of each test */
+        tt = frame%(TEST_NB-1);
 
     switch (tt) {
-    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;
+    case TEST_DC_LUMA:       dc_test(picref->data[0], picref->linesize[0], 256, 256, mod); break;
+    case TEST_DC_CHROMA:     dc_test(picref->data[1], picref->linesize[1], 256, 256, mod); break;
+    case TEST_FREQ_LUMA:   freq_test(picref->data[0], picref->linesize[0], mod); break;
+    case TEST_FREQ_CHROMA: freq_test(picref->data[1], picref->linesize[1], mod); break;
+    case TEST_AMP_LUMA:     amp_test(picref->data[0], picref->linesize[0], mod); break;
+    case TEST_AMP_CHROMA:   amp_test(picref->data[1], picref->linesize[1], mod); break;
+    case TEST_CBP:          cbp_test(picref->data   , picref->linesize   , mod); break;
+    case TEST_MV:            mv_test(picref->data[0], picref->linesize[0], mod); break;
+    case TEST_RING1:      ring1_test(picref->data[0], picref->linesize[0], mod); break;
+    case TEST_RING2:      ring2_test(picref->data[0], picref->linesize[0], mod); break;
     }
 
     return ff_filter_frame(outlink, picref);
-- 
2.6.4



More information about the ffmpeg-devel mailing list