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.

673 lines
19KB

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