summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-03 07:21:52 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-05-06 05:19:50 +0200
commitfbe4e825d8001bb6677589c327ea097db4a97db4 (patch)
treeba16856267583ee7b763eaef39a25eaf540c937b /libavfilter
parent24936a9fbb220a7ba4b1f3a80ceeca68f4f5f7d4 (diff)
avfilter/vf_hflip: Move ff_hflip_init into a header
This removes a dependency of checkasm on lavfi/vf_hflip.o and also allows to inline ff_hflip_init() irrespectively of interposing. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/hflip.h1
-rw-r--r--libavfilter/vf_hflip.c88
-rw-r--r--libavfilter/vf_hflip_init.h110
3 files changed, 111 insertions, 88 deletions
diff --git a/libavfilter/hflip.h b/libavfilter/hflip.h
index a40b98470b..8532dc0f46 100644
--- a/libavfilter/hflip.h
+++ b/libavfilter/hflip.h
@@ -34,7 +34,6 @@ typedef struct FlipContext {
void (*flip_line[4])(const uint8_t *src, uint8_t *dst, int w);
} FlipContext;
-int ff_hflip_init(FlipContext *s, int step[4], int nb_planes);
void ff_hflip_init_x86(FlipContext *s, int step[4], int nb_planes);
#endif /* AVFILTER_HFLIP_H */
diff --git a/libavfilter/vf_hflip.c b/libavfilter/vf_hflip.c
index 0362660679..8517b87889 100644
--- a/libavfilter/vf_hflip.c
+++ b/libavfilter/vf_hflip.c
@@ -31,6 +31,7 @@
#include "formats.h"
#include "hflip.h"
#include "internal.h"
+#include "vf_hflip_init.h"
#include "video.h"
#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
@@ -61,70 +62,6 @@ static int query_formats(AVFilterContext *ctx)
return ff_set_common_formats(ctx, pix_fmts);
}
-static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
-{
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint16_t *src = (const uint16_t *)ssrc;
- uint16_t *dst = (uint16_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint32_t *src = (const uint32_t *)ssrc;
- uint32_t *dst = (uint32_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
-static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
-{
- const uint8_t *in = src;
- uint8_t *out = dst;
- int j;
-
- for (j = 0; j < w; j++, out += 3, in -= 3) {
- int32_t v = AV_RB24(in);
-
- AV_WB24(out, v);
- }
-}
-
-static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
-{
- const uint8_t *in = src;
- uint8_t *out = dst;
- int j;
-
- for (j = 0; j < w; j++, out += 6, in -= 6) {
- int64_t v = AV_RB48(in);
-
- AV_WB48(out, v);
- }
-}
-
-static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
-{
- const uint64_t *src = (const uint64_t *)ssrc;
- uint64_t *dst = (uint64_t *)ddst;
- int j;
-
- for (j = 0; j < w; j++)
- dst[j] = src[-j];
-}
-
static int config_props(AVFilterLink *inlink)
{
FlipContext *s = inlink->dst->priv;
@@ -145,29 +82,6 @@ static int config_props(AVFilterLink *inlink)
return ff_hflip_init(s, s->max_step, nb_planes);
}
-int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
-{
- int i;
-
- for (i = 0; i < nb_planes; i++) {
- step[i] *= s->bayer_plus1;
- switch (step[i]) {
- case 1: s->flip_line[i] = hflip_byte_c; break;
- case 2: s->flip_line[i] = hflip_short_c; break;
- case 3: s->flip_line[i] = hflip_b24_c; break;
- case 4: s->flip_line[i] = hflip_dword_c; break;
- case 6: s->flip_line[i] = hflip_b48_c; break;
- case 8: s->flip_line[i] = hflip_qword_c; break;
- default:
- return AVERROR_BUG;
- }
- }
- if (ARCH_X86)
- ff_hflip_init_x86(s, step, nb_planes);
-
- return 0;
-}
-
typedef struct ThreadData {
AVFrame *in, *out;
} ThreadData;
diff --git a/libavfilter/vf_hflip_init.h b/libavfilter/vf_hflip_init.h
new file mode 100644
index 0000000000..b58cfec901
--- /dev/null
+++ b/libavfilter/vf_hflip_init.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2007 Benoit Fouet
+ * Copyright (c) 2010 Stefano Sabatini
+ *
+ * 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_HFLIP_INIT_H
+#define AVFILTER_HFLIP_INIT_H
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/intreadwrite.h"
+#include "hflip.h"
+
+static void hflip_byte_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_short_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint16_t *src = (const uint16_t *)ssrc;
+ uint16_t *dst = (uint16_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_dword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint32_t *src = (const uint32_t *)ssrc;
+ uint32_t *dst = (uint32_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static void hflip_b24_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ const uint8_t *in = src;
+ uint8_t *out = dst;
+
+ for (int j = 0; j < w; j++, out += 3, in -= 3) {
+ int32_t v = AV_RB24(in);
+
+ AV_WB24(out, v);
+ }
+}
+
+static void hflip_b48_c(const uint8_t *src, uint8_t *dst, int w)
+{
+ const uint8_t *in = src;
+ uint8_t *out = dst;
+
+ for (int j = 0; j < w; j++, out += 6, in -= 6) {
+ int64_t v = AV_RB48(in);
+
+ AV_WB48(out, v);
+ }
+}
+
+static void hflip_qword_c(const uint8_t *ssrc, uint8_t *ddst, int w)
+{
+ const uint64_t *src = (const uint64_t *)ssrc;
+ uint64_t *dst = (uint64_t *)ddst;
+
+ for (int j = 0; j < w; j++)
+ dst[j] = src[-j];
+}
+
+static av_unused int ff_hflip_init(FlipContext *s, int step[4], int nb_planes)
+{
+ for (int i = 0; i < nb_planes; i++) {
+ step[i] *= s->bayer_plus1;
+ switch (step[i]) {
+ case 1: s->flip_line[i] = hflip_byte_c; break;
+ case 2: s->flip_line[i] = hflip_short_c; break;
+ case 3: s->flip_line[i] = hflip_b24_c; break;
+ case 4: s->flip_line[i] = hflip_dword_c; break;
+ case 6: s->flip_line[i] = hflip_b48_c; break;
+ case 8: s->flip_line[i] = hflip_qword_c; break;
+ default:
+ return AVERROR_BUG;
+ }
+ }
+ if (ARCH_X86)
+ ff_hflip_init_x86(s, step, nb_planes);
+
+ return 0;
+}
+
+#endif /* AVFILTER_HFLIP_INIT_H */