summaryrefslogtreecommitdiff
path: root/libavfilter/vf_limiter.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-02-21 00:30:52 +0100
committerPaul B Mahol <onemda@gmail.com>2022-02-21 00:35:11 +0100
commitb8e58f0858116ac102fc116ce1bdf6727df1eb0c (patch)
tree91da03666b18692eee79dc508a95a647f73ae95b /libavfilter/vf_limiter.c
parentebcde3fda839abce4adb36ecfd436846e79da6d5 (diff)
avfilter/vf_limiter: refactor slice functions
Diffstat (limited to 'libavfilter/vf_limiter.c')
-rw-r--r--libavfilter/vf_limiter.c55
1 files 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)
{