Statistics
| Branch: | Revision:

ffmpeg / libavcodec / h263dec.c @ 9f9c3229

History | View | Annotate | Download (20.8 KB)

1
/*
2
 * H263 decoder
3
 * Copyright (c) 2001 Fabrice Bellard.
4
 *
5
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9
 *
10
 * This library is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 */
19
#include "avcodec.h"
20
#include "dsputil.h"
21
#include "mpegvideo.h"
22

    
23
#if 1
24
#define PRINT_QP(a, b) {}
25
#else
26
#define PRINT_QP(a, b) printf(a, b)
27
#endif
28

    
29
//#define DEBUG
30
//#define PRINT_FRAME_TIME
31
#ifdef PRINT_FRAME_TIME
32
static inline long long rdtsc()
33
{
34
        long long l;
35
        asm volatile(        "rdtsc\n\t"
36
                : "=A" (l)
37
        );
38
//        printf("%d\n", int(l/1000));
39
        return l;
40
}
41
#endif
42

    
43
static int h263_decode_init(AVCodecContext *avctx)
44
{
45
    MpegEncContext *s = avctx->priv_data;
46

    
47
    s->avctx = avctx;
48
    s->out_format = FMT_H263;
49

    
50
    s->width = avctx->width;
51
    s->height = avctx->height;
52
    s->workaround_bugs= avctx->workaround_bugs;
53

    
54
    // set defaults
55
    s->quant_precision=5;
56
    s->progressive_sequence=1;
57
    s->decode_mb= ff_h263_decode_mb;
58

    
59
    /* select sub codec */
60
    switch(avctx->codec->id) {
61
    case CODEC_ID_H263:
62
        s->gob_number = 0;
63
        break;
64
    case CODEC_ID_MPEG4:
65
        s->time_increment_bits = 4; /* default value for broken headers */
66
        s->h263_pred = 1;
67
        s->has_b_frames = 1; //default, might be overriden in the vol header during header parsing
68
        break;
69
    case CODEC_ID_MSMPEG4V1:
70
        s->h263_msmpeg4 = 1;
71
        s->h263_pred = 1;
72
        s->msmpeg4_version=1;
73
        break;
74
    case CODEC_ID_MSMPEG4V2:
75
        s->h263_msmpeg4 = 1;
76
        s->h263_pred = 1;
77
        s->msmpeg4_version=2;
78
        break;
79
    case CODEC_ID_MSMPEG4V3:
80
        s->h263_msmpeg4 = 1;
81
        s->h263_pred = 1;
82
        s->msmpeg4_version=3;
83
        break;
84
    case CODEC_ID_WMV1:
85
        s->h263_msmpeg4 = 1;
86
        s->h263_pred = 1;
87
        s->msmpeg4_version=4;
88
        break;
89
    case CODEC_ID_WMV2:
90
        s->h263_msmpeg4 = 1;
91
        s->h263_pred = 1;
92
        s->msmpeg4_version=5;
93
        break;
94
    case CODEC_ID_H263I:
95
        s->h263_intel = 1;
96
        break;
97
    default:
98
        return -1;
99
    }
100
    s->codec_id= avctx->codec->id;
101

    
102
    /* for h263, we allocate the images after having read the header */
103
    if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4)
104
        if (MPV_common_init(s) < 0)
105
            return -1;
106

    
107
    if (s->h263_msmpeg4)
108
        ff_msmpeg4_decode_init(s);
109
    else
110
        h263_decode_init_vlc(s);
111
    
112
    return 0;
113
}
114

    
115
static int h263_decode_end(AVCodecContext *avctx)
116
{
117
    MpegEncContext *s = avctx->priv_data;
118

    
119
    MPV_common_end(s);
120
    return 0;
121
}
122

    
123
/**
124
 * retunrs the number of bytes consumed for building the current frame
125
 */
126
static int get_consumed_bytes(MpegEncContext *s, int buf_size){
127
    int pos= (get_bits_count(&s->gb)+7)>>3;
128
    if(s->divx_version>=500){
129
        //we would have to scan through the whole buf to handle the weird reordering ...
130
        return buf_size; 
131
    }else{
132
        if(pos==0) pos=1; //avoid infinite loops (i doubt thats needed but ...)
133
        if(pos+10>buf_size) pos=buf_size; // oops ;)
134

    
135
        return pos;
136
    }
137
}
138

    
139
static int decode_slice(MpegEncContext *s){
140
    s->last_resync_gb= s->gb;
141
    s->first_slice_line= 1;
142
        
143
    s->resync_mb_x= s->mb_x;
144
    s->resync_mb_y= s->mb_y;
145

    
146
    s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
147
    s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
148
    
149
    if(s->partitioned_frame){
150
        const int qscale= s->qscale;
151

    
152
        if(s->codec_id==CODEC_ID_MPEG4){
153
            if(ff_mpeg4_decode_partitions(s) < 0)
154
                return -1; 
155
        }
156
        
157
        /* restore variables which where modified */
158
        s->first_slice_line=1;
159
        s->mb_x= s->resync_mb_x;
160
        s->mb_y= s->resync_mb_y;
161
        s->qscale= qscale;
162
        s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
163
        s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
164
    }
165

    
166
    for(; s->mb_y < s->mb_height; s->mb_y++) {
167
        /* per-row end of slice checks */
168
        if(s->msmpeg4_version){
169
            if(s->resync_mb_y + s->slice_height == s->mb_y){
170
                const int xy= s->mb_x + s->mb_y*s->mb_width;
171
                s->error_status_table[xy-1]|= AC_END|DC_END|MV_END;
172
                return 0;
173
            }
174
        }
175
        
176
        if(s->msmpeg4_version==1){
177
            s->last_dc[0]=
178
            s->last_dc[1]=
179
            s->last_dc[2]= 128;
180
        }
181
    
182
        ff_init_block_index(s);
183
        for(; s->mb_x < s->mb_width; s->mb_x++) {
184
            int ret;
185

    
186
            ff_update_block_index(s);
187

    
188
            if(s->resync_mb_x == s->mb_x && s->resync_mb_y+1 == s->mb_y){
189
                s->first_slice_line=0; 
190
            }
191

    
192
            /* DCT & quantize */
193
            clear_blocks(s->block[0]);
194
            
195
            s->mv_dir = MV_DIR_FORWARD;
196
            s->mv_type = MV_TYPE_16X16;
197
//printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24));
198
            ret= s->decode_mb(s, s->block);
199
            
200
            PRINT_QP("%2d", s->qscale);
201
            MPV_decode_mb(s, s->block);
202

    
203
            if(ret<0){
204
                const int xy= s->mb_x + s->mb_y*s->mb_width;
205
                if(ret==SLICE_END){
206
//printf("%d %d %d %06X\n", s->mb_x, s->mb_y, s->gb.size*8 - get_bits_count(&s->gb), show_bits(&s->gb, 24));
207
                    s->error_status_table[xy]|= AC_END;
208
                    if(!s->partitioned_frame)
209
                        s->error_status_table[xy]|= MV_END|DC_END;
210

    
211
                    s->padding_bug_score--;
212
                        
213
                    if(++s->mb_x >= s->mb_width){
214
                        s->mb_x=0;
215
                        ff_draw_horiz_band(s);
216
                        s->mb_y++;
217
                    }
218
                    return 0; 
219
                }else if(ret==SLICE_NOEND){
220
                    fprintf(stderr,"Slice mismatch at MB: %d\n", xy);
221
                    return -1;
222
                }
223
                fprintf(stderr,"Error at MB: %d\n", xy);
224
                s->error_status_table[xy]|= AC_ERROR;
225
                if(!s->partitioned_frame)
226
                    s->error_status_table[xy]|= DC_ERROR|MV_ERROR;
227
    
228
                return -1;
229
            }
230
        }
231
        
232
        ff_draw_horiz_band(s);
233
        
234
        PRINT_QP("%s", "\n");
235
        
236
        s->mb_x= 0;
237
    }
238
    
239
    assert(s->mb_x==0 && s->mb_y==s->mb_height);
240

    
241
    /* try to detect the padding bug */
242
    if(      s->codec_id==CODEC_ID_MPEG4
243
       &&   (s->workaround_bugs&FF_BUG_AUTODETECT) 
244
       &&    s->gb.size*8 - get_bits_count(&s->gb) >=0
245
       &&    s->gb.size*8 - get_bits_count(&s->gb) < 48
246
       &&   !s->resync_marker
247
       &&   !s->data_partitioning){
248
        
249
        const int bits_count= get_bits_count(&s->gb);
250
        const int bits_left = s->gb.size*8 - bits_count;
251
        
252
        if(bits_left==0 || bits_left>8){
253
            s->padding_bug_score++;
254
        } else if(bits_left != 1){
255
            int v= show_bits(&s->gb, 8);
256
            v|= 0x7F >> (7-(bits_count&7));
257

    
258
            if(v==0x7F)
259
                s->padding_bug_score--;
260
            else
261
                s->padding_bug_score++;            
262
        }
263
        
264
        if(s->padding_bug_score > -2)
265
            s->workaround_bugs |=  FF_BUG_NO_PADDING;
266
        else
267
            s->workaround_bugs &= ~FF_BUG_NO_PADDING;
268
    }
269

    
270
    // handle formats which dont have unique end markers
271
    if(s->msmpeg4_version || (s->workaround_bugs&FF_BUG_NO_PADDING)){ //FIXME perhaps solve this more cleanly
272
        int left= s->gb.size*8 - get_bits_count(&s->gb);
273
        int max_extra=7;
274
        
275
        /* no markers in M$ crap */
276
        if(s->msmpeg4_version && s->pict_type==I_TYPE)
277
            max_extra+= 17;
278
        
279
        /* buggy padding but the frame should still end approximately at the bitstream end */
280
        if((s->workaround_bugs&FF_BUG_NO_PADDING) && s->error_resilience>=3)
281
            max_extra+= 48;
282
        else if((s->workaround_bugs&FF_BUG_NO_PADDING))
283
            max_extra+= 256*256*256*64;
284
        
285
        if(left>max_extra){
286
            fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24));
287
        }
288
        else if(left<0){
289
            fprintf(stderr, "overreading %d bits\n", -left);
290
        }else
291
            s->error_status_table[s->mb_num-1]|= AC_END|MV_END|DC_END;
292
        
293
        return 0;
294
    }
295

    
296
    fprintf(stderr, "slice end not reached but screenspace end (%d left %06X)\n", 
297
            s->gb.size*8 - get_bits_count(&s->gb),
298
            show_bits(&s->gb, 24));
299
    return -1;
300
}
301

    
302
static int h263_decode_frame(AVCodecContext *avctx, 
303
                             void *data, int *data_size,
304
                             UINT8 *buf, int buf_size)
305
{
306
    MpegEncContext *s = avctx->priv_data;
307
    int ret,i;
308
    AVPicture *pict = data; 
309
#ifdef PRINT_FRAME_TIME
310
uint64_t time= rdtsc();
311
#endif
312
#ifdef DEBUG
313
    printf("*****frame %d size=%d\n", avctx->frame_number, buf_size);
314
    printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
315
#endif
316

    
317
    s->hurry_up= avctx->hurry_up;
318
    s->error_resilience= avctx->error_resilience;
319

    
320
    s->flags= avctx->flags;
321

    
322
    *data_size = 0;
323
   
324
   /* no supplementary picture */
325
    if (buf_size == 0) {
326
        return 0;
327
    }
328

    
329
retry:
330
    
331
    if(s->bitstream_buffer_size && buf_size<20){ //divx 5.01+ frame reorder
332
        init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size);
333
    }else
334
        init_get_bits(&s->gb, buf, buf_size);
335
    s->bitstream_buffer_size=0;
336

    
337
    if (!s->context_initialized) {
338
        if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix
339
            return -1;
340
    }
341
        
342
    /* let's go :-) */
343
    if (s->h263_msmpeg4) {
344
        ret = msmpeg4_decode_picture_header(s);
345
    } else if (s->h263_pred) {
346
        if(s->avctx->extradata_size && s->picture_number==0){
347
            GetBitContext gb;
348
            
349
            init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size);
350
            ret = ff_mpeg4_decode_picture_header(s, &gb);
351
        }
352
        ret = ff_mpeg4_decode_picture_header(s, &s->gb);
353

    
354
        if(s->flags& CODEC_FLAG_LOW_DELAY)
355
            s->low_delay=1;
356

    
357
        s->has_b_frames= !s->low_delay;
358
    } else if (s->h263_intel) {
359
        ret = intel_h263_decode_picture_header(s);
360
    } else {
361
        ret = h263_decode_picture_header(s);
362
    }
363
    avctx->has_b_frames= s->has_b_frames;
364

    
365
    if(s->workaround_bugs&FF_BUG_AUTODETECT){
366
        if(s->avctx->fourcc == ff_get_fourcc("XVIX")) 
367
            s->workaround_bugs|= FF_BUG_XVID_ILACE;
368

    
369
        if(s->avctx->fourcc == ff_get_fourcc("MP4S")) 
370
            s->workaround_bugs|= FF_BUG_AC_VLC;
371
        
372
        if(s->avctx->fourcc == ff_get_fourcc("M4S2")) 
373
            s->workaround_bugs|= FF_BUG_AC_VLC;
374
                
375
        if(s->avctx->fourcc == ff_get_fourcc("UMP4")){
376
            s->workaround_bugs|= FF_BUG_UMP4;
377
            s->workaround_bugs|= FF_BUG_AC_VLC;
378
        }
379

    
380
        if(s->divx_version){
381
            s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
382
        }
383

    
384
        if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0)
385
            s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
386
        
387
        if(s->xvid_build && s->xvid_build<=1)
388
            s->workaround_bugs|= FF_BUG_QPEL_CHROMA;
389

    
390
//printf("padding_bug_score: %d\n", s->padding_bug_score);
391
#if 0
392
        if(s->divx_version==500)
393
            s->workaround_bugs|= FF_BUG_NO_PADDING;
394

395
        /* very ugly XVID padding bug detection FIXME/XXX solve this differently
396
         * lets hope this at least works
397
         */
398
        if(   s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0
399
           && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0)
400
            s->workaround_bugs|= FF_BUG_NO_PADDING;
401
        
402
        if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok
403
            s->workaround_bugs|= FF_BUG_NO_PADDING;
404
#endif
405
    }
406
    
407

    
408
#if 0 // dump bits per frame / qp / complexity
409
{
410
    static FILE *f=NULL;
411
    if(!f) f=fopen("rate_qp_cplx.txt", "w");
412
    fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale);
413
}
414
#endif
415
       
416
        /* After H263 & mpeg4 header decode we have the height, width,*/
417
        /* and other parameters. So then we could init the picture   */
418
        /* FIXME: By the way H263 decoder is evolving it should have */
419
        /* an H263EncContext                                         */
420
    if (   s->width != avctx->width || s->height != avctx->height 
421
        || avctx->aspect_ratio_info != s->aspect_ratio_info
422
        || avctx->aspected_width != s->aspected_width
423
        || avctx->aspected_height != s->aspected_height) {
424
        /* H.263 could change picture size any time */
425
        MPV_common_end(s);
426
        s->context_initialized=0;
427
    }
428
    if (!s->context_initialized) {
429
        avctx->width = s->width;
430
        avctx->height = s->height;
431
        avctx->aspect_ratio_info= s->aspect_ratio_info;
432
        if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
433
        {
434
            avctx->aspected_width = s->aspected_width;
435
            avctx->aspected_height = s->aspected_height;
436
        }
437

    
438
        goto retry;
439
    }
440

    
441
    if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))
442
        s->gob_index = ff_h263_get_gob_height(s);
443

    
444
    if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size);
445
    /* skip if the header was thrashed */
446
    if (ret < 0){
447
        fprintf(stderr, "header damaged\n");
448
        return -1;
449
    }
450
    /* skip b frames if we dont have reference frames */
451
    if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
452
    /* skip b frames if we are in a hurry */
453
    if(s->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size);
454
    
455
    if(s->next_p_frame_damaged){
456
        if(s->pict_type==B_TYPE)
457
            return get_consumed_bytes(s, buf_size);
458
        else
459
            s->next_p_frame_damaged=0;
460
    }
461

    
462
    if(MPV_frame_start(s, avctx) < 0)
463
        return -1;
464

    
465
#ifdef DEBUG
466
    printf("qscale=%d\n", s->qscale);
467
#endif
468

    
469
    if(s->error_resilience)
470
        memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8));
471
    
472
    /* decode each macroblock */
473
    s->block_wrap[0]=
474
    s->block_wrap[1]=
475
    s->block_wrap[2]=
476
    s->block_wrap[3]= s->mb_width*2 + 2;
477
    s->block_wrap[4]=
478
    s->block_wrap[5]= s->mb_width + 2;
479
    s->mb_x=0; 
480
    s->mb_y=0;
481
    
482
    decode_slice(s);
483
    s->error_status_table[0]|= VP_START;
484
    while(s->mb_y<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){
485
        if(s->msmpeg4_version){
486
            if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0)
487
                break;
488
        }else{
489
            if(ff_h263_resync(s)<0)
490
                break;
491
        }
492
        
493
        if(s->msmpeg4_version!=4 && s->h263_pred)
494
            ff_mpeg4_clean_buffers(s);
495

    
496
        decode_slice(s);
497

    
498
        s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START;
499
    }
500

    
501
    if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)
502
        if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1;
503
    
504
    /* divx 5.01+ bistream reorder stuff */
505
    if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){
506
        int current_pos= get_bits_count(&s->gb)>>3;
507

    
508
        if(   buf_size - current_pos > 5 
509
           && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){
510
            int i;
511
            int startcode_found=0;
512
            for(i=current_pos; i<buf_size-3; i++){
513
                if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){
514
                    startcode_found=1;
515
                    break;
516
                }
517
            }
518
            if(startcode_found){
519
                memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos);
520
                s->bitstream_buffer_size= buf_size - current_pos;
521
            }
522
        }
523
    }
524

    
525
    if(s->error_resilience){
526
        int error=0, num_end_markers=0;
527
        for(i=0; i<s->mb_num; i++){
528
            int status= s->error_status_table[i];
529
#if 0
530
            if(i%s->mb_width == 0) printf("\n");
531
            printf("%2X ", status); 
532
#endif
533
            if(status==0) continue;
534

    
535
            if(status&(DC_ERROR|AC_ERROR|MV_ERROR))
536
                error=1;
537
            if(status&VP_START){
538
                if(num_end_markers) 
539
                    error=1;
540
                num_end_markers=3;
541
            }
542
            if(status&AC_END)
543
                num_end_markers--;
544
            if(status&DC_END)
545
                num_end_markers--;
546
            if(status&MV_END)
547
                num_end_markers--;
548
        }
549
        if(num_end_markers || error){
550
            fprintf(stderr, "concealing errors\n");
551
//printf("type:%d\n", s->pict_type);
552
            ff_error_resilience(s);
553
        }
554
    }
555

    
556
    MPV_frame_end(s);
557
#if 0 //dirty show MVs, we should export the MV tables and write a filter to show them
558
{
559
  int mb_y;
560
  s->has_b_frames=1;
561
  for(mb_y=0; mb_y<s->mb_height; mb_y++){
562
    int mb_x;
563
    int y= mb_y*16 + 8;
564
    for(mb_x=0; mb_x<s->mb_width; mb_x++){
565
      int x= mb_x*16 + 8;
566
      uint8_t *ptr= s->last_picture[0];
567
      int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2);
568
      int mx= (s->motion_val[xy][0]>>1) + x;
569
      int my= (s->motion_val[xy][1]>>1) + y;
570
      int i;
571
      int max;
572

573
      if(mx<0) mx=0;
574
      if(my<0) my=0;
575
      if(mx>=s->width)  mx= s->width -1;
576
      if(my>=s->height) my= s->height-1;
577
      max= ABS(mx-x);
578
      if(ABS(my-y) > max) max= ABS(my-y);
579
      /* the ugliest linedrawing routine ... */
580
      for(i=0; i<max; i++){
581
        int x1= x + (mx-x)*i/max;
582
        int y1= y + (my-y)*i/max;
583
        ptr[y1*s->linesize + x1]+=100;
584
      }
585
      ptr[y*s->linesize + x]+=100;
586
      s->mbskip_table[mb_x + mb_y*s->mb_width]=0;
587
    }
588
  }
589

590
}
591
#endif    
592
    if(s->pict_type==B_TYPE || (!s->has_b_frames)){
593
        pict->data[0] = s->current_picture[0];
594
        pict->data[1] = s->current_picture[1];
595
        pict->data[2] = s->current_picture[2];
596
    } else {
597
        pict->data[0] = s->last_picture[0];
598
        pict->data[1] = s->last_picture[1];
599
        pict->data[2] = s->last_picture[2];
600
    }
601
    pict->linesize[0] = s->linesize;
602
    pict->linesize[1] = s->uvlinesize;
603
    pict->linesize[2] = s->uvlinesize;
604

    
605
    avctx->quality = s->qscale;
606

    
607
    /* Return the Picture timestamp as the frame number */
608
    /* we substract 1 because it is added on utils.c    */
609
    avctx->frame_number = s->picture_number - 1;
610

    
611
    /* dont output the last pic after seeking 
612
       note we allready added +1 for the current pix in MPV_frame_end(s) */
613
    if(s->num_available_buffers>=2 || (!s->has_b_frames))
614
        *data_size = sizeof(AVPicture);
615
#ifdef PRINT_FRAME_TIME
616
printf("%Ld\n", rdtsc()-time);
617
#endif
618
    return get_consumed_bytes(s, buf_size);
619
}
620

    
621
AVCodec mpeg4_decoder = {
622
    "mpeg4",
623
    CODEC_TYPE_VIDEO,
624
    CODEC_ID_MPEG4,
625
    sizeof(MpegEncContext),
626
    h263_decode_init,
627
    NULL,
628
    h263_decode_end,
629
    h263_decode_frame,
630
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
631
};
632

    
633
AVCodec h263_decoder = {
634
    "h263",
635
    CODEC_TYPE_VIDEO,
636
    CODEC_ID_H263,
637
    sizeof(MpegEncContext),
638
    h263_decode_init,
639
    NULL,
640
    h263_decode_end,
641
    h263_decode_frame,
642
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
643
};
644

    
645
AVCodec msmpeg4v1_decoder = {
646
    "msmpeg4v1",
647
    CODEC_TYPE_VIDEO,
648
    CODEC_ID_MSMPEG4V1,
649
    sizeof(MpegEncContext),
650
    h263_decode_init,
651
    NULL,
652
    h263_decode_end,
653
    h263_decode_frame,
654
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
655
};
656

    
657
AVCodec msmpeg4v2_decoder = {
658
    "msmpeg4v2",
659
    CODEC_TYPE_VIDEO,
660
    CODEC_ID_MSMPEG4V2,
661
    sizeof(MpegEncContext),
662
    h263_decode_init,
663
    NULL,
664
    h263_decode_end,
665
    h263_decode_frame,
666
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
667
};
668

    
669
AVCodec msmpeg4v3_decoder = {
670
    "msmpeg4",
671
    CODEC_TYPE_VIDEO,
672
    CODEC_ID_MSMPEG4V3,
673
    sizeof(MpegEncContext),
674
    h263_decode_init,
675
    NULL,
676
    h263_decode_end,
677
    h263_decode_frame,
678
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
679
};
680

    
681
AVCodec wmv1_decoder = {
682
    "wmv1",
683
    CODEC_TYPE_VIDEO,
684
    CODEC_ID_WMV1,
685
    sizeof(MpegEncContext),
686
    h263_decode_init,
687
    NULL,
688
    h263_decode_end,
689
    h263_decode_frame,
690
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
691
};
692

    
693
AVCodec wmv2_decoder = {
694
    "wmv2",
695
    CODEC_TYPE_VIDEO,
696
    CODEC_ID_WMV2,
697
    sizeof(MpegEncContext),
698
    h263_decode_init,
699
    NULL,
700
    h263_decode_end,
701
    h263_decode_frame,
702
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
703
};
704

    
705
AVCodec h263i_decoder = {
706
    "h263i",
707
    CODEC_TYPE_VIDEO,
708
    CODEC_ID_H263I,
709
    sizeof(MpegEncContext),
710
    h263_decode_init,
711
    NULL,
712
    h263_decode_end,
713
    h263_decode_frame,
714
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
715
};
716