Mercurial > libavcodec.hg
comparison h263dec.c @ 1004:3b9c2ac59ec4 libavcodec
padding bug autodetection improvement 2nd try
author | michaelni |
---|---|
date | Mon, 13 Jan 2003 13:20:21 +0000 |
parents | c2c116876fd7 |
children | 1f9afd8b9131 |
comparison
equal
deleted
inserted
replaced
1003:c2c116876fd7 | 1004:3b9c2ac59ec4 |
---|---|
142 return pos; | 142 return pos; |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 static int decode_slice(MpegEncContext *s){ | 146 static int decode_slice(MpegEncContext *s){ |
147 const int workaround_bugs= s->workaround_bugs; | |
148 | |
149 s->last_resync_gb= s->gb; | 147 s->last_resync_gb= s->gb; |
150 s->first_slice_line= 1; | 148 s->first_slice_line= 1; |
151 | 149 |
152 s->resync_mb_x= s->mb_x; | 150 s->resync_mb_x= s->mb_x; |
153 s->resync_mb_y= s->mb_y; | 151 s->resync_mb_y= s->mb_y; |
270 if(v==0x7F) | 268 if(v==0x7F) |
271 s->padding_bug_score--; | 269 s->padding_bug_score--; |
272 else | 270 else |
273 s->padding_bug_score++; | 271 s->padding_bug_score++; |
274 } | 272 } |
275 | |
276 if(s->padding_bug_score > -2) | |
277 s->workaround_bugs |= FF_BUG_NO_PADDING; | |
278 else | |
279 s->workaround_bugs &= ~FF_BUG_NO_PADDING; | |
280 } | 273 } |
281 | 274 |
282 // handle formats which dont have unique end markers | 275 // handle formats which dont have unique end markers |
283 if(s->msmpeg4_version || (workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly | 276 if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly |
284 int left= s->gb.size*8 - get_bits_count(&s->gb); | 277 int left= s->gb.size*8 - get_bits_count(&s->gb); |
285 int max_extra=7; | 278 int max_extra=7; |
286 | 279 |
287 /* no markers in M$ crap */ | 280 /* no markers in M$ crap */ |
288 if(s->msmpeg4_version && s->pict_type==I_TYPE) | 281 if(s->msmpeg4_version && s->pict_type==I_TYPE) |
289 max_extra+= 17; | 282 max_extra+= 17; |
290 | 283 |
291 /* buggy padding but the frame should still end approximately at the bitstream end */ | 284 /* buggy padding but the frame should still end approximately at the bitstream end */ |
292 if((workaround_bugs&FF_BUG_NO_PADDING) && s->error_resilience>=3) | 285 if((s->workaround_bugs&FF_BUG_NO_PADDING) && s->error_resilience>=3) |
293 max_extra+= 48; | 286 max_extra+= 48; |
294 else if((workaround_bugs&FF_BUG_NO_PADDING)) | 287 else if((s->workaround_bugs&FF_BUG_NO_PADDING)) |
295 max_extra+= 256*256*256*64; | 288 max_extra+= 256*256*256*64; |
296 | 289 |
297 if(left>max_extra){ | 290 if(left>max_extra){ |
298 fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24)); | 291 fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24)); |
299 } | 292 } |
480 ret = h263_decode_picture_header(s); | 473 ret = h263_decode_picture_header(s); |
481 } | 474 } |
482 avctx->has_b_frames= !s->low_delay; | 475 avctx->has_b_frames= !s->low_delay; |
483 | 476 |
484 if(s->workaround_bugs&FF_BUG_AUTODETECT){ | 477 if(s->workaround_bugs&FF_BUG_AUTODETECT){ |
478 if(s->padding_bug_score > -2 && !s->data_partitioning) | |
479 s->workaround_bugs |= FF_BUG_NO_PADDING; | |
480 else | |
481 s->workaround_bugs &= ~FF_BUG_NO_PADDING; | |
482 | |
485 if(s->avctx->fourcc == ff_get_fourcc("XVIX")) | 483 if(s->avctx->fourcc == ff_get_fourcc("XVIX")) |
486 s->workaround_bugs|= FF_BUG_XVID_ILACE; | 484 s->workaround_bugs|= FF_BUG_XVID_ILACE; |
487 #if 0 | 485 #if 0 |
488 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) | 486 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) |
489 s->workaround_bugs|= FF_BUG_AC_VLC; | 487 s->workaround_bugs|= FF_BUG_AC_VLC; |