comparison h264.c @ 2116:48d9f86fb047 libavcodec

overread fix
author michael
date Thu, 08 Jul 2004 00:53:21 +0000
parents 96b05a70a154
children b25df257eab0
comparison
equal deleted inserted replaced
2115:4ea05f23730b 2116:48d9f86fb047
5115 5115
5116 /* init cabac */ 5116 /* init cabac */
5117 ff_init_cabac_states( &h->cabac, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64 ); 5117 ff_init_cabac_states( &h->cabac, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64 );
5118 ff_init_cabac_decoder( &h->cabac, 5118 ff_init_cabac_decoder( &h->cabac,
5119 s->gb.buffer + get_bits_count(&s->gb)/8, 5119 s->gb.buffer + get_bits_count(&s->gb)/8,
5120 ( s->gb.size_in_bits - get_bits_count(&s->gb) ) ); 5120 ( s->gb.size_in_bits - get_bits_count(&s->gb) + 7)/8);
5121 /* calculate pre-state */ 5121 /* calculate pre-state */
5122 for( i= 0; i < 399; i++ ) { 5122 for( i= 0; i < 399; i++ ) {
5123 int pre; 5123 int pre;
5124 if( h->slice_type == I_TYPE ) 5124 if( h->slice_type == I_TYPE )
5125 pre = clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 ); 5125 pre = clip( ((cabac_context_init_I[i][0] * s->qscale) >>4 ) + cabac_context_init_I[i][1], 1, 126 );
5147 5147
5148 hl_decode_mb(h); 5148 hl_decode_mb(h);
5149 s->mb_y--; 5149 s->mb_y--;
5150 } 5150 }
5151 5151
5152 if( ret < 0 ) { 5152 if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 1) {
5153 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); 5153 av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y);
5154 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); 5154 ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
5155 return -1; 5155 return -1;
5156 } 5156 }
5157 5157