diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-10-27 03:01:11 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-10-27 03:01:11 +0400 |
commit | 99a5e93526cc6394d347e3d2a8c86daf891ef9ac (patch) | |
tree | cbf0f468bc0cc054d16401a10eb3d84069319bfc /libavcodec/ffv1.c | |
parent | 672e7e391aa34e02ccff278ea00771e9a8a17502 (diff) |
Add initial_states array to ffv1.
Originally committed as revision 25582 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ffv1.c')
-rw-r--r-- | libavcodec/ffv1.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index 4985312e72..25006e810a 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -247,6 +247,7 @@ typedef struct FFV1Context{ int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; int context_count[MAX_QUANT_TABLES]; uint8_t state_transition[256]; + uint8_t (*initial_states[MAX_QUANT_TABLES])[32]; int run_index; int colorspace; int_fast16_t *sample_buffer; @@ -754,6 +755,18 @@ static av_cold int init_slice_contexts(FFV1Context *f){ return 0; } +static int allocate_initial_states(FFV1Context *f){ + int i; + + for(i=0; i<f->quant_table_count; i++){ + f->initial_states[i]= av_malloc(f->context_count[i]*sizeof(*f->initial_states[i])); + if(!f->initial_states[i]) + return AVERROR(ENOMEM); + memset(f->initial_states[i], 128, f->context_count[i]*sizeof(*f->initial_states[i])); + } + return 0; +} + #if CONFIG_FFV1_ENCODER static int write_extra_header(FFV1Context *f){ RangeCoder * const c= &f->c; @@ -882,6 +895,9 @@ static av_cold int encode_init(AVCodecContext *avctx) p->context_count= s->context_count[p->quant_table_index]; } + if(allocate_initial_states(s) < 0) + return AVERROR(ENOMEM); + avctx->coded_frame= &s->picture; switch(avctx->pix_fmt){ case PIX_FMT_YUV444P16: @@ -977,6 +993,9 @@ static void clear_state(FFV1Context *f){ p->interlace_bit_state[1]= 128; if(fs->ac){ + if(f->initial_states[p->quant_table_index]){ + memcpy(p->state, f->initial_states[p->quant_table_index], CONTEXT_SIZE*p->context_count); + }else memset(p->state, 128, CONTEXT_SIZE*p->context_count); }else{ for(j=0; j<p->context_count; j++){ @@ -1137,6 +1156,7 @@ static av_cold int common_end(AVCodecContext *avctx){ av_freep(&avctx->stats_out); for(j=0; j<s->quant_table_count; j++){ + av_freep(&s->initial_states[j]); for(i=0; i<s->slice_count; i++){ FFV1Context *sf= s->slice_context[i]; av_freep(&sf->rc_stat2[j]); |