From 74314f1f5f9ef69700eb18b85a8260e2754a31ef Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 7 Aug 2016 23:37:17 +0200 Subject: avcodec/ffv1: template functions to allow data types different from int16_t This is required for >= 16bit RGB support I tried it without templates but its too much duplicated code Signed-off-by: Michael Niedermayer --- libavcodec/ffv1dec.c | 142 ++------------------------------------------------- 1 file changed, 5 insertions(+), 137 deletions(-) (limited to 'libavcodec/ffv1dec.c') diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 1e67fd39e9..e8b726cc7e 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -97,88 +97,12 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState *const state, return ret; } -static av_always_inline void decode_line(FFV1Context *s, int w, - int16_t *sample[2], - int plane_index, int bits) -{ - PlaneContext *const p = &s->plane[plane_index]; - RangeCoder *const c = &s->c; - int x; - int run_count = 0; - int run_mode = 0; - int run_index = s->run_index; - - if (s->slice_coding_mode == 1) { - int i; - for (x = 0; x < w; x++) { - int v = 0; - for (i=0; icontext_count); - - if (s->ac != AC_GOLOMB_RICE) { - diff = get_symbol_inline(c, p->state[context], 1); - } else { - if (context == 0 && run_mode == 0) - run_mode = 1; - - if (run_mode) { - if (run_count == 0 && run_mode == 1) { - if (get_bits1(&s->gb)) { - run_count = 1 << ff_log2_run[run_index]; - if (x + run_count <= w) - run_index++; - } else { - if (ff_log2_run[run_index]) - run_count = get_bits(&s->gb, ff_log2_run[run_index]); - else - run_count = 0; - if (run_index) - run_index--; - run_mode = 2; - } - } - run_count--; - if (run_count < 0) { - run_mode = 0; - run_count = 0; - diff = get_vlc_symbol(&s->gb, &p->vlc_state[context], - bits); - if (diff >= 0) - diff++; - } else - diff = 0; - } else - diff = get_vlc_symbol(&s->gb, &p->vlc_state[context], bits); - - ff_dlog(s->avctx, "count:%d index:%d, mode:%d, x:%d pos:%d\n", - run_count, run_index, run_mode, x, get_bits_count(&s->gb)); - } - - if (sign) - diff = -diff; - - sample[1][x] = av_mod_uintp2(predict(sample[1] + x, sample[0] + x) + diff, bits); - } - s->run_index = run_index; -} static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index, @@ -223,62 +147,6 @@ static void decode_plane(FFV1Context *s, uint8_t *src, } } -static void decode_rgb_frame(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3]) -{ - int x, y, p; - int16_t *sample[4][2]; - int lbd = s->avctx->bits_per_raw_sample <= 8; - int bits = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8; - int offset = 1 << bits; - - for (x = 0; x < 4; x++) { - sample[x][0] = s->sample_buffer + x * 2 * (w + 6) + 3; - sample[x][1] = s->sample_buffer + (x * 2 + 1) * (w + 6) + 3; - } - - s->run_index = 0; - - memset(s->sample_buffer, 0, 8 * (w + 6) * sizeof(*s->sample_buffer)); - - for (y = 0; y < h; y++) { - for (p = 0; p < 3 + s->transparency; p++) { - int16_t *temp = sample[p][0]; // FIXME: try a normal buffer - - sample[p][0] = sample[p][1]; - sample[p][1] = temp; - - sample[p][1][-1]= sample[p][0][0 ]; - sample[p][0][ w]= sample[p][0][w-1]; - if (lbd && s->slice_coding_mode == 0) - decode_line(s, w, sample[p], (p + 1)/2, 9); - else - decode_line(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1)); - } - for (x = 0; x < w; x++) { - int g = sample[0][1][x]; - int b = sample[1][1][x]; - int r = sample[2][1][x]; - int a = sample[3][1][x]; - - if (s->slice_coding_mode != 1) { - b -= offset; - r -= offset; - g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2; - b += g; - r += g; - } - - if (lbd) - *((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24); - else { - *((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b; - *((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g; - *((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r; - } - } - } -} - static int decode_slice_header(FFV1Context *f, FFV1Context *fs) { RangeCoder *c = &fs->c; -- cgit v1.2.3