aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_hflip_init.h
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/vf_hflip_init.h
parent24936a9fbb220a7ba4b1f3a80ceeca68f4f5f7d4 (diff)
downloadffmpeg-fbe4e825d8001bb6677589c327ea097db4a97db4.tar.gz
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/vf_hflip_init.h')
-rw-r--r--libavfilter/vf_hflip_init.h110
1 files changed, 110 insertions, 0 deletions
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 */