diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2011-07-23 17:46:35 +0400 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2011-07-27 17:39:56 +0400 |
commit | 2968bedf129558024ea87a1aabc4aa2d3a5bcb6e (patch) | |
tree | abe755aee5abd6698fef19f58d14142434d38b24 /libavcodec/bink.c | |
parent | 001e600c3b8668191f96d7a1e46da0d7fff546de (diff) |
bink: make IDCT take 32-bit input
Since IDCT transforming 32-bit input to 8-bit output is unusual and unpractical
for most codecs, move Bink IDCT into separate context. Get rid of an additional
permutation table while at it since SIMD support for Bink IDCT is unlikely to
be implemented in foreseeable future.
Quantisation tables also have to change type to signed for proper
dequantisation of DCT coefficients.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavcodec/bink.c')
-rw-r--r-- | libavcodec/bink.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/libavcodec/bink.c b/libavcodec/bink.c index e085aa54e2..8e989d9dd9 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -24,6 +24,7 @@ #include "avcodec.h" #include "dsputil.h" #include "binkdata.h" +#include "binkdsp.h" #include "mathops.h" #define ALT_BITSTREAM_READER_LE @@ -60,8 +61,8 @@ static const int binkb_bundle_signed[BINKB_NB_SRC] = { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0 }; -static uint32_t binkb_intra_quant[16][64]; -static uint32_t binkb_inter_quant[16][64]; +static int32_t binkb_intra_quant[16][64]; +static int32_t binkb_inter_quant[16][64]; /** * IDs for different data types used in Bink video codec @@ -109,11 +110,11 @@ typedef struct Bundle { typedef struct BinkContext { AVCodecContext *avctx; DSPContext dsp; + BinkDSPContext bdsp; AVFrame pic, last; int version; ///< internal Bink file version int has_alpha; int swap_planes; - ScanTable scantable; ///< permutated scantable for DCT coeffs decoding Bundle bundle[BINKB_NB_SRC]; ///< bundles for decoding all data types Tree col_high[16]; ///< trees for decoding high nibble in "colours" data type @@ -580,8 +581,8 @@ static inline int binkb_get_value(BinkContext *c, int bundle_num) * @param quant_matrices quantization matrices * @return 0 for success, negative value in other cases */ -static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t *scan, - const uint32_t quant_matrices[16][64], int q) +static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *scan, + const int32_t quant_matrices[16][64], int q) { int coef_list[128]; int mode_list[128]; @@ -590,7 +591,7 @@ static int read_dct_coeffs(GetBitContext *gb, DCTELEM block[64], const uint8_t * int coef_count = 0; int coef_idx[64]; int quant_idx; - const uint32_t *quant; + const int32_t *quant; coef_list[list_end] = 4; mode_list[list_end++] = 0; coef_list[list_end] = 24; mode_list[list_end++] = 0; @@ -791,6 +792,7 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, const uint8_t *scan; int xoff, yoff; LOCAL_ALIGNED_16(DCTELEM, block, [64]); + LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; int ybias = is_key ? -15 : 0; int qp; @@ -845,11 +847,11 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, dst[coordmap[*scan++]] = binkb_get_value(c, BINKB_SRC_COLORS); break; case 2: - c->dsp.clear_block(block); - block[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = binkb_get_value(c, BINKB_SRC_INTRA_DC); qp = binkb_get_value(c, BINKB_SRC_INTRA_Q); - read_dct_coeffs(gb, block, c->scantable.permutated, binkb_intra_quant, qp); - c->dsp.idct_put(dst, stride, block); + read_dct_coeffs(gb, dctblock, bink_scan, binkb_intra_quant, qp); + c->bdsp.idct_put(dst, stride, dctblock); break; case 3: xoff = binkb_get_value(c, BINKB_SRC_X_OFF); @@ -878,11 +880,11 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, } else { put_pixels8x8_overlapped(dst, ref, stride); } - c->dsp.clear_block(block); - block[0] = binkb_get_value(c, BINKB_SRC_INTER_DC); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = binkb_get_value(c, BINKB_SRC_INTER_DC); qp = binkb_get_value(c, BINKB_SRC_INTER_Q); - read_dct_coeffs(gb, block, c->scantable.permutated, binkb_inter_quant, qp); - c->dsp.idct_add(dst, stride, block); + read_dct_coeffs(gb, dctblock, bink_scan, binkb_inter_quant, qp); + c->bdsp.idct_add(dst, stride, dctblock); break; case 5: v = binkb_get_value(c, BINKB_SRC_COLORS); @@ -937,6 +939,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, int xoff, yoff; LOCAL_ALIGNED_16(DCTELEM, block, [64]); LOCAL_ALIGNED_16(uint8_t, ublock, [64]); + LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; const int stride = c->pic.linesize[plane_idx]; @@ -1019,11 +1022,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, ublock[*scan++] = get_value(c, BINK_SRC_COLORS); break; case INTRA_BLOCK: - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTRA_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1); - c->dsp.idct(block); - c->dsp.put_pixels_nonclamped(block, ublock, 8); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); + c->bdsp.idct_put(ublock, 8, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); @@ -1103,10 +1105,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, c->dsp.add_pixels8(dst, block, stride); break; case INTRA_BLOCK: - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTRA_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_intra_quant, -1); - c->dsp.idct_put(dst, stride, block); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTRA_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_intra_quant, -1); + c->bdsp.idct_put(dst, stride, dctblock); break; case FILL_BLOCK: v = get_value(c, BINK_SRC_COLORS); @@ -1117,10 +1119,10 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, yoff = get_value(c, BINK_SRC_Y_OFF); ref = prev + xoff + yoff * stride; c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8); - c->dsp.clear_block(block); - block[0] = get_value(c, BINK_SRC_INTER_DC); - read_dct_coeffs(gb, block, c->scantable.permutated, bink_inter_quant, -1); - c->dsp.idct_add(dst, stride, block); + memset(dctblock, 0, sizeof(*dctblock) * 64); + dctblock[0] = get_value(c, BINK_SRC_INTER_DC); + read_dct_coeffs(gb, dctblock, bink_scan, bink_inter_quant, -1); + c->bdsp.idct_add(dst, stride, dctblock); break; case PATTERN_BLOCK: for (i = 0; i < 2; i++) @@ -1288,7 +1290,7 @@ static av_cold int decode_init(AVCodecContext *avctx) avctx->idct_algo = FF_IDCT_BINK; dsputil_init(&c->dsp, avctx); - ff_init_scantable(c->dsp.idct_permutation, &c->scantable, bink_scan); + ff_binkdsp_init(&c->bdsp); init_bundles(c); |