Revision eec1c6b9

View differences:

libavcodec/h263.c
2564 2564
        }
2565 2565
        state = ((state << 8) | v) & 0xffffff;
2566 2566
        if( get_bits_count(&s->gb) > s->gb.size*8-32){
2567
            printf("no VOP startcode found\n");
2568
            return -1;
2567
            if(s->gb.size>50){
2568
                printf("no VOP startcode found, frame size was=%d\n", s->gb.size);
2569
                return -1;
2570
            }else{
2571
                printf("frame skip\n");
2572
                return FRAME_SKIPED;
2573
            }
2569 2574
        }
2570 2575
    }
2571 2576
//printf("startcode %X %d\n", startcode, get_bits_count(&s->gb));
......
2763 2768
        }
2764 2769
        buf[255]=0;
2765 2770
        e=sscanf(buf, "DivX%dBuild%d", &ver, &build);
2771
        if(e!=2)
2772
            e=sscanf(buf, "DivX%db%d", &ver, &build);
2766 2773
        if(e==2){
2767 2774
            s->divx_version= ver;
2768 2775
            s->divx_build= build;
2769 2776
            if(s->picture_number==0){
2770 2777
                printf("This file was encoded with DivX%d Build%d\n", ver, build);
2771
                if(ver==500 && build==413){ //most likely all version are indeed totally buggy but i dunno for sure ...
2778
                if(ver==500 && build==413){
2772 2779
                    printf("WARNING: this version of DivX is not MPEG4 compatible, trying to workaround these bugs...\n");
2780
#if 0
2773 2781
                }else{
2774 2782
                    printf("hmm, i havnt seen that version of divx yet, lets assume they fixed these bugs ...\n"
2775 2783
                           "using mpeg4 decoder, if it fails contact the developers (of ffmpeg)\n");
2784
#endif 
2776 2785
                }
2777 2786
            }
2778 2787
        }
......
2887 2896
         }
2888 2897
     }
2889 2898
     s->picture_number++; // better than pic number==0 allways ;)
2899
//printf("done\n");
2890 2900
     return 0;
2891 2901
}
2892 2902

  
libavcodec/h263dec.c
119 119
        return 0;
120 120
    }
121 121

  
122
    init_get_bits(&s->gb, buf, buf_size);
122
    if(s->bitstream_buffer_size) //divx 5.01+ frame reorder
123
        init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size);
124
    else
125
        init_get_bits(&s->gb, buf, buf_size);
123 126

  
124 127
    /* let's go :-) */
125 128
    if (s->h263_msmpeg4) {
......
131 134
    } else {
132 135
        ret = h263_decode_picture_header(s);
133 136
    }
137
    if(ret==FRAME_SKIPED) return 0;
134 138

  
135 139
        /* After H263 & mpeg4 header decode we have the height, width,*/
136 140
        /* and other parameters. So then we could init the picture   */
......
241 245
    
242 246
    if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)
243 247
        if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
244

  
248
    
249
    /* divx 5.01+ bistream reorder stuff */
250
    if(s->h263_pred && s->bitstream_buffer_size==0){
251
        int current_pos= get_bits_count(&s->gb)/8;
252
        if(   buf_size - current_pos > 5 
253
           && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){
254
            memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
255
            s->bitstream_buffer_size= buf_size - current_pos;
256
        }
257
    }else
258
        s->bitstream_buffer_size=0;
259
  
245 260
    MPV_frame_end(s);
246 261
    
247 262
    if(s->pict_type==B_TYPE || (!s->has_b_frames)){
libavcodec/mpegvideo.c
292 292
        if (!s->mbintra_table)
293 293
            goto fail;
294 294
        memset(s->mbintra_table, 1, s->mb_num);
295
        
296
        /* divx501 bitstream reorder buffer */
297
        s->bitstream_buffer= av_mallocz(BITSTREAM_BUFFER_SIZE);
298
        if (!s->bitstream_buffer)
299
            goto fail;
295 300
    }
296 301
    /* default structure is frame */
297 302
    s->picture_structure = PICT_FRAME;
......
340 345
    CHECK_FREE(s->me_scratchpad);
341 346

  
342 347
    CHECK_FREE(s->mbskip_table);
348
    CHECK_FREE(s->bitstream_buffer);
343 349
    for(i=0;i<3;i++) {
344 350
        int j;
345 351
        CHECK_FREE(s->last_picture_base[i]);
libavcodec/mpegvideo.h
23 23
#define B_TYPE 3
24 24
#define S_TYPE 4 //S(GMC)-VOP MPEG4
25 25

  
26
#define FRAME_SKIPED 100 // return value for header parsers if frame is not coded
27

  
26 28
enum OutputFormat {
27 29
    FMT_MPEG1,
28 30
    FMT_H263,
......
298 300
    /* divx specific, used to workaround (many) bugs in divx5 */
299 301
    int divx_version;
300 302
    int divx_build;
301

  
303
#define BITSTREAM_BUFFER_SIZE 1024*256
304
    uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
305
    int bitstream_buffer_size;
306
    
302 307
    /* RV10 specific */
303 308
    int rv10_version; /* RV10 version: 0 or 3 */
304 309
    int rv10_first_dc_coded[3];

Also available in: Unified diff