diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2004-08-31 16:28:49 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2004-08-31 16:28:49 +0000 |
commit | 19aa028dc54cc2091b0bfd2543f5622d5fd6f789 (patch) | |
tree | daade8be5fd2d1789e54cda74addb2ec5e9d50ad /libavcodec | |
parent | 39c61bbbd3fb5fd69ab58d30471a5a967514e95d (diff) | |
download | ffmpeg-19aa028dc54cc2091b0bfd2543f5622d5fd6f789.tar.gz |
10l (keyframes and context resets)
Originally committed as revision 3426 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/snow.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libavcodec/snow.c b/libavcodec/snow.c index 45840c6a04..e8d68dfb4a 100644 --- a/libavcodec/snow.c +++ b/libavcodec/snow.c @@ -400,6 +400,7 @@ typedef struct SnowContext{ uint8_t header_state[32]; uint8_t block_state[128 + 32*128]; int keyframe; + int always_reset; int version; int spatial_decomposition_type; int temporal_decomposition_type; @@ -1526,7 +1527,7 @@ static inline void decode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTE static void reset_contexts(SnowContext *s){ int plane_index, level, orientation; - for(plane_index=0; plane_index<2; plane_index++){ + for(plane_index=0; plane_index<3; plane_index++){ for(level=0; level<s->spatial_decomposition_count; level++){ for(orientation=level ? 1:0; orientation<4; orientation++){ memset(s->plane[plane_index].band[level][orientation].state, 0, sizeof(s->plane[plane_index].band[level][orientation].state)); @@ -2261,10 +2262,14 @@ static void correlate(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int static void encode_header(SnowContext *s){ int plane_index, level, orientation; + uint8_t kstate[32]={0}; - put_cabac(&s->c, s->header_state, s->keyframe); // state clearing stuff? + put_cabac(&s->c, kstate, s->keyframe); + if(s->keyframe || s->always_reset) + reset_contexts(s); if(s->keyframe){ put_symbol(&s->c, s->header_state, s->version, 0); + put_cabac(&s->c, s->header_state, s->always_reset); put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0); put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0); put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0); @@ -2292,14 +2297,18 @@ static void encode_header(SnowContext *s){ static int decode_header(SnowContext *s){ int plane_index, level, orientation; + uint8_t kstate[32]={0}; - s->keyframe= get_cabac(&s->c, s->header_state); + s->keyframe= get_cabac(&s->c, kstate); + if(s->keyframe || s->always_reset) + reset_contexts(s); if(s->keyframe){ s->version= get_symbol(&s->c, s->header_state, 0); if(s->version>0){ av_log(s->avctx, AV_LOG_ERROR, "version %d not supported", s->version); return -1; } + s->always_reset= get_cabac(&s->c, s->header_state); s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); @@ -2522,9 +2531,6 @@ static int frame_start(SnowContext *s){ int w= s->avctx->width; //FIXME round up to x16 ? int h= s->avctx->height; - if(s->keyframe) - reset_contexts(s); - if(s->current_picture.data[0]){ draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH ); draw_edges(s->current_picture.data[1], s->current_picture.linesize[1], w>>1, h>>1, EDGE_WIDTH/2); @@ -2557,8 +2563,6 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, s->input_picture = *pict; - memset(s->header_state, 0, sizeof(s->header_state)); - s->keyframe=avctx->gop_size==0 || avctx->frame_number % avctx->gop_size == 0; pict->pict_type= s->keyframe ? FF_I_TYPE : FF_P_TYPE; @@ -2571,6 +2575,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, } frame_start(s); + s->current_picture.key_frame= s->keyframe; if(pict->pict_type == P_TYPE){ int block_width = (width +15)>>4; @@ -2777,8 +2782,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8 ff_init_cabac_decoder(c, buf, buf_size); ff_init_cabac_states(c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); - memset(s->header_state, 0, sizeof(s->header_state)); - s->current_picture.pict_type= FF_I_TYPE; //FIXME I vs. P decode_header(s); if(!s->block) alloc_blocks(s); |