From 650dee63c8b1e6693c6cf5983f4a5ed3f571379f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 18 Jun 2014 10:59:37 +0200 Subject: dv: get rid of global non-const tables Instead, store them in the context and compute on each parameter change. --- libavcodec/dvdec.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'libavcodec/dvdec.c') diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index ef9ba4cd1c..f354b9e0e8 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -178,12 +178,12 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) if (DV_PROFILE_IS_HD(s->sys)) { mb->idct_put = s->idct_put[0]; mb->scan_table = s->dv_zigzag[0]; - mb->factor_table = &s->sys->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64]; + mb->factor_table = &s->idct_factor[(j >= 4)*4*16*64 + class1*16*64 + quant*64]; is_field_mode[mb_index] |= !j && dct_mode; } else { mb->idct_put = s->idct_put[dct_mode && log2_blocksize == 3]; mb->scan_table = s->dv_zigzag[dct_mode]; - mb->factor_table = &s->sys->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 + + mb->factor_table = &s->idct_factor[(class1 == 3)*2*22*64 + dct_mode*22*64 + (quant + ff_dv_quant_offset[class1])*64]; } dc = dc << 2; @@ -320,13 +320,23 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, DVVideoContext *s = avctx->priv_data; const uint8_t* vsc_pack; int apt, is16_9, ret; + const DVprofile *sys; - s->sys = avpriv_dv_frame_profile(s->sys, buf, buf_size); - if (!s->sys || buf_size < s->sys->frame_size || ff_dv_init_dynamic_tables(s->sys)) { + sys = avpriv_dv_frame_profile(s->sys, buf, buf_size); + if (!sys || buf_size < sys->frame_size) { av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n"); return -1; /* NOTE: we only accept several full frames */ } + if (sys != s->sys) { + ret = ff_dv_init_dynamic_tables(s, sys); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error initializing the work tables.\n"); + return ret; + } + s->sys = sys; + } + s->frame = data; s->frame->key_frame = 1; s->frame->pict_type = AV_PICTURE_TYPE_I; @@ -345,7 +355,7 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, s->frame->top_field_first = 0; s->buf = buf; - avctx->execute(avctx, dv_decode_video_segment, s->sys->work_chunks, NULL, + avctx->execute(avctx, dv_decode_video_segment, s->work_chunks, NULL, dv_work_pool_size(s->sys), sizeof(DVwork_chunk)); emms_c(); -- cgit v1.2.3