Mercurial > libavcodec.hg
comparison h263dec.c @ 750:4adadf210b3b libavcodec
better padding bug detection
author | michaelni |
---|---|
date | Mon, 14 Oct 2002 19:53:04 +0000 |
parents | 3d4377531f6c |
children | 97077dd24bfa |
comparison
equal
deleted
inserted
replaced
749:07e58dc635a5 | 750:4adadf210b3b |
---|---|
206 if(ret==SLICE_END){ | 206 if(ret==SLICE_END){ |
207 //printf("%d %d %06X\n", s->mb_x, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24)); | 207 //printf("%d %d %06X\n", s->mb_x, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24)); |
208 s->error_status_table[xy]|= AC_END; | 208 s->error_status_table[xy]|= AC_END; |
209 if(!s->partitioned_frame) | 209 if(!s->partitioned_frame) |
210 s->error_status_table[xy]|= MV_END|DC_END; | 210 s->error_status_table[xy]|= MV_END|DC_END; |
211 | 211 |
212 s->padding_bug_score--; | |
213 | |
212 if(++s->mb_x >= s->mb_width){ | 214 if(++s->mb_x >= s->mb_width){ |
213 s->mb_x=0; | 215 s->mb_x=0; |
214 ff_draw_horiz_band(s); | 216 ff_draw_horiz_band(s); |
215 s->mb_y++; | 217 s->mb_y++; |
216 } | 218 } |
235 s->mb_x= 0; | 237 s->mb_x= 0; |
236 } | 238 } |
237 | 239 |
238 assert(s->mb_x==0 && s->mb_y==s->mb_height); | 240 assert(s->mb_x==0 && s->mb_y==s->mb_height); |
239 | 241 |
242 /* try to detect the padding bug */ | |
243 if( s->codec_id==CODEC_ID_MPEG4 | |
244 && (s->workaround_bugs&FF_BUG_AUTODETECT) | |
245 && s->gb.size*8 - get_bits_count(&s->gb) >=0 | |
246 && s->gb.size*8 - get_bits_count(&s->gb) < 48 | |
247 && !s->resync_marker | |
248 && !s->data_partitioning){ | |
249 | |
250 const int bits_count= get_bits_count(&s->gb); | |
251 const int bits_left = s->gb.size*8 - bits_count; | |
252 | |
253 if(bits_left==0 || bits_left>8){ | |
254 s->padding_bug_score++; | |
255 } else { | |
256 int v= show_bits(&s->gb, 8); | |
257 v|= 0x7F >> (7-(bits_count&7)); | |
258 | |
259 if(v==0x7F) | |
260 s->padding_bug_score--; | |
261 else | |
262 s->padding_bug_score++; | |
263 } | |
264 | |
265 if(s->padding_bug_score > -2) | |
266 s->workaround_bugs |= FF_BUG_NO_PADDING; | |
267 else | |
268 s->workaround_bugs &= ~FF_BUG_NO_PADDING; | |
269 } | |
270 | |
240 // handle formats which dont have unique end markers | 271 // handle formats which dont have unique end markers |
241 if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly | 272 if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly |
242 int left= s->gb.size*8 - get_bits_count(&s->gb); | 273 int left= s->gb.size*8 - get_bits_count(&s->gb); |
243 int max_extra=7; | 274 int max_extra=7; |
244 | 275 |
260 }else | 291 }else |
261 s->error_status_table[s->mb_num-1]|= AC_END|MV_END|DC_END; | 292 s->error_status_table[s->mb_num-1]|= AC_END|MV_END|DC_END; |
262 | 293 |
263 return 0; | 294 return 0; |
264 } | 295 } |
265 | 296 |
266 fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n", | 297 fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n", |
267 s->gb.size*8 - get_bits_count(&s->gb), | 298 s->gb.size*8 - get_bits_count(&s->gb), |
268 show_bits(&s->gb, 24)); | 299 show_bits(&s->gb, 24)); |
269 return -1; | 300 return -1; |
270 } | 301 } |
339 | 370 |
340 if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ | 371 if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ |
341 s->workaround_bugs|= FF_BUG_UMP4; | 372 s->workaround_bugs|= FF_BUG_UMP4; |
342 s->workaround_bugs|= FF_BUG_AC_VLC; | 373 s->workaround_bugs|= FF_BUG_AC_VLC; |
343 } | 374 } |
344 | 375 //printf("padding_bug_score: %d\n", s->padding_bug_score); |
376 #if 0 | |
345 if(s->divx_version==500) | 377 if(s->divx_version==500) |
346 s->workaround_bugs|= FF_BUG_NO_PADDING; | 378 s->workaround_bugs|= FF_BUG_NO_PADDING; |
347 | 379 |
348 /* very ugly XVID padding bug detection FIXME/XXX solve this differently | 380 /* very ugly XVID padding bug detection FIXME/XXX solve this differently |
349 * lets hope this at least works | 381 * lets hope this at least works |
352 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) | 384 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) |
353 s->workaround_bugs|= FF_BUG_NO_PADDING; | 385 s->workaround_bugs|= FF_BUG_NO_PADDING; |
354 | 386 |
355 if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok | 387 if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok |
356 s->workaround_bugs|= FF_BUG_NO_PADDING; | 388 s->workaround_bugs|= FF_BUG_NO_PADDING; |
389 #endif | |
357 } | 390 } |
358 | 391 |
359 | 392 |
360 #if 0 // dump bits per frame / qp / complexity | 393 #if 0 // dump bits per frame / qp / complexity |
361 { | 394 { |