You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

671 lines
19KB

  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 Libav.
  7. *
  8. * Libav 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. * Libav 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 Libav; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. /**
  23. * @file
  24. * H.261 decoder.
  25. */
  26. #include "avcodec.h"
  27. #include "bitstream.h"
  28. #include "mpeg_er.h"
  29. #include "mpegutils.h"
  30. #include "mpegvideo.h"
  31. #include "h263.h"
  32. #include "h261.h"
  33. #include "internal.h"
  34. #include "vlc.h"
  35. #define H261_MBA_VLC_BITS 9
  36. #define H261_MTYPE_VLC_BITS 6
  37. #define H261_MV_VLC_BITS 7
  38. #define H261_CBP_VLC_BITS 9
  39. #define TCOEFF_VLC_BITS 9
  40. #define MBA_STUFFING 33
  41. #define MBA_STARTCODE 34
  42. static VLC h261_mba_vlc;
  43. static VLC h261_mtype_vlc;
  44. static VLC h261_mv_vlc;
  45. static VLC h261_cbp_vlc;
  46. static av_cold void h261_decode_init_vlc(H261Context *h)
  47. {
  48. static int done = 0;
  49. if (!done) {
  50. done = 1;
  51. INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
  52. ff_h261_mba_bits, 1, 1,
  53. ff_h261_mba_code, 1, 1, 662);
  54. INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
  55. ff_h261_mtype_bits, 1, 1,
  56. ff_h261_mtype_code, 1, 1, 80);
  57. INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
  58. &ff_h261_mv_tab[0][1], 2, 1,
  59. &ff_h261_mv_tab[0][0], 2, 1, 144);
  60. INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
  61. &ff_h261_cbp_tab[0][1], 2, 1,
  62. &ff_h261_cbp_tab[0][0], 2, 1, 512);
  63. INIT_VLC_RL(ff_h261_rl_tcoeff, 552);
  64. }
  65. }
  66. static av_cold int h261_decode_init(AVCodecContext *avctx)
  67. {
  68. H261Context *h = avctx->priv_data;
  69. MpegEncContext *const s = &h->s;
  70. // set defaults
  71. ff_mpv_decode_defaults(s);
  72. s->avctx = avctx;
  73. s->width = s->avctx->coded_width;
  74. s->height = s->avctx->coded_height;
  75. s->codec_id = s->avctx->codec->id;
  76. s->out_format = FMT_H261;
  77. s->low_delay = 1;
  78. avctx->pix_fmt = AV_PIX_FMT_YUV420P;
  79. s->codec_id = avctx->codec->id;
  80. ff_h261_common_init();
  81. h261_decode_init_vlc(h);
  82. h->gob_start_code_skipped = 0;
  83. return 0;
  84. }
  85. /**
  86. * Decode the group of blocks header or slice header.
  87. * @return <0 if an error occurred
  88. */
  89. static int h261_decode_gob_header(H261Context *h)
  90. {
  91. unsigned int val;
  92. MpegEncContext *const s = &h->s;
  93. if (!h->gob_start_code_skipped) {
  94. /* Check for GOB Start Code */
  95. val = bitstream_peek(&s->bc, 15);
  96. if (val)
  97. return -1;
  98. /* We have a GBSC */
  99. bitstream_skip(&s->bc, 16);
  100. }
  101. h->gob_start_code_skipped = 0;
  102. h->gob_number = bitstream_read(&s->bc, 4); /* GN */
  103. s->qscale = bitstream_read(&s->bc, 5); /* GQUANT */
  104. /* Check if gob_number is valid */
  105. if (s->mb_height == 18) { // CIF
  106. if ((h->gob_number <= 0) || (h->gob_number > 12))
  107. return -1;
  108. } else { // QCIF
  109. if ((h->gob_number != 1) && (h->gob_number != 3) &&
  110. (h->gob_number != 5))
  111. return -1;
  112. }
  113. /* GEI */
  114. while (bitstream_read_bit(&s->bc) != 0)
  115. bitstream_skip(&s->bc, 8);
  116. if (s->qscale == 0) {
  117. av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n");
  118. if (s->avctx->err_recognition & AV_EF_BITSTREAM)
  119. return -1;
  120. }
  121. /* For the first transmitted macroblock in a GOB, MBA is the absolute
  122. * address. For subsequent macroblocks, MBA is the difference between
  123. * the absolute addresses of the macroblock and the last transmitted
  124. * macroblock. */
  125. h->current_mba = 0;
  126. h->mba_diff = 0;
  127. return 0;
  128. }
  129. /**
  130. * Decode the group of blocks / video packet header.
  131. * @return <0 if no resync found
  132. */
  133. static int h261_resync(H261Context *h)
  134. {
  135. MpegEncContext *const s = &h->s;
  136. int left, ret;
  137. if (h->gob_start_code_skipped) {
  138. ret = h261_decode_gob_header(h);
  139. if (ret >= 0)
  140. return 0;
  141. } else {
  142. if (bitstream_peek(&s->bc, 15) == 0) {
  143. ret = h261_decode_gob_header(h);
  144. if (ret >= 0)
  145. return 0;
  146. }
  147. // OK, it is not where it is supposed to be ...
  148. s->bc = s->last_resync_bc;
  149. bitstream_align(&s->bc);
  150. left = bitstream_bits_left(&s->bc);
  151. for (; left > 15 + 1 + 4 + 5; left -= 8) {
  152. if (bitstream_peek(&s->bc, 15) == 0) {
  153. BitstreamContext bak = s->bc;
  154. ret = h261_decode_gob_header(h);
  155. if (ret >= 0)
  156. return 0;
  157. s->bc = bak;
  158. }
  159. bitstream_skip(&s->bc, 8);
  160. }
  161. }
  162. return -1;
  163. }
  164. /**
  165. * Decode skipped macroblocks.
  166. * @return 0
  167. */
  168. static int h261_decode_mb_skipped(H261Context *h, int mba1, int mba2)
  169. {
  170. MpegEncContext *const s = &h->s;
  171. int i;
  172. s->mb_intra = 0;
  173. for (i = mba1; i < mba2; i++) {
  174. int j, xy;
  175. s->mb_x = ((h->gob_number - 1) % 2) * 11 + i % 11;
  176. s->mb_y = ((h->gob_number - 1) / 2) * 3 + i / 11;
  177. xy = s->mb_x + s->mb_y * s->mb_stride;
  178. ff_init_block_index(s);
  179. ff_update_block_index(s);
  180. for (j = 0; j < 6; j++)
  181. s->block_last_index[j] = -1;
  182. s->mv_dir = MV_DIR_FORWARD;
  183. s->mv_type = MV_TYPE_16X16;
  184. s->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
  185. s->mv[0][0][0] = 0;
  186. s->mv[0][0][1] = 0;
  187. s->mb_skipped = 1;
  188. h->mtype &= ~MB_TYPE_H261_FIL;
  189. ff_mpv_decode_mb(s, s->block);
  190. }
  191. return 0;
  192. }
  193. static const int mvmap[17] = {
  194. 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16
  195. };
  196. static int decode_mv_component(BitstreamContext *bc, int v)
  197. {
  198. int mv_diff = bitstream_read_vlc(bc, h261_mv_vlc.table, H261_MV_VLC_BITS, 2);
  199. /* check if mv_diff is valid */
  200. if (mv_diff < 0)
  201. return v;
  202. mv_diff = mvmap[mv_diff];
  203. if (mv_diff && !bitstream_read_bit(bc))
  204. mv_diff = -mv_diff;
  205. v += mv_diff;
  206. if (v <= -16)
  207. v += 32;
  208. else if (v >= 16)
  209. v -= 32;
  210. return v;
  211. }
  212. /**
  213. * Decode a macroblock.
  214. * @return <0 if an error occurred
  215. */
  216. static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
  217. {
  218. MpegEncContext *const s = &h->s;
  219. int code, level, i, j, run;
  220. RLTable *rl = &ff_h261_rl_tcoeff;
  221. const uint8_t *scan_table;
  222. /* For the variable length encoding there are two code tables, one being
  223. * used for the first transmitted LEVEL in INTER, INTER + MC and
  224. * INTER + MC + FIL blocks, the second for all other LEVELs except the
  225. * first one in INTRA blocks which is fixed length coded with 8 bits.
  226. * NOTE: The two code tables only differ in one VLC so we handle that
  227. * manually. */
  228. scan_table = s->intra_scantable.permutated;
  229. if (s->mb_intra) {
  230. /* DC coef */
  231. level = bitstream_read(&s->bc, 8);
  232. // 0 (00000000b) and -128 (10000000b) are FORBIDDEN
  233. if ((level & 0x7F) == 0) {
  234. av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
  235. level, s->mb_x, s->mb_y);
  236. return -1;
  237. }
  238. /* The code 1000 0000 is not used, the reconstruction level of 1024
  239. * being coded as 1111 1111. */
  240. if (level == 255)
  241. level = 128;
  242. block[0] = level;
  243. i = 1;
  244. } else if (coded) {
  245. // Run Level Code
  246. // EOB Not possible for first level when cbp is available (that's why the table is different)
  247. // 0 1 1s
  248. // * * 0*
  249. int check = bitstream_peek(&s->bc, 2);
  250. i = 0;
  251. if (check & 0x2) {
  252. bitstream_skip(&s->bc, 2);
  253. block[0] = (check & 0x1) ? -1 : 1;
  254. i = 1;
  255. }
  256. } else {
  257. i = 0;
  258. }
  259. if (!coded) {
  260. s->block_last_index[n] = i - 1;
  261. return 0;
  262. }
  263. for (;;) {
  264. code = bitstream_read_vlc(&s->bc, rl->vlc.table, TCOEFF_VLC_BITS, 2);
  265. if (code < 0) {
  266. av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n",
  267. s->mb_x, s->mb_y);
  268. return -1;
  269. }
  270. if (code == rl->n) {
  271. /* escape */
  272. /* The remaining combinations of (run, level) are encoded with a
  273. * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
  274. * level. */
  275. run = bitstream_read(&s->bc, 6);
  276. level = bitstream_read_signed(&s->bc, 8);
  277. } else if (code == 0) {
  278. break;
  279. } else {
  280. run = rl->table_run[code];
  281. level = rl->table_level[code];
  282. if (bitstream_read_bit(&s->bc))
  283. level = -level;
  284. }
  285. i += run;
  286. if (i >= 64) {
  287. av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
  288. s->mb_x, s->mb_y);
  289. return -1;
  290. }
  291. j = scan_table[i];
  292. block[j] = level;
  293. i++;
  294. }
  295. s->block_last_index[n] = i - 1;
  296. return 0;
  297. }
  298. static int h261_decode_mb(H261Context *h)
  299. {
  300. MpegEncContext *const s = &h->s;
  301. int i, cbp, xy;
  302. cbp = 63;
  303. // Read mba
  304. do {
  305. h->mba_diff = bitstream_read_vlc(&s->bc, h261_mba_vlc.table,
  306. H261_MBA_VLC_BITS, 2);
  307. /* Check for slice end */
  308. /* NOTE: GOB can be empty (no MB data) or exist only of MBA_stuffing */
  309. if (h->mba_diff == MBA_STARTCODE) { // start code
  310. h->gob_start_code_skipped = 1;
  311. return SLICE_END;
  312. }
  313. } while (h->mba_diff == MBA_STUFFING); // stuffing
  314. if (h->mba_diff < 0) {
  315. if (bitstream_bits_left(&s->bc) <= 7)
  316. return SLICE_END;
  317. av_log(s->avctx, AV_LOG_ERROR, "illegal mba at %d %d\n", s->mb_x, s->mb_y);
  318. return SLICE_ERROR;
  319. }
  320. h->mba_diff += 1;
  321. h->current_mba += h->mba_diff;
  322. if (h->current_mba > MBA_STUFFING)
  323. return SLICE_ERROR;
  324. s->mb_x = ((h->gob_number - 1) % 2) * 11 + ((h->current_mba - 1) % 11);
  325. s->mb_y = ((h->gob_number - 1) / 2) * 3 + ((h->current_mba - 1) / 11);
  326. xy = s->mb_x + s->mb_y * s->mb_stride;
  327. ff_init_block_index(s);
  328. ff_update_block_index(s);
  329. // Read mtype
  330. h->mtype = bitstream_read_vlc(&s->bc, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
  331. if (h->mtype < 0 || h->mtype >= FF_ARRAY_ELEMS(ff_h261_mtype_map)) {
  332. av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n",
  333. h->mtype);
  334. return SLICE_ERROR;
  335. }
  336. h->mtype = ff_h261_mtype_map[h->mtype];
  337. // Read mquant
  338. if (IS_QUANT(h->mtype))
  339. ff_set_qscale(s, bitstream_read(&s->bc, 5));
  340. s->mb_intra = IS_INTRA4x4(h->mtype);
  341. // Read mv
  342. if (IS_16X16(h->mtype)) {
  343. /* Motion vector data is included for all MC macroblocks. MVD is
  344. * obtained from the macroblock vector by subtracting the vector
  345. * of the preceding macroblock. For this calculation the vector
  346. * of the preceding macroblock is regarded as zero in the
  347. * following three situations:
  348. * 1) evaluating MVD for macroblocks 1, 12 and 23;
  349. * 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1;
  350. * 3) MTYPE of the previous macroblock was not MC. */
  351. if ((h->current_mba == 1) || (h->current_mba == 12) ||
  352. (h->current_mba == 23) || (h->mba_diff != 1)) {
  353. h->current_mv_x = 0;
  354. h->current_mv_y = 0;
  355. }
  356. h->current_mv_x = decode_mv_component(&s->bc, h->current_mv_x);
  357. h->current_mv_y = decode_mv_component(&s->bc, h->current_mv_y);
  358. } else {
  359. h->current_mv_x = 0;
  360. h->current_mv_y = 0;
  361. }
  362. // Read cbp
  363. if (HAS_CBP(h->mtype))
  364. cbp = bitstream_read_vlc(&s->bc, h261_cbp_vlc.table, H261_CBP_VLC_BITS, 2) + 1;
  365. if (s->mb_intra) {
  366. s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
  367. goto intra;
  368. }
  369. //set motion vectors
  370. s->mv_dir = MV_DIR_FORWARD;
  371. s->mv_type = MV_TYPE_16X16;
  372. s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
  373. s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation
  374. s->mv[0][0][1] = h->current_mv_y * 2;
  375. intra:
  376. /* decode each block */
  377. if (s->mb_intra || HAS_CBP(h->mtype)) {
  378. s->bdsp.clear_blocks(s->block[0]);
  379. for (i = 0; i < 6; i++) {
  380. if (h261_decode_block(h, s->block[i], i, cbp & 32) < 0)
  381. return SLICE_ERROR;
  382. cbp += cbp;
  383. }
  384. } else {
  385. for (i = 0; i < 6; i++)
  386. s->block_last_index[i] = -1;
  387. }
  388. ff_mpv_decode_mb(s, s->block);
  389. return SLICE_OK;
  390. }
  391. /**
  392. * Decode the H.261 picture header.
  393. * @return <0 if no startcode found
  394. */
  395. static int h261_decode_picture_header(H261Context *h)
  396. {
  397. MpegEncContext *const s = &h->s;
  398. int format, i;
  399. uint32_t startcode = 0;
  400. for (i = bitstream_bits_left(&s->bc); i > 24; i -= 1) {
  401. startcode = ((startcode << 1) | bitstream_read(&s->bc, 1)) & 0x000FFFFF;
  402. if (startcode == 0x10)
  403. break;
  404. }
  405. if (startcode != 0x10) {
  406. av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
  407. return -1;
  408. }
  409. /* temporal reference */
  410. i = bitstream_read(&s->bc, 5); /* picture timestamp */
  411. if (i < (s->picture_number & 31))
  412. i += 32;
  413. s->picture_number = (s->picture_number & ~31) + i;
  414. s->avctx->framerate = (AVRational) { 30000, 1001 };
  415. /* PTYPE starts here */
  416. bitstream_skip(&s->bc, 1); /* split screen off */
  417. bitstream_skip(&s->bc, 1); /* camera off */
  418. bitstream_skip(&s->bc, 1); /* freeze picture release off */
  419. format = bitstream_read_bit(&s->bc);
  420. // only 2 formats possible
  421. if (format == 0) { // QCIF
  422. s->width = 176;
  423. s->height = 144;
  424. s->mb_width = 11;
  425. s->mb_height = 9;
  426. } else { // CIF
  427. s->width = 352;
  428. s->height = 288;
  429. s->mb_width = 22;
  430. s->mb_height = 18;
  431. }
  432. s->mb_num = s->mb_width * s->mb_height;
  433. bitstream_skip(&s->bc, 1); /* still image mode off */
  434. bitstream_skip(&s->bc, 1); /* Reserved */
  435. /* PEI */
  436. while (bitstream_read_bit(&s->bc) != 0)
  437. bitstream_skip(&s->bc, 8);
  438. /* H.261 has no I-frames, but if we pass AV_PICTURE_TYPE_I for the first
  439. * frame, the codec crashes if it does not contain all I-blocks
  440. * (e.g. when a packet is lost). */
  441. s->pict_type = AV_PICTURE_TYPE_P;
  442. h->gob_number = 0;
  443. return 0;
  444. }
  445. static int h261_decode_gob(H261Context *h)
  446. {
  447. MpegEncContext *const s = &h->s;
  448. ff_set_qscale(s, s->qscale);
  449. /* decode mb's */
  450. while (h->current_mba <= MBA_STUFFING) {
  451. int ret;
  452. /* DCT & quantize */
  453. ret = h261_decode_mb(h);
  454. if (ret < 0) {
  455. if (ret == SLICE_END) {
  456. h261_decode_mb_skipped(h, h->current_mba, 33);
  457. return 0;
  458. }
  459. av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n",
  460. s->mb_x + s->mb_y * s->mb_stride);
  461. return -1;
  462. }
  463. h261_decode_mb_skipped(h,
  464. h->current_mba - h->mba_diff,
  465. h->current_mba - 1);
  466. }
  467. return -1;
  468. }
  469. /**
  470. * returns the number of bytes consumed for building the current frame
  471. */
  472. static int get_consumed_bytes(MpegEncContext *s, int buf_size)
  473. {
  474. int pos = bitstream_tell(&s->bc) >> 3;
  475. if (pos == 0)
  476. pos = 1; // avoid infinite loops (i doubt that is needed but ...)
  477. if (pos + 10 > buf_size)
  478. pos = buf_size; // oops ;)
  479. return pos;
  480. }
  481. static int h261_decode_frame(AVCodecContext *avctx, void *data,
  482. int *got_frame, AVPacket *avpkt)
  483. {
  484. const uint8_t *buf = avpkt->data;
  485. int buf_size = avpkt->size;
  486. H261Context *h = avctx->priv_data;
  487. MpegEncContext *s = &h->s;
  488. int ret;
  489. AVFrame *pict = data;
  490. ff_dlog(avctx, "*****frame %d size=%d\n", avctx->frame_number, buf_size);
  491. ff_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
  492. h->gob_start_code_skipped = 0;
  493. retry:
  494. bitstream_init8(&s->bc, buf, buf_size);
  495. if (!s->context_initialized)
  496. // we need the IDCT permutation for reading a custom matrix
  497. ff_mpv_idct_init(s);
  498. ret = h261_decode_picture_header(h);
  499. /* skip if the header was thrashed */
  500. if (ret < 0) {
  501. av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
  502. return -1;
  503. }
  504. if (s->width != avctx->coded_width || s->height != avctx->coded_height) {
  505. ParseContext pc = s->parse_context; // FIXME move this demuxing hack to libavformat
  506. s->parse_context.buffer = 0;
  507. ff_mpv_common_end(s);
  508. s->parse_context = pc;
  509. }
  510. if (!s->context_initialized) {
  511. if ((ret = ff_mpv_common_init(s)) < 0)
  512. return ret;
  513. ret = ff_set_dimensions(avctx, s->width, s->height);
  514. if (ret < 0)
  515. return ret;
  516. goto retry;
  517. }
  518. // for skipping the frame
  519. s->current_picture.f->pict_type = s->pict_type;
  520. s->current_picture.f->key_frame = s->pict_type == AV_PICTURE_TYPE_I;
  521. if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) ||
  522. (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) ||
  523. avctx->skip_frame >= AVDISCARD_ALL)
  524. return get_consumed_bytes(s, buf_size);
  525. if (ff_mpv_frame_start(s, avctx) < 0)
  526. return -1;
  527. ff_mpeg_er_frame_start(s);
  528. /* decode each macroblock */
  529. s->mb_x = 0;
  530. s->mb_y = 0;
  531. while (h->gob_number < (s->mb_height == 18 ? 12 : 5)) {
  532. if (h261_resync(h) < 0)
  533. break;
  534. h261_decode_gob(h);
  535. }
  536. ff_mpv_frame_end(s);
  537. assert(s->current_picture.f->pict_type == s->current_picture_ptr->f->pict_type);
  538. assert(s->current_picture.f->pict_type == s->pict_type);
  539. if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0)
  540. return ret;
  541. ff_print_debug_info(s, s->current_picture_ptr);
  542. *got_frame = 1;
  543. return get_consumed_bytes(s, buf_size);
  544. }
  545. static av_cold int h261_decode_end(AVCodecContext *avctx)
  546. {
  547. H261Context *h = avctx->priv_data;
  548. MpegEncContext *s = &h->s;
  549. ff_mpv_common_end(s);
  550. return 0;
  551. }
  552. AVCodec ff_h261_decoder = {
  553. .name = "h261",
  554. .long_name = NULL_IF_CONFIG_SMALL("H.261"),
  555. .type = AVMEDIA_TYPE_VIDEO,
  556. .id = AV_CODEC_ID_H261,
  557. .priv_data_size = sizeof(H261Context),
  558. .init = h261_decode_init,
  559. .close = h261_decode_end,
  560. .decode = h261_decode_frame,
  561. .capabilities = AV_CODEC_CAP_DR1,
  562. };