aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dsputil_template.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-07-21 12:39:41 +0100
committerMans Rullgard <mans@mansr.com>2011-07-21 18:10:58 +0100
commit5cc2600964c72dad995efb18c918a63e0965f8db (patch)
tree8b0c518a870efbcb4e2cd275a6d96d1ceabd1453 /libavcodec/dsputil_template.c
parent0a72533e9854aa615bb6d1569dd5f0c4cd031429 (diff)
downloadffmpeg-5cc2600964c72dad995efb18c918a63e0965f8db.tar.gz
dsputil: create 16/32-bit dctcoef versions of some functions
High bitdepth H.264 needs 32-bit transform coefficients, whereas dnxhd does not. This creates a conflict with the templated functions operating on DCTELEM data. This patch adds a field allowing the caller to choose the element size in dsputil_init() and adds the required functions. Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/dsputil_template.c')
-rw-r--r--libavcodec/dsputil_template.c106
1 files changed, 58 insertions, 48 deletions
diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c
index 9f8cf557c8..5863275c00 100644
--- a/libavcodec/dsputil_template.c
+++ b/libavcodec/dsputil_template.c
@@ -192,43 +192,66 @@ void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src, int linesize, i
}
}
-static void FUNCC(add_pixels8)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size)
-{
- int i;
- pixel *restrict pixels = (pixel *restrict)_pixels;
- dctcoef *block = (dctcoef*)_block;
- line_size /= sizeof(pixel);
-
- for(i=0;i<8;i++) {
- pixels[0] += block[0];
- pixels[1] += block[1];
- pixels[2] += block[2];
- pixels[3] += block[3];
- pixels[4] += block[4];
- pixels[5] += block[5];
- pixels[6] += block[6];
- pixels[7] += block[7];
- pixels += line_size;
- block += 8;
- }
+#define DCTELEM_FUNCS(dctcoef, suffix) \
+static void FUNCC(add_pixels8 ## suffix)(uint8_t *restrict _pixels, \
+ DCTELEM *_block, \
+ int line_size) \
+{ \
+ int i; \
+ pixel *restrict pixels = (pixel *restrict)_pixels; \
+ dctcoef *block = (dctcoef*)_block; \
+ line_size /= sizeof(pixel); \
+ \
+ for(i=0;i<8;i++) { \
+ pixels[0] += block[0]; \
+ pixels[1] += block[1]; \
+ pixels[2] += block[2]; \
+ pixels[3] += block[3]; \
+ pixels[4] += block[4]; \
+ pixels[5] += block[5]; \
+ pixels[6] += block[6]; \
+ pixels[7] += block[7]; \
+ pixels += line_size; \
+ block += 8; \
+ } \
+} \
+ \
+static void FUNCC(add_pixels4 ## suffix)(uint8_t *restrict _pixels, \
+ DCTELEM *_block, \
+ int line_size) \
+{ \
+ int i; \
+ pixel *restrict pixels = (pixel *restrict)_pixels; \
+ dctcoef *block = (dctcoef*)_block; \
+ line_size /= sizeof(pixel); \
+ \
+ for(i=0;i<4;i++) { \
+ pixels[0] += block[0]; \
+ pixels[1] += block[1]; \
+ pixels[2] += block[2]; \
+ pixels[3] += block[3]; \
+ pixels += line_size; \
+ block += 4; \
+ } \
+} \
+ \
+static void FUNCC(clear_block ## suffix)(DCTELEM *block) \
+{ \
+ memset(block, 0, sizeof(dctcoef)*64); \
+} \
+ \
+/** \
+ * memset(blocks, 0, sizeof(DCTELEM)*6*64) \
+ */ \
+static void FUNCC(clear_blocks ## suffix)(DCTELEM *blocks) \
+{ \
+ memset(blocks, 0, sizeof(dctcoef)*6*64); \
}
-static void FUNCC(add_pixels4)(uint8_t *restrict _pixels, DCTELEM *_block, int line_size)
-{
- int i;
- pixel *restrict pixels = (pixel *restrict)_pixels;
- dctcoef *block = (dctcoef*)_block;
- line_size /= sizeof(pixel);
-
- for(i=0;i<4;i++) {
- pixels[0] += block[0];
- pixels[1] += block[1];
- pixels[2] += block[2];
- pixels[3] += block[3];
- pixels += line_size;
- block += 4;
- }
-}
+DCTELEM_FUNCS(DCTELEM, _16)
+#if BIT_DEPTH > 8
+DCTELEM_FUNCS(dctcoef, _32)
+#endif
#define PIXOP2(OPNAME, OP) \
static void FUNCC(OPNAME ## _pixels2)(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
@@ -1231,16 +1254,3 @@ void FUNCC(ff_put_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
void FUNCC(ff_avg_pixels16x16)(uint8_t *dst, uint8_t *src, int stride) {
FUNCC(avg_pixels16)(dst, src, stride, 16);
}
-
-static void FUNCC(clear_block)(DCTELEM *block)
-{
- memset(block, 0, sizeof(dctcoef)*64);
-}
-
-/**
- * memset(blocks, 0, sizeof(DCTELEM)*6*64)
- */
-static void FUNCC(clear_blocks)(DCTELEM *blocks)
-{
- memset(blocks, 0, sizeof(dctcoef)*6*64);
-}