Statistics
| Branch: | Revision:

ffmpeg / libavcodec / h263dec.c @ d6db1c9c

History | View | Annotate | Download (20.7 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
        s->first_slice_line = 0;
64
        break;
65
    case CODEC_ID_MPEG4:
66
        s->time_increment_bits = 4; /* default value for broken headers */
67
        s->h263_pred = 1;
68
        s->has_b_frames = 1; //default, might be overriden in the vol header during header parsing
69
        break;
70
    case CODEC_ID_MSMPEG4V1:
71
        s->h263_msmpeg4 = 1;
72
        s->h263_pred = 1;
73
        s->msmpeg4_version=1;
74
        break;
75
    case CODEC_ID_MSMPEG4V2:
76
        s->h263_msmpeg4 = 1;
77
        s->h263_pred = 1;
78
        s->msmpeg4_version=2;
79
        break;
80
    case CODEC_ID_MSMPEG4V3:
81
        s->h263_msmpeg4 = 1;
82
        s->h263_pred = 1;
83
        s->msmpeg4_version=3;
84
        break;
85
    case CODEC_ID_WMV1:
86
        s->h263_msmpeg4 = 1;
87
        s->h263_pred = 1;
88
        s->msmpeg4_version=4;
89
        break;
90
    case CODEC_ID_WMV2:
91
        s->h263_msmpeg4 = 1;
92
        s->h263_pred = 1;
93
        s->msmpeg4_version=5;
94
        break;
95
    case CODEC_ID_H263I:
96
        s->h263_intel = 1;
97
        break;
98
    default:
99
        return -1;
100
    }
101
    s->codec_id= avctx->codec->id;
102

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

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

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

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

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

    
136
        return pos;
137
    }
138
}
139

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

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

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

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

    
187
            ff_update_block_index(s);
188

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

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

    
204
            if(ret<0){
205
                const int xy= s->mb_x + s->mb_y*s->mb_width;
206
                if(ret==SLICE_END){
207
//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));
208
                    s->error_status_table[xy]|= AC_END;
209
                    if(!s->partitioned_frame)
210
                        s->error_status_table[xy]|= MV_END|DC_END;
211

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
436
        goto retry;
437
    }
438

    
439
    if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))
440
        s->gob_index = ff_h263_get_gob_height(s);
441

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

    
460
    if(MPV_frame_start(s, avctx) < 0)
461
        return -1;
462

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

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

    
494
        decode_slice(s);
495

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

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

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

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

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

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

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

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

    
603
    avctx->quality = s->qscale;
604

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

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

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

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

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

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

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

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

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

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