[FFmpeg-devel] [PATCH v1 3/5] avcodec/v210enc: define DEFINE_V210_PLANAR_FUNC to remove duplicate function
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Wed Aug 28 18:45:14 EEST 2019
From: Limin Wang <lance.lmwang at gmail.com>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
libavcodec/v210enc.c | 43 ++++++++++++++++---------------------------
1 file changed, 16 insertions(+), 27 deletions(-)
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 69a2efe..716544a 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -36,35 +36,24 @@
dst += 4; \
} while (0)
-static void v210_planar_pack_8_c(const uint8_t *y, const uint8_t *u,
- const uint8_t *v, uint8_t *dst,
- ptrdiff_t width)
-{
- uint32_t val;
- int i;
-
- for (i = 0; i < width - 5; i += 6) {
- WRITE_PIXELS(u, y, v, 8);
- WRITE_PIXELS(y, u, y, 8);
- WRITE_PIXELS(v, y, u, 8);
- WRITE_PIXELS(y, v, y, 8);
- }
+#define DEFINE_V210_PLANAR_FUNC(nbits, depth) \
+static void v210_planar_pack_##depth##_c(const uint##nbits##_t *y, \
+ const uint##nbits##_t *u, const uint##nbits##_t *v, \
+ uint8_t *dst, ptrdiff_t width) \
+{ \
+ uint32_t val; \
+ int i; \
+ \
+ for (i = 0; i < width - 5; i += 6) { \
+ WRITE_PIXELS(u, y, v, depth); \
+ WRITE_PIXELS(y, u, y, depth); \
+ WRITE_PIXELS(v, y, u, depth); \
+ WRITE_PIXELS(y, v, y, depth); \
+ } \
}
-static void v210_planar_pack_10_c(const uint16_t *y, const uint16_t *u,
- const uint16_t *v, uint8_t *dst,
- ptrdiff_t width)
-{
- uint32_t val;
- int i;
-
- for (i = 0; i < width - 5; i += 6) {
- WRITE_PIXELS(u, y, v, 10);
- WRITE_PIXELS(y, u, y, 10);
- WRITE_PIXELS(v, y, u, 10);
- WRITE_PIXELS(y, v, y, 10);
- }
-}
+DEFINE_V210_PLANAR_FUNC(8, 8);
+DEFINE_V210_PLANAR_FUNC(16, 10);
av_cold void ff_v210enc_init(V210EncContext *s)
{
--
2.6.4
More information about the ffmpeg-devel
mailing list