[FFmpeg-cvslog] avfilter/vf_limiter: refactor slice functions

Paul B Mahol git at videolan.org
Mon Feb 21 01:34:52 EET 2022


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Feb 21 00:30:52 2022 +0100| [b8e58f0858116ac102fc116ce1bdf6727df1eb0c] | committer: Paul B Mahol

avfilter/vf_limiter: refactor slice functions

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

 libavfilter/vf_limiter.c | 55 ++++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 34 deletions(-)

diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c
index 488c8865dd..f7d06fec48 100644
--- a/libavfilter/vf_limiter.c
+++ b/libavfilter/vf_limiter.c
@@ -88,42 +88,29 @@ static const enum AVPixelFormat pix_fmts[] = {
     AV_PIX_FMT_NONE
 };
 
-static void limiter8(const uint8_t *src, uint8_t *dst,
-                     ptrdiff_t slinesize, ptrdiff_t dlinesize,
-                     int w, int h, int min, int max)
-{
-    int x, y;
-
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < w; x++) {
-            dst[x] = av_clip(src[x], min, max);
-        }
-
-        dst += dlinesize;
-        src += slinesize;
-    }
+#define LIMITER(n, type)                                        \
+static void limiter##n(const uint8_t *ssrc, uint8_t *ddst,      \
+                       ptrdiff_t slinesize, ptrdiff_t dlinesize,\
+                       int w, int h, int min, int max)          \
+{                                                               \
+    const type *src = (const type *)ssrc;                       \
+    type *dst = (type *)ddst;                                   \
+                                                                \
+    dlinesize /= sizeof(type);                                  \
+    slinesize /= sizeof(type);                                  \
+                                                                \
+    for (int y = 0; y < h; y++) {                               \
+        for (int x = 0; x < w; x++) {                           \
+            dst[x] = av_clip(src[x], min, max);                 \
+        }                                                       \
+                                                                \
+        dst += dlinesize;                                       \
+        src += slinesize;                                       \
+    }                                                           \
 }
 
-static void limiter16(const uint8_t *ssrc, uint8_t *ddst,
-                      ptrdiff_t slinesize, ptrdiff_t dlinesize,
-                      int w, int h, int min, int max)
-{
-    const uint16_t *src = (const uint16_t *)ssrc;
-    uint16_t *dst = (uint16_t *)ddst;
-    int x, y;
-
-    dlinesize /= 2;
-    slinesize /= 2;
-
-    for (y = 0; y < h; y++) {
-        for (x = 0; x < w; x++) {
-            dst[x] = av_clip(src[x], min, max);
-        }
-
-        dst += dlinesize;
-        src += slinesize;
-    }
-}
+LIMITER(8,  uint8_t)
+LIMITER(16, uint16_t)
 
 static int config_input(AVFilterLink *inlink)
 {



More information about the ffmpeg-cvslog mailing list