Commit b1eb28e0b8 for ffmpeg

commit b1eb28e0b8b7f5a1b0ffd996fca31250a15de25d
Author: Rodrigo Camacho <rodrigompcamacho@gmail.com>
Date:   Thu Apr 23 23:49:13 2026 +0100

    avfilter/vf_limiter: Move ff_limiter_init into a header

    This change allows ff_limiter_init to be inlined
    without depending on vf_limiter.o

    Signed-off-by: Rodrigo Camacho <rodrigompcamacho@gmail.com>

diff --git a/libavfilter/limiter.h b/libavfilter/limiter.h
index 54d423d1f4..8740c51bcb 100644
--- a/libavfilter/limiter.h
+++ b/libavfilter/limiter.h
@@ -21,6 +21,7 @@

 #include <stddef.h>
 #include <stdint.h>
+#include "avfilter.h"

 typedef struct LimiterDSPContext {
     void (*limiter)(const uint8_t *src, uint8_t *dst,
@@ -28,6 +29,20 @@ typedef struct LimiterDSPContext {
                     int w, int h, int min, int max);
 } LimiterDSPContext;

+typedef struct LimiterContext {
+    const AVClass *class;
+    int min, max; /* user-facing option */
+    int planes;
+    int nb_planes;
+    int plane_min[4]; /* resolved per-plane limits */
+    int plane_max[4];
+    int linesize[4];
+    int width[4];
+    int height[4];
+
+    LimiterDSPContext dsp;
+} LimiterContext;
+
 void ff_limiter_init_x86(LimiterDSPContext *dsp, int bpp);

 #endif /* AVFILTER_LIMITER_H */
diff --git a/libavfilter/vf_limiter.c b/libavfilter/vf_limiter.c
index f46c7c21f0..d3be902491 100644
--- a/libavfilter/vf_limiter.c
+++ b/libavfilter/vf_limiter.c
@@ -17,6 +17,7 @@
  */

 #include "libavutil/avassert.h"
+#include "libavfilter/vf_limiter_init.h"
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
@@ -32,20 +33,6 @@ typedef struct ThreadData {
     AVFrame *out;
 } ThreadData;

-typedef struct LimiterContext {
-    const AVClass *class;
-    int min, max; /* user-facing option */
-    int planes;
-    int nb_planes;
-    int plane_min[4]; /* resolved per-plane limits */
-    int plane_max[4];
-    int linesize[4];
-    int width[4];
-    int height[4];
-
-    LimiterDSPContext dsp;
-} LimiterContext;
-
 #define OFFSET(x) offsetof(LimiterContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_RUNTIME_PARAM

@@ -81,30 +68,6 @@ static const enum AVPixelFormat pix_fmts[] = {
     AV_PIX_FMT_NONE
 };

-#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;                                       \
-    }                                                           \
-}
-
-LIMITER(8,  uint8_t)
-LIMITER(16, uint16_t)
-
 static int config_input(AVFilterLink *inlink)
 {
     AVFilterContext *ctx = inlink->dst;
@@ -125,15 +88,7 @@ static int config_input(AVFilterLink *inlink)
     s->width[1]  = s->width[2]  = AV_CEIL_RSHIFT(inlink->w, hsub);
     s->width[0]  = s->width[3]  = inlink->w;

-    if (depth == 8) {
-        s->dsp.limiter = limiter8;
-    } else {
-        s->dsp.limiter = limiter16;
-    }
-
-#if ARCH_X86 && HAVE_X86ASM
-    ff_limiter_init_x86(&s->dsp, desc->comp[0].depth);
-#endif
+    ff_limiter_init(s, depth);

     return 0;
 }
diff --git a/libavfilter/vf_limiter_init.h b/libavfilter/vf_limiter_init.h
new file mode 100644
index 0000000000..f8e0a3319d
--- /dev/null
+++ b/libavfilter/vf_limiter_init.h
@@ -0,0 +1,65 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVFILTER_LIMITER_INIT_H
+#define AVFILTER_LIMITER_INIT_H
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/common.h"
+#include "limiter.h"
+
+#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;                                       \
+    }                                                           \
+}
+
+LIMITER(8,  uint8_t)
+LIMITER(16, uint16_t)
+
+static av_unused void ff_limiter_init(LimiterContext *s, int depth)
+{
+    if (depth == 8) {
+        s->dsp.limiter = limiter8;
+    } else {
+        s->dsp.limiter = limiter16;
+    }
+
+#if ARCH_X86 && HAVE_X86ASM
+    ff_limiter_init_x86(&s->dsp, depth);
+#endif
+
+}
+
+#endif /* AVFILTER_LIMITER_INIT_H */