diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-25 00:54:50 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-25 01:29:09 +0400 |
commit | e37419a8065f20bd00e7955fa57b38d0530daad3 (patch) | |
tree | 78c61e853b9ac4978dc311680617ec5cf3c4908c /libavcodec/ffv1.c | |
parent | 2b336df3cb9d9bcc12c4b398ea1dbdfe224d152e (diff) |
ffv1: move ac->vlc switch to encode_slice()
This will allow us to use vlc coding in 1.3 too
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ffv1.c')
-rw-r--r-- | libavcodec/ffv1.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c index ac37216c7d..8e79f4712a 100644 --- a/libavcodec/ffv1.c +++ b/libavcodec/ffv1.c @@ -181,6 +181,7 @@ typedef struct FFV1Context{ AVFrame picture; int plane_count; int ac; ///< 1=range coder <-> 0=golomb rice + int ac_byte_count; ///< number of bytes used for AC coding PlaneContext plane[MAX_PLANES]; int16_t quant_table[MAX_CONTEXT_INPUTS][256]; int16_t quant_tables[MAX_QUANT_TABLES][MAX_CONTEXT_INPUTS][256]; @@ -1195,6 +1196,10 @@ static int encode_slice(AVCodecContext *c, void *arg){ if(f->version > 2){ encode_slice_header(f, fs); } + if(!fs->ac){ + fs->ac_byte_count = f->version > 2 || (!x&&!y) ? ff_rac_terminate(&fs->c) : 0; + init_put_bits(&fs->pb, fs->c.bytestream_start + fs->ac_byte_count, fs->c.bytestream_end - fs->c.bytestream_start - fs->ac_byte_count); + } if(f->colorspace==0){ const int chroma_width = -((-width )>>f->chroma_h_shift); @@ -1250,11 +1255,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, p->key_frame= 0; } - if(!f->ac){ - used_count += ff_rac_terminate(c); -//printf("pos=%d\n", used_count); - init_put_bits(&f->slice_context[0]->pb, pkt->data + used_count, pkt->size - used_count); - }else if (f->ac>1){ + if (f->ac>1){ int i; for(i=1; i<256; i++){ c->one_state[i]= f->state_transition[i]; @@ -1267,11 +1268,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *start = pkt->data + (pkt->size-used_count)*i/f->slice_count; int len = pkt->size/f->slice_count; - if(fs->ac){ - ff_init_range_encoder(&fs->c, start, len); - }else{ - init_put_bits(&fs->pb, start, len); - } + ff_init_range_encoder(&fs->c, start, len); } avctx->execute(avctx, encode_slice, &f->slice_context[0], NULL, f->slice_count, sizeof(void*)); @@ -1286,8 +1283,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytes= ff_rac_terminate(&fs->c); }else{ flush_put_bits(&fs->pb); //nicer padding FIXME - bytes= used_count + (put_bits_count(&fs->pb)+7)/8; - used_count= 0; + bytes= fs->ac_byte_count + (put_bits_count(&fs->pb)+7)/8; } if(i>0){ av_assert0(bytes < pkt->size/f->slice_count); |