]> git.sesse.net Git - ffmpeg/blob - libavcodec/h261dec.c
avcodec/h261dec: Don't initialize unused part of RLTable
[ffmpeg] / libavcodec / h261dec.c
1 /*
2  * H.261 decoder
3  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4  * Copyright (c) 2004 Maarten Daniels
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 /**
24  * @file
25  * H.261 decoder.
26  */
27
28 #include "libavutil/avassert.h"
29 #include "avcodec.h"
30 #include "mpeg_er.h"
31 #include "mpegutils.h"
32 #include "mpegvideo.h"
33 #include "h263.h"
34 #include "h261.h"
35 #include "internal.h"
36
37 #define H261_MBA_VLC_BITS 9
38 #define H261_MTYPE_VLC_BITS 6
39 #define H261_MV_VLC_BITS 7
40 #define H261_CBP_VLC_BITS 9
41 #define TCOEFF_VLC_BITS 9
42 #define MBA_STUFFING 33
43 #define MBA_STARTCODE 34
44
45 static VLC h261_mba_vlc;
46 static VLC h261_mtype_vlc;
47 static VLC h261_mv_vlc;
48 static VLC h261_cbp_vlc;
49
50 static av_cold void h261_decode_init_vlc(H261Context *h)
51 {
52     static int done = 0;
53
54     if (!done) {
55         done = 1;
56         INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
57                         ff_h261_mba_bits, 1, 1,
58                         ff_h261_mba_code, 1, 1, 662);
59         INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
60                         ff_h261_mtype_bits, 1, 1,
61                         ff_h261_mtype_code, 1, 1, 80);
62         INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
63                         &ff_h261_mv_tab[0][1], 2, 1,
64                         &ff_h261_mv_tab[0][0], 2, 1, 144);
65         INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
66                         &ff_h261_cbp_tab[0][1], 2, 1,
67                         &ff_h261_cbp_tab[0][0], 2, 1, 512);
68         INIT_FIRST_VLC_RL(ff_h261_rl_tcoeff, 552);
69     }
70 }
71
72 static av_cold int h261_decode_init(AVCodecContext *avctx)
73 {
74     H261Context *h          = avctx->priv_data;
75     MpegEncContext *const s = &h->s;
76
77     // set defaults
78     ff_mpv_decode_init(s, avctx);
79
80     s->out_format  = FMT_H261;
81     s->low_delay   = 1;
82     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
83
84     h261_decode_init_vlc(h);
85
86     h->gob_start_code_skipped = 0;
87
88     return 0;
89 }
90
91 /**
92  * Decode the group of blocks header or slice header.
93  * @return <0 if an error occurred
94  */
95 static int h261_decode_gob_header(H261Context *h)
96 {
97     unsigned int val;
98     MpegEncContext *const s = &h->s;
99
100     if (!h->gob_start_code_skipped) {
101         /* Check for GOB Start Code */
102         val = show_bits(&s->gb, 15);
103         if (val)
104             return -1;
105
106         /* We have a GBSC */
107         skip_bits(&s->gb, 16);
108     }
109
110     h->gob_start_code_skipped = 0;
111
112     h->gob_number = get_bits(&s->gb, 4); /* GN */
113     s->qscale     = get_bits(&s->gb, 5); /* GQUANT */
114
115     /* Check if gob_number is valid */
116     if (s->mb_height == 18) { // CIF
117         if ((h->gob_number <= 0) || (h->gob_number > 12))
118             return -1;
119     } else { // QCIF
120         if ((h->gob_number != 1) && (h->gob_number != 3) &&
121             (h->gob_number != 5))
122             return -1;
123     }
124
125     /* GEI */
126     if (skip_1stop_8data_bits(&s->gb) < 0)
127         return AVERROR_INVALIDDATA;
128
129     if (s->qscale == 0) {
130         av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n");
131         if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
132             return -1;
133     }
134
135     /* For the first transmitted macroblock in a GOB, MBA is the absolute
136      * address. For subsequent macroblocks, MBA is the difference between
137      * the absolute addresses of the macroblock and the last transmitted
138      * macroblock. */
139     h->current_mba = 0;
140     h->mba_diff    = 0;
141
142     return 0;
143 }
144
145 /**
146  * Decode the group of blocks / video packet header.
147  * @return <0 if no resync found
148  */
149 static int h261_resync(H261Context *h)
150 {
151     MpegEncContext *const s = &h->s;
152     int left, ret;
153
154     if (h->gob_start_code_skipped) {
155         ret = h261_decode_gob_header(h);
156         if (ret >= 0)
157             return 0;
158     } else {
159         if (show_bits(&s->gb, 15) == 0) {
160             ret = h261_decode_gob_header(h);
161             if (ret >= 0)
162                 return 0;
163         }
164         // OK, it is not where it is supposed to be ...
165         s->gb = s->last_resync_gb;
166         align_get_bits(&s->gb);
167         left = get_bits_left(&s->gb);
168
169         for (; left > 15 + 1 + 4 + 5; left -= 8) {
170             if (show_bits(&s->gb, 15) == 0) {
171                 GetBitContext bak = s->gb;
172
173                 ret = h261_decode_gob_header(h);
174                 if (ret >= 0)
175                     return 0;
176
177                 s->gb = bak;
178             }
179             skip_bits(&s->gb, 8);
180         }
181     }
182
183     return -1;
184 }
185
186 /**
187  * Decode skipped macroblocks.
188  * @return 0
189  */
190 static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2)
191 {
192     MpegEncContext *const s = &h->s;
193     int i;
194
195     s->mb_intra = 0;
196
197     for (i = mba1; i < mba2; i++) {
198         int j, xy;
199
200         s->mb_x = ((h->gob_number - 1) % 2) * 11 + i % 11;
201         s->mb_y = ((h->gob_number - 1) / 2) * 3 + i / 11;
202         xy      = s->mb_x + s->mb_y * s->mb_stride;
203         ff_init_block_index(s);
204         ff_update_block_index(s);
205
206         for (j = 0; j < 6; j++)
207             s->block_last_index[j] = -1;
208
209         s->mv_dir                      = MV_DIR_FORWARD;
210         s->mv_type                     = MV_TYPE_16X16;
211         s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
212         s->mv[0][0][0]                 = 0;
213         s->mv[0][0][1]                 = 0;
214         s->mb_skipped                  = 1;
215         h->mtype                      &= ~MB_TYPE_H261_FIL;
216
217         if (s->current_picture.motion_val[0]) {
218             int b_stride = 2*s->mb_width + 1;
219             int b_xy     = 2 * s->mb_x + (2 * s->mb_y) * b_stride;
220             s->current_picture.motion_val[0][b_xy][0] = s->mv[0][0][0];
221             s->current_picture.motion_val[0][b_xy][1] = s->mv[0][0][1];
222         }
223
224         ff_mpv_reconstruct_mb(s, s->block);
225     }
226
227     return 0;
228 }
229
230 static const int mvmap[17] = {
231     0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
232 };
233
234 static int decode_mv_component(GetBitContext *gb, int v)
235 {
236     int mv_diff = get_vlc2(gb, h261_mv_vlc.table, H261_MV_VLC_BITS, 2);
237
238     /* check if mv_diff is valid */
239     if (mv_diff < 0)
240         return v;
241
242     mv_diff = mvmap[mv_diff];
243
244     if (mv_diff && !get_bits1(gb))
245         mv_diff = -mv_diff;
246
247     v += mv_diff;
248     if (v <= -16)
249         v += 32;
250     else if (v >= 16)
251         v -= 32;
252
253     return v;
254 }
255
256 /**
257  * Decode a macroblock.
258  * @return <0 if an error occurred
259  */
260 static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
261 {
262     MpegEncContext *const s = &h->s;
263     int level, i, j, run;
264     RLTable *rl = &ff_h261_rl_tcoeff;
265     const uint8_t *scan_table;
266
267     /* For the variable length encoding there are two code tables, one being
268      * used for the first transmitted LEVEL in INTER, INTER + MC and
269      * INTER + MC + FIL blocks, the second for all other LEVELs except the
270      * first one in INTRA blocks which is fixed length coded with 8 bits.
271      * NOTE: The two code tables only differ in one VLC so we handle that
272      * manually. */
273     scan_table = s->intra_scantable.permutated;
274     if (s->mb_intra) {
275         /* DC coef */
276         level = get_bits(&s->gb, 8);
277         // 0 (00000000b) and -128 (10000000b) are FORBIDDEN
278         if ((level & 0x7F) == 0) {
279             av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
280                    level, s->mb_x, s->mb_y);
281             return -1;
282         }
283         /* The code 1000 0000 is not used, the reconstruction level of 1024
284          * being coded as 1111 1111. */
285         if (level == 255)
286             level = 128;
287         block[0] = level;
288         i        = 1;
289     } else if (coded) {
290         // Run  Level   Code
291         // EOB          Not possible for first level when cbp is available (that's why the table is different)
292         // 0    1       1s
293         // *    *       0*
294         int check = show_bits(&s->gb, 2);
295         i = 0;
296         if (check & 0x2) {
297             skip_bits(&s->gb, 2);
298             block[0] = (check & 0x1) ? -1 : 1;
299             i        = 1;
300         }
301     } else {
302         i = 0;
303     }
304     if (!coded) {
305         s->block_last_index[n] = i - 1;
306         return 0;
307     }
308     {
309     OPEN_READER(re, &s->gb);
310     i--; // offset by -1 to allow direct indexing of scan_table
311     for (;;) {
312         UPDATE_CACHE(re, &s->gb);
313         GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TCOEFF_VLC_BITS, 2, 0);
314         if (run == 66) {
315             if (level) {
316                 CLOSE_READER(re, &s->gb);
317                 av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n",
318                        s->mb_x, s->mb_y);
319                 return -1;
320             }
321             /* escape */
322             /* The remaining combinations of (run, level) are encoded with a
323              * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
324              * level. */
325             run   = SHOW_UBITS(re, &s->gb, 6) + 1;
326             SKIP_CACHE(re, &s->gb, 6);
327             level = SHOW_SBITS(re, &s->gb, 8);
328             SKIP_COUNTER(re, &s->gb, 6 + 8);
329         } else if (level == 0) {
330             break;
331         } else {
332             if (SHOW_UBITS(re, &s->gb, 1))
333                 level = -level;
334             SKIP_COUNTER(re, &s->gb, 1);
335         }
336         i += run;
337         if (i >= 64) {
338             CLOSE_READER(re, &s->gb);
339             av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
340                    s->mb_x, s->mb_y);
341             return -1;
342         }
343         j        = scan_table[i];
344         block[j] = level;
345     }
346     CLOSE_READER(re, &s->gb);
347     }
348     s->block_last_index[n] = i;
349     return 0;
350 }
351
352 static int h261_decode_mb(H261Context *h)
353 {
354     MpegEncContext *const s = &h->s;
355     int i, cbp, xy;
356
357     cbp = 63;
358     // Read mba
359     do {
360         h->mba_diff = get_vlc2(&s->gb, h261_mba_vlc.table,
361                                H261_MBA_VLC_BITS, 2);
362
363         /* Check for slice end */
364         /* NOTE: GOB can be empty (no MB data) or exist only of MBA_stuffing */
365         if (h->mba_diff == MBA_STARTCODE) { // start code
366             h->gob_start_code_skipped = 1;
367             return SLICE_END;
368         }
369     } while (h->mba_diff == MBA_STUFFING); // stuffing
370
371     if (h->mba_diff < 0) {
372         if (get_bits_left(&s->gb) <= 7)
373             return SLICE_END;
374
375         av_log(s->avctx, AV_LOG_ERROR, "illegal mba at %d %d\n", s->mb_x, s->mb_y);
376         return SLICE_ERROR;
377     }
378
379     h->mba_diff    += 1;
380     h->current_mba += h->mba_diff;
381
382     if (h->current_mba > MBA_STUFFING)
383         return SLICE_ERROR;
384
385     s->mb_x = ((h->gob_number - 1) % 2) * 11 + ((h->current_mba - 1) % 11);
386     s->mb_y = ((h->gob_number - 1) / 2) * 3 + ((h->current_mba - 1) / 11);
387     xy      = s->mb_x + s->mb_y * s->mb_stride;
388     ff_init_block_index(s);
389     ff_update_block_index(s);
390
391     // Read mtype
392     h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
393     if (h->mtype < 0) {
394         av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n",
395                h->mtype);
396         return SLICE_ERROR;
397     }
398     av_assert0(h->mtype < FF_ARRAY_ELEMS(ff_h261_mtype_map));
399     h->mtype = ff_h261_mtype_map[h->mtype];
400
401     // Read mquant
402     if (IS_QUANT(h->mtype))
403         ff_set_qscale(s, get_bits(&s->gb, 5));
404
405     s->mb_intra = IS_INTRA4x4(h->mtype);
406
407     // Read mv
408     if (IS_16X16(h->mtype)) {
409         /* Motion vector data is included for all MC macroblocks. MVD is
410          * obtained from the macroblock vector by subtracting the vector
411          * of the preceding macroblock. For this calculation the vector
412          * of the preceding macroblock is regarded as zero in the
413          * following three situations:
414          * 1) evaluating MVD for macroblocks 1, 12 and 23;
415          * 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1;
416          * 3) MTYPE of the previous macroblock was not MC. */
417         if ((h->current_mba ==  1) || (h->current_mba == 12) ||
418             (h->current_mba == 23) || (h->mba_diff != 1)) {
419             h->current_mv_x = 0;
420             h->current_mv_y = 0;
421         }
422
423         h->current_mv_x = decode_mv_component(&s->gb, h->current_mv_x);
424         h->current_mv_y = decode_mv_component(&s->gb, h->current_mv_y);
425     } else {
426         h->current_mv_x = 0;
427         h->current_mv_y = 0;
428     }
429
430     // Read cbp
431     if (HAS_CBP(h->mtype))
432         cbp = get_vlc2(&s->gb, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 1) + 1;
433
434     if (s->mb_intra) {
435         s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
436         goto intra;
437     }
438
439     //set motion vectors
440     s->mv_dir                      = MV_DIR_FORWARD;
441     s->mv_type                     = MV_TYPE_16X16;
442     s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
443     s->mv[0][0][0]                 = h->current_mv_x * 2; // gets divided by 2 in motion compensation
444     s->mv[0][0][1]                 = h->current_mv_y * 2;
445
446     if (s->current_picture.motion_val[0]) {
447         int b_stride = 2*s->mb_width + 1;
448         int b_xy     = 2 * s->mb_x + (2 * s->mb_y) * b_stride;
449         s->current_picture.motion_val[0][b_xy][0] = s->mv[0][0][0];
450         s->current_picture.motion_val[0][b_xy][1] = s->mv[0][0][1];
451     }
452
453 intra:
454     /* decode each block */
455     if (s->mb_intra || HAS_CBP(h->mtype)) {
456         s->bdsp.clear_blocks(s->block[0]);
457         for (i = 0; i < 6; i++) {
458             if (h261_decode_block(h, s->block[i], i, cbp & 32) < 0)
459                 return SLICE_ERROR;
460             cbp += cbp;
461         }
462     } else {
463         for (i = 0; i < 6; i++)
464             s->block_last_index[i] = -1;
465     }
466
467     ff_mpv_reconstruct_mb(s, s->block);
468
469     return SLICE_OK;
470 }
471
472 /**
473  * Decode the H.261 picture header.
474  * @return <0 if no startcode found
475  */
476 static int h261_decode_picture_header(H261Context *h)
477 {
478     MpegEncContext *const s = &h->s;
479     int format, i;
480     uint32_t startcode = 0;
481
482     for (i = get_bits_left(&s->gb); i > 24; i -= 1) {
483         startcode = ((startcode << 1) | get_bits(&s->gb, 1)) & 0x000FFFFF;
484
485         if (startcode == 0x10)
486             break;
487     }
488
489     if (startcode != 0x10) {
490         av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
491         return -1;
492     }
493
494     /* temporal reference */
495     i = get_bits(&s->gb, 5); /* picture timestamp */
496     if (i < (s->picture_number & 31))
497         i += 32;
498     s->picture_number = (s->picture_number & ~31) + i;
499
500     s->avctx->framerate = (AVRational) { 30000, 1001 };
501
502     /* PTYPE starts here */
503     skip_bits1(&s->gb); /* split screen off */
504     skip_bits1(&s->gb); /* camera  off */
505     skip_bits1(&s->gb); /* freeze picture release off */
506
507     format = get_bits1(&s->gb);
508
509     // only 2 formats possible
510     if (format == 0) { // QCIF
511         s->width     = 176;
512         s->height    = 144;
513         s->mb_width  = 11;
514         s->mb_height = 9;
515     } else { // CIF
516         s->width     = 352;
517         s->height    = 288;
518         s->mb_width  = 22;
519         s->mb_height = 18;
520     }
521
522     s->mb_num = s->mb_width * s->mb_height;
523
524     skip_bits1(&s->gb); /* still image mode off */
525     skip_bits1(&s->gb); /* Reserved */
526
527     /* PEI */
528     if (skip_1stop_8data_bits(&s->gb) < 0)
529         return AVERROR_INVALIDDATA;
530
531     /* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first
532      * frame, the codec crashes if it does not contain all I-blocks
533      * (e.g. when a packet is lost). */
534     s->pict_type = AV_PICTURE_TYPE_P;
535
536     h->gob_number = 0;
537     return 0;
538 }
539
540 static int h261_decode_gob(H261Context *h)
541 {
542     MpegEncContext *const s = &h->s;
543
544     ff_set_qscale(s, s->qscale);
545
546     /* decode mb's */
547     while (h->current_mba <= MBA_STUFFING) {
548         int ret;
549         /* DCT & quantize */
550         ret = h261_decode_mb(h);
551         if (ret < 0) {
552             if (ret == SLICE_END) {
553                 h261_decode_mb_skipped(h, h->current_mba, 33);
554                 return 0;
555             }
556             av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n",
557                    s->mb_x + s->mb_y * s->mb_stride);
558             return -1;
559         }
560
561         h261_decode_mb_skipped(h,
562                                h->current_mba - h->mba_diff,
563                                h->current_mba - 1);
564     }
565
566     return -1;
567 }
568
569 /**
570  * returns the number of bytes consumed for building the current frame
571  */
572 static int get_consumed_bytes(MpegEncContext *s, int buf_size)
573 {
574     int pos = get_bits_count(&s->gb) >> 3;
575     if (pos == 0)
576         pos = 1;      // avoid infinite loops (i doubt that is needed but ...)
577     if (pos + 10 > buf_size)
578         pos = buf_size;               // oops ;)
579
580     return pos;
581 }
582
583 static int h261_decode_frame(AVCodecContext *avctx, void *data,
584                              int *got_frame, AVPacket *avpkt)
585 {
586     const uint8_t *buf = avpkt->data;
587     int buf_size       = avpkt->size;
588     H261Context *h     = avctx->priv_data;
589     MpegEncContext *s  = &h->s;
590     int ret;
591     AVFrame *pict = data;
592
593     ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
594     ff_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
595
596     h->gob_start_code_skipped = 0;
597
598 retry:
599     init_get_bits(&s->gb, buf, buf_size * 8);
600
601     if (!s->context_initialized)
602         // we need the IDCT permutation for reading a custom matrix
603         ff_mpv_idct_init(s);
604
605     ret = h261_decode_picture_header(h);
606
607     /* skip if the header was thrashed */
608     if (ret < 0) {
609         av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
610         return -1;
611     }
612
613     if (s->width != avctx->coded_width || s->height != avctx->coded_height) {
614         ParseContext pc = s->parse_context; // FIXME move this demuxing hack to libavformat
615         s->parse_context.buffer = 0;
616         ff_mpv_common_end(s);
617         s->parse_context = pc;
618     }
619
620     if (!s->context_initialized) {
621         if ((ret = ff_mpv_common_init(s)) < 0)
622             return ret;
623
624         ret = ff_set_dimensions(avctx, s->width, s->height);
625         if (ret < 0)
626             return ret;
627
628         goto retry;
629     }
630
631     // for skipping the frame
632     s->current_picture.f->pict_type = s->pict_type;
633     s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
634
635     if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
636         (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
637          avctx->skip_frame >= AVDISCARD_ALL)
638         return get_consumed_bytes(s, buf_size);
639
640     if (ff_mpv_frame_start(s, avctx) < 0)
641         return -1;
642
643     ff_mpeg_er_frame_start(s);
644
645     /* decode each macroblock */
646     s->mb_x = 0;
647     s->mb_y = 0;
648
649     while (h->gob_number < (s->mb_height == 18 ? 12 : 5)) {
650         if (h261_resync(h) < 0)
651             break;
652         h261_decode_gob(h);
653     }
654     ff_mpv_frame_end(s);
655
656     av_assert0(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
657     av_assert0(s->current_picture.f->pict_type == s->pict_type);
658
659     if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
660         return ret;
661     ff_print_debug_info(s, s->current_picture_ptr, pict);
662
663     *got_frame = 1;
664
665     return get_consumed_bytes(s, buf_size);
666 }
667
668 static av_cold int h261_decode_end(AVCodecContext *avctx)
669 {
670     H261Context *h    = avctx->priv_data;
671     MpegEncContext *s = &h->s;
672
673     ff_mpv_common_end(s);
674     return 0;
675 }
676
677 AVCodec ff_h261_decoder = {
678     .name           = "h261",
679     .long_name      = NULL_IF_CONFIG_SMALL("H.261"),
680     .type           = AVMEDIA_TYPE_VIDEO,
681     .id             = AV_CODEC_ID_H261,
682     .priv_data_size = sizeof(H261Context),
683     .init           = h261_decode_init,
684     .close          = h261_decode_end,
685     .decode         = h261_decode_frame,
686     .capabilities   = AV_CODEC_CAP_DR1,
687     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
688     .max_lowres     = 3,
689 };