Revision a61f8265 libavcodec/h263dec.c

View differences:

libavcodec/h263dec.c
208 208
                    s->error_status_table[xy]|= AC_END;
209 209
                    if(!s->partitioned_frame)
210 210
                        s->error_status_table[xy]|= MV_END|DC_END;
211
                    
211

  
212
                    s->padding_bug_score--;
213
                        
212 214
                    if(++s->mb_x >= s->mb_width){
213 215
                        s->mb_x=0;
214 216
                        ff_draw_horiz_band(s);
......
237 239
    
238 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 271
    // handle formats which dont have unique end markers
241 272
    if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly
242 273
        int left= s->gb.size*8 - get_bits_count(&s->gb);
......
262 293
        
263 294
        return 0;
264 295
    }
265
        
296

  
266 297
    fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n", 
267 298
            s->gb.size*8 - get_bits_count(&s->gb),
268 299
            show_bits(&s->gb, 24));
......
341 372
            s->workaround_bugs|= FF_BUG_UMP4;
342 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 377
        if(s->divx_version==500)
346 378
            s->workaround_bugs|= FF_BUG_NO_PADDING;
347 379

  
......
354 386
        
355 387
        if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok
356 388
            s->workaround_bugs|= FF_BUG_NO_PADDING;
389
#endif
357 390
    }
358 391
    
359 392

  

Also available in: Unified diff