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.

646 lines
21KB

  1. /*
  2. * Indeo Video Interactive v5 compatible decoder
  3. * Copyright (c) 2009 Maxim Poliakovski
  4. *
  5. * This file is part of Libav.
  6. *
  7. * Libav is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * Libav is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with Libav; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file
  23. * Indeo Video Interactive version 5 decoder
  24. *
  25. * Indeo5 data is usually transported within .avi or .mov files.
  26. * Known FOURCCs: 'IV50'
  27. */
  28. #define BITSTREAM_READER_LE
  29. #include "avcodec.h"
  30. #include "get_bits.h"
  31. #include "dsputil.h"
  32. #include "ivi_dsp.h"
  33. #include "ivi_common.h"
  34. #include "indeo5data.h"
  35. /**
  36. * Indeo5 frame types.
  37. */
  38. enum {
  39. FRAMETYPE_INTRA = 0,
  40. FRAMETYPE_INTER = 1, ///< non-droppable P-frame
  41. FRAMETYPE_INTER_SCAL = 2, ///< droppable P-frame used in the scalability mode
  42. FRAMETYPE_INTER_NOREF = 3, ///< droppable P-frame
  43. FRAMETYPE_NULL = 4 ///< empty frame with no data
  44. };
  45. #define IVI5_PIC_SIZE_ESC 15
  46. /**
  47. * Decode Indeo5 GOP (Group of pictures) header.
  48. * This header is present in key frames only.
  49. * It defines parameters for all frames in a GOP.
  50. *
  51. * @param[in,out] ctx ptr to the decoder context
  52. * @param[in] avctx ptr to the AVCodecContext
  53. * @return result code: 0 = OK, -1 = error
  54. */
  55. static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
  56. {
  57. int result, i, p, tile_size, pic_size_indx, mb_size, blk_size;
  58. int quant_mat, blk_size_changed = 0;
  59. IVIBandDesc *band, *band1, *band2;
  60. IVIPicConfig pic_conf;
  61. ctx->gop_flags = get_bits(&ctx->gb, 8);
  62. ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
  63. if (ctx->gop_flags & IVI5_IS_PROTECTED)
  64. ctx->lock_word = get_bits_long(&ctx->gb, 32);
  65. tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
  66. if (tile_size > 256) {
  67. av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size);
  68. return -1;
  69. }
  70. /* decode number of wavelet bands */
  71. /* num_levels * 3 + 1 */
  72. pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1;
  73. pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1;
  74. ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1;
  75. if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) {
  76. av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n",
  77. pic_conf.luma_bands, pic_conf.chroma_bands);
  78. return -1;
  79. }
  80. pic_size_indx = get_bits(&ctx->gb, 4);
  81. if (pic_size_indx == IVI5_PIC_SIZE_ESC) {
  82. pic_conf.pic_height = get_bits(&ctx->gb, 13);
  83. pic_conf.pic_width = get_bits(&ctx->gb, 13);
  84. } else {
  85. pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2;
  86. pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2;
  87. }
  88. if (ctx->gop_flags & 2) {
  89. av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n");
  90. return -1;
  91. }
  92. pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2;
  93. pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2;
  94. if (!tile_size) {
  95. pic_conf.tile_height = pic_conf.pic_height;
  96. pic_conf.tile_width = pic_conf.pic_width;
  97. } else {
  98. pic_conf.tile_height = pic_conf.tile_width = tile_size;
  99. }
  100. /* check if picture layout was changed and reallocate buffers */
  101. if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) {
  102. result = ff_ivi_init_planes(ctx->planes, &pic_conf);
  103. if (result) {
  104. av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n");
  105. return -1;
  106. }
  107. ctx->pic_conf = pic_conf;
  108. blk_size_changed = 1; /* force reallocation of the internal structures */
  109. }
  110. for (p = 0; p <= 1; p++) {
  111. for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) {
  112. band = &ctx->planes[p].bands[i];
  113. band->is_halfpel = get_bits1(&ctx->gb);
  114. mb_size = get_bits1(&ctx->gb);
  115. blk_size = 8 >> get_bits1(&ctx->gb);
  116. mb_size = blk_size << !mb_size;
  117. blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size;
  118. if (blk_size_changed) {
  119. band->mb_size = mb_size;
  120. band->blk_size = blk_size;
  121. }
  122. if (get_bits1(&ctx->gb)) {
  123. av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n");
  124. return -1;
  125. }
  126. /* select transform function and scan pattern according to plane and band number */
  127. switch ((p << 2) + i) {
  128. case 0:
  129. band->inv_transform = ff_ivi_inverse_slant_8x8;
  130. band->dc_transform = ff_ivi_dc_slant_2d;
  131. band->scan = ff_zigzag_direct;
  132. break;
  133. case 1:
  134. band->inv_transform = ff_ivi_row_slant8;
  135. band->dc_transform = ff_ivi_dc_row_slant;
  136. band->scan = ff_ivi_vertical_scan_8x8;
  137. break;
  138. case 2:
  139. band->inv_transform = ff_ivi_col_slant8;
  140. band->dc_transform = ff_ivi_dc_col_slant;
  141. band->scan = ff_ivi_horizontal_scan_8x8;
  142. break;
  143. case 3:
  144. band->inv_transform = ff_ivi_put_pixels_8x8;
  145. band->dc_transform = ff_ivi_put_dc_pixel_8x8;
  146. band->scan = ff_ivi_horizontal_scan_8x8;
  147. break;
  148. case 4:
  149. band->inv_transform = ff_ivi_inverse_slant_4x4;
  150. band->dc_transform = ff_ivi_dc_slant_2d;
  151. band->scan = ff_ivi_direct_scan_4x4;
  152. break;
  153. }
  154. band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 ||
  155. band->inv_transform == ff_ivi_inverse_slant_4x4;
  156. /* select dequant matrix according to plane and band number */
  157. if (!p) {
  158. quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0;
  159. } else {
  160. quant_mat = 5;
  161. }
  162. if (band->blk_size == 8) {
  163. band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0];
  164. band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0];
  165. band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0];
  166. band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0];
  167. } else {
  168. band->intra_base = ivi5_base_quant_4x4_intra;
  169. band->inter_base = ivi5_base_quant_4x4_inter;
  170. band->intra_scale = ivi5_scale_quant_4x4_intra;
  171. band->inter_scale = ivi5_scale_quant_4x4_inter;
  172. }
  173. if (get_bits(&ctx->gb, 2)) {
  174. av_log(avctx, AV_LOG_ERROR, "End marker missing!\n");
  175. return -1;
  176. }
  177. }
  178. }
  179. /* copy chroma parameters into the 2nd chroma plane */
  180. for (i = 0; i < pic_conf.chroma_bands; i++) {
  181. band1 = &ctx->planes[1].bands[i];
  182. band2 = &ctx->planes[2].bands[i];
  183. band2->width = band1->width;
  184. band2->height = band1->height;
  185. band2->mb_size = band1->mb_size;
  186. band2->blk_size = band1->blk_size;
  187. band2->is_halfpel = band1->is_halfpel;
  188. band2->intra_base = band1->intra_base;
  189. band2->inter_base = band1->inter_base;
  190. band2->intra_scale = band1->intra_scale;
  191. band2->inter_scale = band1->inter_scale;
  192. band2->scan = band1->scan;
  193. band2->inv_transform = band1->inv_transform;
  194. band2->dc_transform = band1->dc_transform;
  195. band2->is_2d_trans = band1->is_2d_trans;
  196. }
  197. /* reallocate internal structures if needed */
  198. if (blk_size_changed) {
  199. result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
  200. pic_conf.tile_height);
  201. if (result) {
  202. av_log(avctx, AV_LOG_ERROR,
  203. "Couldn't reallocate internal structures!\n");
  204. return -1;
  205. }
  206. }
  207. if (ctx->gop_flags & 8) {
  208. if (get_bits(&ctx->gb, 3)) {
  209. av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n");
  210. return -1;
  211. }
  212. if (get_bits1(&ctx->gb))
  213. skip_bits_long(&ctx->gb, 24); /* skip transparency fill color */
  214. }
  215. align_get_bits(&ctx->gb);
  216. skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
  217. /* skip GOP extension if any */
  218. if (get_bits1(&ctx->gb)) {
  219. do {
  220. i = get_bits(&ctx->gb, 16);
  221. } while (i & 0x8000);
  222. }
  223. align_get_bits(&ctx->gb);
  224. return 0;
  225. }
  226. /**
  227. * Skip a header extension.
  228. *
  229. * @param[in,out] gb the GetBit context
  230. */
  231. static inline void skip_hdr_extension(GetBitContext *gb)
  232. {
  233. int i, len;
  234. do {
  235. len = get_bits(gb, 8);
  236. for (i = 0; i < len; i++) skip_bits(gb, 8);
  237. } while(len);
  238. }
  239. /**
  240. * Decode Indeo5 picture header.
  241. *
  242. * @param[in,out] ctx ptr to the decoder context
  243. * @param[in] avctx ptr to the AVCodecContext
  244. * @return result code: 0 = OK, -1 = error
  245. */
  246. static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
  247. {
  248. if (get_bits(&ctx->gb, 5) != 0x1F) {
  249. av_log(avctx, AV_LOG_ERROR, "Invalid picture start code!\n");
  250. return -1;
  251. }
  252. ctx->prev_frame_type = ctx->frame_type;
  253. ctx->frame_type = get_bits(&ctx->gb, 3);
  254. if (ctx->frame_type >= 5) {
  255. av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
  256. return -1;
  257. }
  258. ctx->frame_num = get_bits(&ctx->gb, 8);
  259. if (ctx->frame_type == FRAMETYPE_INTRA) {
  260. ctx->gop_invalid = 1;
  261. if (decode_gop_header(ctx, avctx)) {
  262. av_log(avctx, AV_LOG_ERROR, "Invalid GOP header, skipping frames.\n");
  263. return AVERROR_INVALIDDATA;
  264. }
  265. ctx->gop_invalid = 0;
  266. }
  267. if (ctx->frame_type != FRAMETYPE_NULL) {
  268. ctx->frame_flags = get_bits(&ctx->gb, 8);
  269. ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits_long(&ctx->gb, 24) : 0;
  270. ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
  271. /* skip unknown extension if any */
  272. if (ctx->frame_flags & 0x20)
  273. skip_hdr_extension(&ctx->gb); /* XXX: untested */
  274. /* decode macroblock huffman codebook */
  275. if (ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40, IVI_MB_HUFF, &ctx->mb_vlc, avctx))
  276. return -1;
  277. skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
  278. }
  279. align_get_bits(&ctx->gb);
  280. return 0;
  281. }
  282. /**
  283. * Decode Indeo5 band header.
  284. *
  285. * @param[in,out] ctx ptr to the decoder context
  286. * @param[in,out] band ptr to the band descriptor
  287. * @param[in] avctx ptr to the AVCodecContext
  288. * @return result code: 0 = OK, -1 = error
  289. */
  290. static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
  291. AVCodecContext *avctx)
  292. {
  293. int i;
  294. uint8_t band_flags;
  295. band_flags = get_bits(&ctx->gb, 8);
  296. if (band_flags & 1) {
  297. band->is_empty = 1;
  298. return 0;
  299. }
  300. band->data_size = (ctx->frame_flags & 0x80) ? get_bits_long(&ctx->gb, 24) : 0;
  301. band->inherit_mv = band_flags & 2;
  302. band->inherit_qdelta = band_flags & 8;
  303. band->qdelta_present = band_flags & 4;
  304. if (!band->qdelta_present) band->inherit_qdelta = 1;
  305. /* decode rvmap probability corrections if any */
  306. band->num_corr = 0; /* there are no corrections */
  307. if (band_flags & 0x10) {
  308. band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
  309. if (band->num_corr > 61) {
  310. av_log(avctx, AV_LOG_ERROR, "Too many corrections: %d\n",
  311. band->num_corr);
  312. return -1;
  313. }
  314. /* read correction pairs */
  315. for (i = 0; i < band->num_corr * 2; i++)
  316. band->corr[i] = get_bits(&ctx->gb, 8);
  317. }
  318. /* select appropriate rvmap table for this band */
  319. band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
  320. /* decode block huffman codebook */
  321. if (ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF, &band->blk_vlc, avctx))
  322. return -1;
  323. band->checksum_present = get_bits1(&ctx->gb);
  324. if (band->checksum_present)
  325. band->checksum = get_bits(&ctx->gb, 16);
  326. band->glob_quant = get_bits(&ctx->gb, 5);
  327. /* skip unknown extension if any */
  328. if (band_flags & 0x20) { /* XXX: untested */
  329. align_get_bits(&ctx->gb);
  330. skip_hdr_extension(&ctx->gb);
  331. }
  332. align_get_bits(&ctx->gb);
  333. return 0;
  334. }
  335. /**
  336. * Decode info (block type, cbp, quant delta, motion vector)
  337. * for all macroblocks in the current tile.
  338. *
  339. * @param[in,out] ctx ptr to the decoder context
  340. * @param[in,out] band ptr to the band descriptor
  341. * @param[in,out] tile ptr to the tile descriptor
  342. * @param[in] avctx ptr to the AVCodecContext
  343. * @return result code: 0 = OK, -1 = error
  344. */
  345. static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
  346. IVITile *tile, AVCodecContext *avctx)
  347. {
  348. int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
  349. mv_scale, blks_per_mb;
  350. IVIMbInfo *mb, *ref_mb;
  351. int row_offset = band->mb_size * band->pitch;
  352. mb = tile->mbs;
  353. ref_mb = tile->ref_mbs;
  354. offs = tile->ypos * band->pitch + tile->xpos;
  355. if (!ref_mb &&
  356. ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
  357. return AVERROR_INVALIDDATA;
  358. if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) {
  359. av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches parameters %d\n",
  360. tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size));
  361. return AVERROR_INVALIDDATA;
  362. }
  363. /* scale factor for motion vectors */
  364. mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
  365. mv_x = mv_y = 0;
  366. for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
  367. mb_offset = offs;
  368. for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
  369. mb->xpos = x;
  370. mb->ypos = y;
  371. mb->buf_offs = mb_offset;
  372. if (get_bits1(&ctx->gb)) {
  373. if (ctx->frame_type == FRAMETYPE_INTRA) {
  374. av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
  375. return -1;
  376. }
  377. mb->type = 1; /* empty macroblocks are always INTER */
  378. mb->cbp = 0; /* all blocks are empty */
  379. mb->q_delta = 0;
  380. if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
  381. mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
  382. IVI_VLC_BITS, 1);
  383. mb->q_delta = IVI_TOSIGNED(mb->q_delta);
  384. }
  385. mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
  386. if (band->inherit_mv){
  387. /* motion vector inheritance */
  388. if (mv_scale) {
  389. mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
  390. mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
  391. } else {
  392. mb->mv_x = ref_mb->mv_x;
  393. mb->mv_y = ref_mb->mv_y;
  394. }
  395. }
  396. } else {
  397. if (band->inherit_mv) {
  398. mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
  399. } else if (ctx->frame_type == FRAMETYPE_INTRA) {
  400. mb->type = 0; /* mb_type is always INTRA for intra-frames */
  401. } else {
  402. mb->type = get_bits1(&ctx->gb);
  403. }
  404. blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
  405. mb->cbp = get_bits(&ctx->gb, blks_per_mb);
  406. mb->q_delta = 0;
  407. if (band->qdelta_present) {
  408. if (band->inherit_qdelta) {
  409. if (ref_mb) mb->q_delta = ref_mb->q_delta;
  410. } else if (mb->cbp || (!band->plane && !band->band_num &&
  411. (ctx->frame_flags & 8))) {
  412. mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
  413. IVI_VLC_BITS, 1);
  414. mb->q_delta = IVI_TOSIGNED(mb->q_delta);
  415. }
  416. }
  417. if (!mb->type) {
  418. mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
  419. } else {
  420. if (band->inherit_mv){
  421. /* motion vector inheritance */
  422. if (mv_scale) {
  423. mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
  424. mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
  425. } else {
  426. mb->mv_x = ref_mb->mv_x;
  427. mb->mv_y = ref_mb->mv_y;
  428. }
  429. } else {
  430. /* decode motion vector deltas */
  431. mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
  432. IVI_VLC_BITS, 1);
  433. mv_y += IVI_TOSIGNED(mv_delta);
  434. mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
  435. IVI_VLC_BITS, 1);
  436. mv_x += IVI_TOSIGNED(mv_delta);
  437. mb->mv_x = mv_x;
  438. mb->mv_y = mv_y;
  439. }
  440. }
  441. }
  442. mb++;
  443. if (ref_mb)
  444. ref_mb++;
  445. mb_offset += band->mb_size;
  446. }
  447. offs += row_offset;
  448. }
  449. align_get_bits(&ctx->gb);
  450. return 0;
  451. }
  452. /**
  453. * Switch buffers.
  454. *
  455. * @param[in,out] ctx ptr to the decoder context
  456. */
  457. static void switch_buffers(IVI45DecContext *ctx)
  458. {
  459. switch (ctx->prev_frame_type) {
  460. case FRAMETYPE_INTRA:
  461. case FRAMETYPE_INTER:
  462. ctx->buf_switch ^= 1;
  463. ctx->dst_buf = ctx->buf_switch;
  464. ctx->ref_buf = ctx->buf_switch ^ 1;
  465. break;
  466. case FRAMETYPE_INTER_SCAL:
  467. if (!ctx->inter_scal) {
  468. ctx->ref2_buf = 2;
  469. ctx->inter_scal = 1;
  470. }
  471. FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
  472. ctx->ref_buf = ctx->ref2_buf;
  473. break;
  474. case FRAMETYPE_INTER_NOREF:
  475. break;
  476. }
  477. switch (ctx->frame_type) {
  478. case FRAMETYPE_INTRA:
  479. ctx->buf_switch = 0;
  480. /* FALLTHROUGH */
  481. case FRAMETYPE_INTER:
  482. ctx->inter_scal = 0;
  483. ctx->dst_buf = ctx->buf_switch;
  484. ctx->ref_buf = ctx->buf_switch ^ 1;
  485. break;
  486. case FRAMETYPE_INTER_SCAL:
  487. case FRAMETYPE_INTER_NOREF:
  488. case FRAMETYPE_NULL:
  489. break;
  490. }
  491. }
  492. static int is_nonnull_frame(IVI45DecContext *ctx)
  493. {
  494. return ctx->frame_type != FRAMETYPE_NULL;
  495. }
  496. /**
  497. * Initialize Indeo5 decoder.
  498. */
  499. static av_cold int decode_init(AVCodecContext *avctx)
  500. {
  501. IVI45DecContext *ctx = avctx->priv_data;
  502. int result;
  503. ff_ivi_init_static_vlc();
  504. /* copy rvmap tables in our context so we can apply changes to them */
  505. memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
  506. /* set the initial picture layout according to the basic profile:
  507. there is only one band per plane (no scalability), only one tile (no local decoding)
  508. and picture format = YVU9 */
  509. ctx->pic_conf.pic_width = avctx->width;
  510. ctx->pic_conf.pic_height = avctx->height;
  511. ctx->pic_conf.chroma_width = (avctx->width + 3) >> 2;
  512. ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
  513. ctx->pic_conf.tile_width = avctx->width;
  514. ctx->pic_conf.tile_height = avctx->height;
  515. ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1;
  516. result = ff_ivi_init_planes(ctx->planes, &ctx->pic_conf);
  517. if (result) {
  518. av_log(avctx, AV_LOG_ERROR, "Couldn't allocate color planes!\n");
  519. return -1;
  520. }
  521. ctx->buf_switch = 0;
  522. ctx->inter_scal = 0;
  523. ctx->decode_pic_hdr = decode_pic_hdr;
  524. ctx->decode_band_hdr = decode_band_hdr;
  525. ctx->decode_mb_info = decode_mb_info;
  526. ctx->switch_buffers = switch_buffers;
  527. ctx->is_nonnull_frame = is_nonnull_frame;
  528. avctx->pix_fmt = PIX_FMT_YUV410P;
  529. return 0;
  530. }
  531. AVCodec ff_indeo5_decoder = {
  532. .name = "indeo5",
  533. .type = AVMEDIA_TYPE_VIDEO,
  534. .id = AV_CODEC_ID_INDEO5,
  535. .priv_data_size = sizeof(IVI45DecContext),
  536. .init = decode_init,
  537. .close = ff_ivi_decode_close,
  538. .decode = ff_ivi_decode_frame,
  539. .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo Video Interactive 5"),
  540. };