1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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 <michaelni@gmx.at>
This commit is contained in:
Ronald S. Bultje 2013-03-14 06:44:18 -07:00 committed by Michael Niedermayer
parent 49a514c13e
commit 4a88d81c9e
4 changed files with 42 additions and 87 deletions

View File

@ -44,19 +44,7 @@
uint32_t ff_squareTbl[512] = {0, }; uint32_t ff_squareTbl[512] = {0, };
#define BIT_DEPTH 9 #define BIT_DEPTH 16
#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
#include "dsputil_template.c" #include "dsputil_template.c"
#undef BIT_DEPTH #undef BIT_DEPTH
@ -2931,44 +2919,23 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
#define FUNC(f, depth) f ## _ ## depth #define FUNC(f, depth) f ## _ ## depth
#define FUNCC(f, depth) f ## _ ## depth ## _c #define FUNCC(f, depth) f ## _ ## depth ## _c
#define BIT_DEPTH_FUNCS(depth, dct)\ #define BIT_DEPTH_FUNCS(depth) \
c->get_pixels = FUNCC(get_pixels ## dct , depth);\ c->get_pixels = FUNCC(get_pixels, depth);\
c->draw_edges = FUNCC(draw_edges , depth);\ c->draw_edges = FUNCC(draw_edges, depth);
c->clear_block = FUNCC(clear_block ## dct , depth);\
c->clear_blocks = FUNCC(clear_blocks ## dct , depth);\ c->clear_block = FUNCC(clear_block, 8);\
c->clear_blocks = FUNCC(clear_blocks, 8);\
switch (avctx->bits_per_raw_sample) { switch (avctx->bits_per_raw_sample) {
case 9: case 9:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(9, _32);
} else {
BIT_DEPTH_FUNCS(9, _16);
}
break;
case 10: case 10:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(10, _32);
} else {
BIT_DEPTH_FUNCS(10, _16);
}
break;
case 12: case 12:
if (c->dct_bits == 32) {
BIT_DEPTH_FUNCS(12, _32);
} else {
BIT_DEPTH_FUNCS(12, _16);
}
break;
case 14: case 14:
if (c->dct_bits == 32) { BIT_DEPTH_FUNCS(16);
BIT_DEPTH_FUNCS(14, _32);
} else {
BIT_DEPTH_FUNCS(14, _16);
}
break; break;
default: default:
if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) { if(avctx->bits_per_raw_sample<=8 || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
BIT_DEPTH_FUNCS(8, _16); BIT_DEPTH_FUNCS(8);
} }
break; break;
} }

View File

@ -125,11 +125,6 @@ void ff_init_scantable_permutation(uint8_t *idct_permutation,
* DSPContext. * DSPContext.
*/ */
typedef struct DSPContext { typedef struct DSPContext {
/**
* Size of DCT coefficients.
*/
int dct_bits;
/* pixel ops : interface with DCT */ /* pixel ops : interface with DCT */
void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size); 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); void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);

View File

@ -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 memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom
} }
#define DCTELEM_FUNCS(dctcoef, suffix) \ static void FUNCC(get_pixels)(int16_t *av_restrict block,
static void FUNCC(get_pixels ## suffix)(int16_t *av_restrict _block, \ const uint8_t *_pixels,
const uint8_t *_pixels, \ int line_size)
int line_size) \ {
{ \ const pixel *pixels = (const pixel *) _pixels;
const pixel *pixels = (const pixel *) _pixels; \ int i;
dctcoef *av_restrict block = (dctcoef *) _block; \
int i; \ /* read the pixels */
\ for(i=0;i<8;i++) {
/* read the pixels */ \ block[0] = pixels[0];
for(i=0;i<8;i++) { \ block[1] = pixels[1];
block[0] = pixels[0]; \ block[2] = pixels[2];
block[1] = pixels[1]; \ block[3] = pixels[3];
block[2] = pixels[2]; \ block[4] = pixels[4];
block[3] = pixels[3]; \ block[5] = pixels[5];
block[4] = pixels[4]; \ block[6] = pixels[6];
block[5] = pixels[5]; \ block[7] = pixels[7];
block[6] = pixels[6]; \ pixels += line_size / sizeof(pixel);
block[7] = pixels[7]; \ block += 8;
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); \
} }
DCTELEM_FUNCS(int16_t, _16) #if BIT_DEPTH == 8
#if BIT_DEPTH > 8 static void FUNCC(clear_block)(int16_t *block)
DCTELEM_FUNCS(dctcoef, _32) {
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 #endif
#if BIT_DEPTH == 8 #if BIT_DEPTH == 8

View File

@ -1421,7 +1421,6 @@ static av_cold void common_init(H264Context *h)
h->dequant_coeff_pps = -1; h->dequant_coeff_pps = -1;
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
h->dsp.dct_bits = 16;
/* needed so that IDCT permutation is known early */ /* needed so that IDCT permutation is known early */
ff_dsputil_init(&h->dsp, h->avctx); 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, ff_h264_pred_init(&h->hpc, h->avctx->codec_id, h->sps.bit_depth_luma,
h->sps.chroma_format_idc); h->sps.chroma_format_idc);
if (CONFIG_ERROR_RESILIENCE) { if (CONFIG_ERROR_RESILIENCE) {
h->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16;
ff_dsputil_init(&h->dsp, h->avctx); ff_dsputil_init(&h->dsp, h->avctx);
} }
ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma); ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);