From 4a88d81c9e3758dfad6bf35681e27b9c10f0b346 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 14 Mar 2013 06:44:18 -0700 Subject: dsputil: remove duplicate or unused functions. dct_bits is never set except in h264, where it is never used, thus remove it. Then, remove all functions that were set based on non-zero (32) values for dct_bits. Lastly, merge 9-14 bpp functions for get_pixels and draw_edge, which only care about pixel storage unit size, not actual bits used (i.e. they don't clip). Signed-off-by: Michael Niedermayer --- libavcodec/dsputil.c | 51 ++++++------------------------- libavcodec/dsputil.h | 5 --- libavcodec/dsputil_template.c | 71 ++++++++++++++++++++----------------------- libavcodec/h264.c | 2 -- 4 files changed, 42 insertions(+), 87 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index f4f84b5..d425933 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -44,19 +44,7 @@ uint32_t ff_squareTbl[512] = {0, }; -#define BIT_DEPTH 9 -#include "dsputil_template.c" -#undef BIT_DEPTH - -#define BIT_DEPTH 10 -#include "dsputil_template.c" -#undef BIT_DEPTH - -#define BIT_DEPTH 12 -#include "dsputil_template.c" -#undef BIT_DEPTH - -#define BIT_DEPTH 14 +#define BIT_DEPTH 16 #include "dsputil_template.c" #undef BIT_DEPTH @@ -2931,44 +2919,23 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx) #define FUNC(f, depth) f ## _ ## depth #define FUNCC(f, depth) f ## _ ## depth ## _c -#define BIT_DEPTH_FUNCS(depth, dct)\ - c->get_pixels = FUNCC(get_pixels ## dct , depth);\ - c->draw_edges = FUNCC(draw_edges , depth);\ - c->clear_block = FUNCC(clear_block ## dct , depth);\ - c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ +#define BIT_DEPTH_FUNCS(depth) \ + c->get_pixels = FUNCC(get_pixels, depth);\ + c->draw_edges = FUNCC(draw_edges, depth); + + c->clear_block = FUNCC(clear_block, 8);\ + c->clear_blocks = FUNCC(clear_blocks, 8);\ switch (avctx->bits_per_raw_sample) { case 9: - if (c->dct_bits == 32) { - BIT_DEPTH_FUNCS(9, _32); - } else { - BIT_DEPTH_FUNCS(9, _16); - } - break; case 10: - if (c->dct_bits == 32) { - BIT_DEPTH_FUNCS(10, _32); - } else { - BIT_DEPTH_FUNCS(10, _16); - } - break; case 12: - if (c->dct_bits == 32) { - BIT_DEPTH_FUNCS(12, _32); - } else { - BIT_DEPTH_FUNCS(12, _16); - } - break; case 14: - if (c->dct_bits == 32) { - BIT_DEPTH_FUNCS(14, _32); - } else { - BIT_DEPTH_FUNCS(14, _16); - } + BIT_DEPTH_FUNCS(16); break; default: if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { - BIT_DEPTH_FUNCS(8, _16); + BIT_DEPTH_FUNCS(8); } break; } diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h index 29a2710..75017ca 100644 --- a/libavcodec/dsputil.h +++ b/libavcodec/dsputil.h @@ -125,11 +125,6 @@ void ff_init_scantable_permutation(uint8_t *idct_permutation, * DSPContext. */ typedef struct DSPContext { - /** - * Size of DCT coefficients. - */ - int dct_bits; - /* pixel ops : interface with DCT */ void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size); void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride); diff --git a/libavcodec/dsputil_template.c b/libavcodec/dsputil_template.c index f7f4709..6830ec3 100644 --- a/libavcodec/dsputil_template.c +++ b/libavcodec/dsputil_template.c @@ -65,46 +65,41 @@ static void FUNCC(draw_edges)(uint8_t *p_buf, int p_wrap, int width, int height, memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom } -#define DCTELEM_FUNCS(dctcoef, suffix) \ -static void FUNCC(get_pixels ## suffix)(int16_t *av_restrict _block, \ - const uint8_t *_pixels, \ - int line_size) \ -{ \ - const pixel *pixels = (const pixel *) _pixels; \ - dctcoef *av_restrict block = (dctcoef *) _block; \ - int i; \ - \ - /* read the pixels */ \ - for(i=0;i<8;i++) { \ - block[0] = pixels[0]; \ - block[1] = pixels[1]; \ - block[2] = pixels[2]; \ - block[3] = pixels[3]; \ - block[4] = pixels[4]; \ - block[5] = pixels[5]; \ - block[6] = pixels[6]; \ - block[7] = pixels[7]; \ - pixels += line_size / sizeof(pixel); \ - block += 8; \ - } \ -} \ - \ -static void FUNCC(clear_block ## suffix)(int16_t *block) \ -{ \ - memset(block, 0, sizeof(dctcoef)*64); \ -} \ - \ -/** \ - * memset(blocks, 0, sizeof(int16_t)*6*64) \ - */ \ -static void FUNCC(clear_blocks ## suffix)(int16_t *blocks) \ -{ \ - memset(blocks, 0, sizeof(dctcoef)*6*64); \ +static void FUNCC(get_pixels)(int16_t *av_restrict block, + const uint8_t *_pixels, + int line_size) +{ + const pixel *pixels = (const pixel *) _pixels; + int i; + + /* read the pixels */ + for(i=0;i<8;i++) { + block[0] = pixels[0]; + block[1] = pixels[1]; + block[2] = pixels[2]; + block[3] = pixels[3]; + block[4] = pixels[4]; + block[5] = pixels[5]; + block[6] = pixels[6]; + block[7] = pixels[7]; + pixels += line_size / sizeof(pixel); + block += 8; + } } -DCTELEM_FUNCS(int16_t, _16) -#if BIT_DEPTH > 8 -DCTELEM_FUNCS(dctcoef, _32) +#if BIT_DEPTH == 8 +static void FUNCC(clear_block)(int16_t *block) +{ + memset(block, 0, sizeof(int16_t)*64); +} + +/** + * memset(blocks, 0, sizeof(int16_t)*6*64) + */ +static void FUNCC(clear_blocks)(int16_t *blocks) +{ + memset(blocks, 0, sizeof(int16_t)*6*64); +} #endif #if BIT_DEPTH == 8 diff --git a/libavcodec/h264.c b/libavcodec/h264.c index bc8ee2e..e8140c9 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -1421,7 +1421,6 @@ static av_cold void common_init(H264Context *h) h->dequant_coeff_pps = -1; if (CONFIG_ERROR_RESILIENCE) { - h->dsp.dct_bits = 16; /* needed so that IDCT permutation is known early */ ff_dsputil_init(&h->dsp, h->avctx); } @@ -2973,7 +2972,6 @@ static int h264_set_parameter_from_sps(H264Context *h) ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma, h->sps.chroma_format_idc); if (CONFIG_ERROR_RESILIENCE) { - h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; ff_dsputil_init(&h->dsp, h->avctx); } ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma); -- cgit v1.1