[FFmpeg-devel] [PATCH V1] lavfi/normalize: improve the performance

Jun Zhao mypopydev at gmail.com
Thu Jun 20 16:43:46 EEST 2019


From: Jun Zhao <barryjzhao at tencent.com>

Remove unnecessary max value found, it's will improve the performance
about 10%. Used the test command like:
ffmpeg -i 1080P.mp4 -an -vf normalize -f null /dev/null, the FPS change
from 96fps to 107fps.

Signed-off-by: Jun Zhao <barryjzhao at tencent.com>
---
 libavfilter/vf_normalize.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_normalize.c b/libavfilter/vf_normalize.c
index 48eea59..40dc031 100644
--- a/libavfilter/vf_normalize.c
+++ b/libavfilter/vf_normalize.c
@@ -143,14 +143,13 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out)
         min[c].in = max[c].in = in->data[0][s->co[c]];
     for (y = 0; y < in->height; y++) {
         uint8_t *inp = in->data[0] + y * in->linesize[0];
-        uint8_t *outp = out->data[0] + y * out->linesize[0];
         for (x = 0; x < in->width; x++) {
             for (c = 0; c < 3; c++) {
-                min[c].in = FFMIN(min[c].in, inp[s->co[c]]);
-                max[c].in = FFMAX(max[c].in, inp[s->co[c]]);
+                uint8_t val = inp[s->co[c]];
+                if (val < min[c].in)      min[c].in = val;
+                else if (val > max[c].in) max[c].in = val;
             }
             inp += s->step;
-            outp += s->step;
         }
     }
 
-- 
1.7.1



More information about the ffmpeg-devel mailing list