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.

704 lines
20KB

  1. /*
  2. * Interplay MVE Video Decoder
  3. * Copyright (C) 2003 the ffmpeg project
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg 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. * FFmpeg 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 FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. /**
  22. * @file libavcodec/interplayvideo.c
  23. * Interplay MVE Video Decoder by Mike Melanson (melanson@pcisys.net)
  24. * For more information about the Interplay MVE format, visit:
  25. * http://www.pcisys.net/~melanson/codecs/interplay-mve.txt
  26. * This code is written in such a way that the identifiers match up
  27. * with the encoding descriptions in the document.
  28. *
  29. * This decoder presently only supports a PAL8 output colorspace.
  30. *
  31. * An Interplay video frame consists of 2 parts: The decoding map and
  32. * the video data. A demuxer must load these 2 parts together in a single
  33. * buffer before sending it through the stream to this decoder.
  34. */
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. #include "avcodec.h"
  39. #include "bytestream.h"
  40. #include "dsputil.h"
  41. #define ALT_BITSTREAM_READER_LE
  42. #include "get_bits.h"
  43. #define PALETTE_COUNT 256
  44. /* debugging support */
  45. #define DEBUG_INTERPLAY 0
  46. #if DEBUG_INTERPLAY
  47. #define debug_interplay(x,...) av_log(NULL, AV_LOG_DEBUG, x, __VA_ARGS__)
  48. #else
  49. static inline void debug_interplay(const char *format, ...) { }
  50. #endif
  51. typedef struct IpvideoContext {
  52. AVCodecContext *avctx;
  53. DSPContext dsp;
  54. AVFrame second_last_frame;
  55. AVFrame last_frame;
  56. AVFrame current_frame;
  57. const unsigned char *decoding_map;
  58. int decoding_map_size;
  59. const unsigned char *buf;
  60. int size;
  61. const unsigned char *stream_ptr;
  62. const unsigned char *stream_end;
  63. unsigned char *pixel_ptr;
  64. int line_inc;
  65. int stride;
  66. int upper_motion_limit_offset;
  67. } IpvideoContext;
  68. #define CHECK_STREAM_PTR(n) \
  69. if (s->stream_end - s->stream_ptr < n) { \
  70. av_log(s->avctx, AV_LOG_ERROR, "Interplay video warning: stream_ptr out of bounds (%p >= %p)\n", \
  71. s->stream_ptr + n, s->stream_end); \
  72. return -1; \
  73. }
  74. static int copy_from(IpvideoContext *s, AVFrame *src, int delta_x, int delta_y)
  75. {
  76. int current_offset = s->pixel_ptr - s->current_frame.data[0];
  77. int motion_offset = current_offset + delta_y * s->stride + delta_x;
  78. if (motion_offset < 0) {
  79. av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset < 0 (%d)\n", motion_offset);
  80. return -1;
  81. } else if (motion_offset > s->upper_motion_limit_offset) {
  82. av_log(s->avctx, AV_LOG_ERROR, " Interplay video: motion offset above limit (%d >= %d)\n",
  83. motion_offset, s->upper_motion_limit_offset);
  84. return -1;
  85. }
  86. s->dsp.put_pixels_tab[1][0](s->pixel_ptr, src->data[0] + motion_offset, s->stride, 8);
  87. return 0;
  88. }
  89. static int ipvideo_decode_block_opcode_0x0(IpvideoContext *s)
  90. {
  91. return copy_from(s, &s->last_frame, 0, 0);
  92. }
  93. static int ipvideo_decode_block_opcode_0x1(IpvideoContext *s)
  94. {
  95. return copy_from(s, &s->second_last_frame, 0, 0);
  96. }
  97. static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)
  98. {
  99. unsigned char B;
  100. int x, y;
  101. /* copy block from 2 frames ago using a motion vector; need 1 more byte */
  102. CHECK_STREAM_PTR(1);
  103. B = *s->stream_ptr++;
  104. if (B < 56) {
  105. x = 8 + (B % 7);
  106. y = B / 7;
  107. } else {
  108. x = -14 + ((B - 56) % 29);
  109. y = 8 + ((B - 56) / 29);
  110. }
  111. debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
  112. return copy_from(s, &s->second_last_frame, x, y);
  113. }
  114. static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s)
  115. {
  116. unsigned char B;
  117. int x, y;
  118. /* copy 8x8 block from current frame from an up/left block */
  119. /* need 1 more byte for motion */
  120. CHECK_STREAM_PTR(1);
  121. B = *s->stream_ptr++;
  122. if (B < 56) {
  123. x = -(8 + (B % 7));
  124. y = -(B / 7);
  125. } else {
  126. x = -(-14 + ((B - 56) % 29));
  127. y = -( 8 + ((B - 56) / 29));
  128. }
  129. debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
  130. return copy_from(s, &s->current_frame, x, y);
  131. }
  132. static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s)
  133. {
  134. int x, y;
  135. unsigned char B, BL, BH;
  136. /* copy a block from the previous frame; need 1 more byte */
  137. CHECK_STREAM_PTR(1);
  138. B = *s->stream_ptr++;
  139. BL = B & 0x0F;
  140. BH = (B >> 4) & 0x0F;
  141. x = -8 + BL;
  142. y = -8 + BH;
  143. debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
  144. return copy_from(s, &s->last_frame, x, y);
  145. }
  146. static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)
  147. {
  148. signed char x, y;
  149. /* copy a block from the previous frame using an expanded range;
  150. * need 2 more bytes */
  151. CHECK_STREAM_PTR(2);
  152. x = *s->stream_ptr++;
  153. y = *s->stream_ptr++;
  154. debug_interplay (" motion bytes = %d, %d\n", x, y);
  155. return copy_from(s, &s->last_frame, x, y);
  156. }
  157. static int ipvideo_decode_block_opcode_0x6(IpvideoContext *s)
  158. {
  159. /* mystery opcode? skip multiple blocks? */
  160. av_log(s->avctx, AV_LOG_ERROR, " Interplay video: Help! Mystery opcode 0x6 seen\n");
  161. /* report success */
  162. return 0;
  163. }
  164. static int ipvideo_decode_block_opcode_0x7(IpvideoContext *s)
  165. {
  166. int x, y;
  167. unsigned char P[2];
  168. unsigned int flags;
  169. /* 2-color encoding */
  170. CHECK_STREAM_PTR(2);
  171. P[0] = *s->stream_ptr++;
  172. P[1] = *s->stream_ptr++;
  173. if (P[0] <= P[1]) {
  174. /* need 8 more bytes from the stream */
  175. CHECK_STREAM_PTR(8);
  176. for (y = 0; y < 8; y++) {
  177. flags = *s->stream_ptr++ | 0x100;
  178. for (; flags != 1; flags >>= 1)
  179. *s->pixel_ptr++ = P[flags & 1];
  180. s->pixel_ptr += s->line_inc;
  181. }
  182. } else {
  183. /* need 2 more bytes from the stream */
  184. CHECK_STREAM_PTR(2);
  185. flags = bytestream_get_le16(&s->stream_ptr);
  186. for (y = 0; y < 8; y += 2) {
  187. for (x = 0; x < 8; x += 2, flags >>= 1) {
  188. s->pixel_ptr[x ] =
  189. s->pixel_ptr[x + 1 ] =
  190. s->pixel_ptr[x + s->stride] =
  191. s->pixel_ptr[x + 1 + s->stride] = P[flags & 1];
  192. }
  193. s->pixel_ptr += s->stride * 2;
  194. }
  195. }
  196. /* report success */
  197. return 0;
  198. }
  199. static int ipvideo_decode_block_opcode_0x8(IpvideoContext *s)
  200. {
  201. int x, y;
  202. unsigned char P[2];
  203. unsigned int flags = 0;
  204. /* 2-color encoding for each 4x4 quadrant, or 2-color encoding on
  205. * either top and bottom or left and right halves */
  206. CHECK_STREAM_PTR(2);
  207. P[0] = *s->stream_ptr++;
  208. P[1] = *s->stream_ptr++;
  209. if (P[0] <= P[1]) {
  210. CHECK_STREAM_PTR(14);
  211. s->stream_ptr -= 2;
  212. for (y = 0; y < 16; y++) {
  213. // new values for each 4x4 block
  214. if (!(y & 3)) {
  215. P[0] = *s->stream_ptr++; P[1] = *s->stream_ptr++;
  216. flags = bytestream_get_le16(&s->stream_ptr);
  217. }
  218. for (x = 0; x < 4; x++, flags >>= 1)
  219. *s->pixel_ptr++ = P[flags & 1];
  220. s->pixel_ptr += s->stride - 4;
  221. // switch to right half
  222. if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;
  223. }
  224. } else {
  225. /* need 10 more bytes */
  226. CHECK_STREAM_PTR(10);
  227. if (s->stream_ptr[4] <= s->stream_ptr[5]) {
  228. flags = bytestream_get_le32(&s->stream_ptr);
  229. /* vertical split; left & right halves are 2-color encoded */
  230. for (y = 0; y < 16; y++) {
  231. for (x = 0; x < 4; x++, flags >>= 1)
  232. *s->pixel_ptr++ = P[flags & 1];
  233. s->pixel_ptr += s->stride - 4;
  234. // switch to right half
  235. if (y == 7) {
  236. s->pixel_ptr -= 8 * s->stride - 4;
  237. P[0] = *s->stream_ptr++; P[1] = *s->stream_ptr++;
  238. flags = bytestream_get_le32(&s->stream_ptr);
  239. }
  240. }
  241. } else {
  242. /* horizontal split; top & bottom halves are 2-color encoded */
  243. for (y = 0; y < 8; y++) {
  244. if (y == 4) {
  245. P[0] = *s->stream_ptr++;
  246. P[1] = *s->stream_ptr++;
  247. }
  248. flags = *s->stream_ptr++ | 0x100;
  249. for (; flags != 1; flags >>= 1)
  250. *s->pixel_ptr++ = P[flags & 1];
  251. s->pixel_ptr += s->line_inc;
  252. }
  253. }
  254. }
  255. /* report success */
  256. return 0;
  257. }
  258. static int ipvideo_decode_block_opcode_0x9(IpvideoContext *s)
  259. {
  260. int x, y;
  261. unsigned char P[4];
  262. /* 4-color encoding */
  263. CHECK_STREAM_PTR(4);
  264. memcpy(P, s->stream_ptr, 4);
  265. s->stream_ptr += 4;
  266. if (P[0] <= P[1]) {
  267. if (P[2] <= P[3]) {
  268. /* 1 of 4 colors for each pixel, need 16 more bytes */
  269. CHECK_STREAM_PTR(16);
  270. for (y = 0; y < 8; y++) {
  271. /* get the next set of 8 2-bit flags */
  272. int flags = bytestream_get_le16(&s->stream_ptr);
  273. for (x = 0; x < 8; x++, flags >>= 2)
  274. *s->pixel_ptr++ = P[flags & 0x03];
  275. s->pixel_ptr += s->line_inc;
  276. }
  277. } else {
  278. uint32_t flags;
  279. /* 1 of 4 colors for each 2x2 block, need 4 more bytes */
  280. CHECK_STREAM_PTR(4);
  281. flags = bytestream_get_le32(&s->stream_ptr);
  282. for (y = 0; y < 8; y += 2) {
  283. for (x = 0; x < 8; x += 2, flags >>= 2) {
  284. s->pixel_ptr[x ] =
  285. s->pixel_ptr[x + 1 ] =
  286. s->pixel_ptr[x + s->stride] =
  287. s->pixel_ptr[x + 1 + s->stride] = P[flags & 0x03];
  288. }
  289. s->pixel_ptr += s->stride * 2;
  290. }
  291. }
  292. } else {
  293. uint64_t flags;
  294. /* 1 of 4 colors for each 2x1 or 1x2 block, need 8 more bytes */
  295. CHECK_STREAM_PTR(8);
  296. flags = bytestream_get_le64(&s->stream_ptr);
  297. if (P[2] <= P[3]) {
  298. for (y = 0; y < 8; y++) {
  299. for (x = 0; x < 8; x += 2, flags >>= 2) {
  300. s->pixel_ptr[x ] =
  301. s->pixel_ptr[x + 1] = P[flags & 0x03];
  302. }
  303. s->pixel_ptr += s->stride;
  304. }
  305. } else {
  306. for (y = 0; y < 8; y += 2) {
  307. for (x = 0; x < 8; x++, flags >>= 2) {
  308. s->pixel_ptr[x ] =
  309. s->pixel_ptr[x + s->stride] = P[flags & 0x03];
  310. }
  311. s->pixel_ptr += s->stride * 2;
  312. }
  313. }
  314. }
  315. /* report success */
  316. return 0;
  317. }
  318. static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s)
  319. {
  320. int x, y;
  321. unsigned char P[4];
  322. int flags = 0;
  323. /* 4-color encoding for each 4x4 quadrant, or 4-color encoding on
  324. * either top and bottom or left and right halves */
  325. CHECK_STREAM_PTR(24);
  326. if (s->stream_ptr[0] <= s->stream_ptr[1]) {
  327. /* 4-color encoding for each quadrant; need 32 bytes */
  328. CHECK_STREAM_PTR(32);
  329. for (y = 0; y < 16; y++) {
  330. // new values for each 4x4 block
  331. if (!(y & 3)) {
  332. memcpy(P, s->stream_ptr, 4);
  333. s->stream_ptr += 4;
  334. flags = bytestream_get_le32(&s->stream_ptr);
  335. }
  336. for (x = 0; x < 4; x++, flags >>= 2)
  337. *s->pixel_ptr++ = P[flags & 0x03];
  338. s->pixel_ptr += s->stride - 4;
  339. // switch to right half
  340. if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;
  341. }
  342. } else {
  343. // vertical split?
  344. int vert = s->stream_ptr[12] <= s->stream_ptr[13];
  345. uint64_t flags = 0;
  346. /* 4-color encoding for either left and right or top and bottom
  347. * halves */
  348. for (y = 0; y < 16; y++) {
  349. // load values for each half
  350. if (!(y & 7)) {
  351. memcpy(P, s->stream_ptr, 4);
  352. s->stream_ptr += 4;
  353. flags = bytestream_get_le64(&s->stream_ptr);
  354. }
  355. for (x = 0; x < 4; x++, flags >>= 2)
  356. *s->pixel_ptr++ = P[flags & 0x03];
  357. if (vert) {
  358. s->pixel_ptr += s->stride - 4;
  359. // switch to right half
  360. if (y == 7) s->pixel_ptr -= 8 * s->stride - 4;
  361. } else if (y & 1) s->pixel_ptr += s->line_inc;
  362. }
  363. }
  364. /* report success */
  365. return 0;
  366. }
  367. static int ipvideo_decode_block_opcode_0xB(IpvideoContext *s)
  368. {
  369. int y;
  370. /* 64-color encoding (each pixel in block is a different color) */
  371. CHECK_STREAM_PTR(64);
  372. for (y = 0; y < 8; y++) {
  373. memcpy(s->pixel_ptr, s->stream_ptr, 8);
  374. s->stream_ptr += 8;
  375. s->pixel_ptr += s->stride;
  376. }
  377. /* report success */
  378. return 0;
  379. }
  380. static int ipvideo_decode_block_opcode_0xC(IpvideoContext *s)
  381. {
  382. int x, y;
  383. /* 16-color block encoding: each 2x2 block is a different color */
  384. CHECK_STREAM_PTR(16);
  385. for (y = 0; y < 8; y += 2) {
  386. for (x = 0; x < 8; x += 2) {
  387. s->pixel_ptr[x ] =
  388. s->pixel_ptr[x + 1 ] =
  389. s->pixel_ptr[x + s->stride] =
  390. s->pixel_ptr[x + 1 + s->stride] = *s->stream_ptr++;
  391. }
  392. s->pixel_ptr += s->stride * 2;
  393. }
  394. /* report success */
  395. return 0;
  396. }
  397. static int ipvideo_decode_block_opcode_0xD(IpvideoContext *s)
  398. {
  399. int y;
  400. unsigned char P[2];
  401. /* 4-color block encoding: each 4x4 block is a different color */
  402. CHECK_STREAM_PTR(4);
  403. for (y = 0; y < 8; y++) {
  404. if (!(y & 3)) {
  405. P[0] = *s->stream_ptr++;
  406. P[1] = *s->stream_ptr++;
  407. }
  408. memset(s->pixel_ptr, P[0], 4);
  409. memset(s->pixel_ptr + 4, P[1], 4);
  410. s->pixel_ptr += s->stride;
  411. }
  412. /* report success */
  413. return 0;
  414. }
  415. static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s)
  416. {
  417. int y;
  418. unsigned char pix;
  419. /* 1-color encoding: the whole block is 1 solid color */
  420. CHECK_STREAM_PTR(1);
  421. pix = *s->stream_ptr++;
  422. for (y = 0; y < 8; y++) {
  423. memset(s->pixel_ptr, pix, 8);
  424. s->pixel_ptr += s->stride;
  425. }
  426. /* report success */
  427. return 0;
  428. }
  429. static int ipvideo_decode_block_opcode_0xF(IpvideoContext *s)
  430. {
  431. int x, y;
  432. unsigned char sample[2];
  433. /* dithered encoding */
  434. CHECK_STREAM_PTR(2);
  435. sample[0] = *s->stream_ptr++;
  436. sample[1] = *s->stream_ptr++;
  437. for (y = 0; y < 8; y++) {
  438. for (x = 0; x < 8; x += 2) {
  439. *s->pixel_ptr++ = sample[ y & 1 ];
  440. *s->pixel_ptr++ = sample[!(y & 1)];
  441. }
  442. s->pixel_ptr += s->line_inc;
  443. }
  444. /* report success */
  445. return 0;
  446. }
  447. static int (* const ipvideo_decode_block[])(IpvideoContext *s) = {
  448. ipvideo_decode_block_opcode_0x0, ipvideo_decode_block_opcode_0x1,
  449. ipvideo_decode_block_opcode_0x2, ipvideo_decode_block_opcode_0x3,
  450. ipvideo_decode_block_opcode_0x4, ipvideo_decode_block_opcode_0x5,
  451. ipvideo_decode_block_opcode_0x6, ipvideo_decode_block_opcode_0x7,
  452. ipvideo_decode_block_opcode_0x8, ipvideo_decode_block_opcode_0x9,
  453. ipvideo_decode_block_opcode_0xA, ipvideo_decode_block_opcode_0xB,
  454. ipvideo_decode_block_opcode_0xC, ipvideo_decode_block_opcode_0xD,
  455. ipvideo_decode_block_opcode_0xE, ipvideo_decode_block_opcode_0xF,
  456. };
  457. static void ipvideo_decode_opcodes(IpvideoContext *s)
  458. {
  459. int x, y;
  460. unsigned char opcode;
  461. int ret;
  462. static int frame = 0;
  463. GetBitContext gb;
  464. debug_interplay("------------------ frame %d\n", frame);
  465. frame++;
  466. /* this is PAL8, so make the palette available */
  467. memcpy(s->current_frame.data[1], s->avctx->palctrl->palette, PALETTE_COUNT * 4);
  468. s->stride = s->current_frame.linesize[0];
  469. s->stream_ptr = s->buf + 14; /* data starts 14 bytes in */
  470. s->stream_end = s->buf + s->size;
  471. s->line_inc = s->stride - 8;
  472. s->upper_motion_limit_offset = (s->avctx->height - 8) * s->stride
  473. + s->avctx->width - 8;
  474. init_get_bits(&gb, s->decoding_map, s->decoding_map_size * 8);
  475. for (y = 0; y < (s->stride * s->avctx->height); y += s->stride * 8) {
  476. for (x = y; x < y + s->avctx->width; x += 8) {
  477. opcode = get_bits(&gb, 4);
  478. debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
  479. x - y, y / s->stride, opcode, s->stream_ptr);
  480. s->pixel_ptr = s->current_frame.data[0] + x;
  481. ret = ipvideo_decode_block[opcode](s);
  482. if (ret != 0) {
  483. av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode problem on frame %d, @ block (%d, %d)\n",
  484. frame, x - y, y / s->stride);
  485. return;
  486. }
  487. }
  488. }
  489. if (s->stream_end - s->stream_ptr > 1) {
  490. av_log(s->avctx, AV_LOG_ERROR, " Interplay video: decode finished with %td bytes left over\n",
  491. s->stream_end - s->stream_ptr);
  492. }
  493. }
  494. static av_cold int ipvideo_decode_init(AVCodecContext *avctx)
  495. {
  496. IpvideoContext *s = avctx->priv_data;
  497. s->avctx = avctx;
  498. if (s->avctx->palctrl == NULL) {
  499. av_log(avctx, AV_LOG_ERROR, " Interplay video: palette expected.\n");
  500. return -1;
  501. }
  502. avctx->pix_fmt = PIX_FMT_PAL8;
  503. dsputil_init(&s->dsp, avctx);
  504. /* decoding map contains 4 bits of information per 8x8 block */
  505. s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
  506. s->current_frame.data[0] = s->last_frame.data[0] =
  507. s->second_last_frame.data[0] = NULL;
  508. return 0;
  509. }
  510. static int ipvideo_decode_frame(AVCodecContext *avctx,
  511. void *data, int *data_size,
  512. AVPacket *avpkt)
  513. {
  514. const uint8_t *buf = avpkt->data;
  515. int buf_size = avpkt->size;
  516. IpvideoContext *s = avctx->priv_data;
  517. AVPaletteControl *palette_control = avctx->palctrl;
  518. /* compressed buffer needs to be large enough to at least hold an entire
  519. * decoding map */
  520. if (buf_size < s->decoding_map_size)
  521. return buf_size;
  522. s->decoding_map = buf;
  523. s->buf = buf + s->decoding_map_size;
  524. s->size = buf_size - s->decoding_map_size;
  525. s->current_frame.reference = 3;
  526. if (avctx->get_buffer(avctx, &s->current_frame)) {
  527. av_log(avctx, AV_LOG_ERROR, " Interplay Video: get_buffer() failed\n");
  528. return -1;
  529. }
  530. ipvideo_decode_opcodes(s);
  531. if (palette_control->palette_changed) {
  532. palette_control->palette_changed = 0;
  533. s->current_frame.palette_has_changed = 1;
  534. }
  535. *data_size = sizeof(AVFrame);
  536. *(AVFrame*)data = s->current_frame;
  537. /* shuffle frames */
  538. if (s->second_last_frame.data[0])
  539. avctx->release_buffer(avctx, &s->second_last_frame);
  540. s->second_last_frame = s->last_frame;
  541. s->last_frame = s->current_frame;
  542. s->current_frame.data[0] = NULL; /* catch any access attempts */
  543. /* report that the buffer was completely consumed */
  544. return buf_size;
  545. }
  546. static av_cold int ipvideo_decode_end(AVCodecContext *avctx)
  547. {
  548. IpvideoContext *s = avctx->priv_data;
  549. /* release the last frame */
  550. if (s->last_frame.data[0])
  551. avctx->release_buffer(avctx, &s->last_frame);
  552. if (s->second_last_frame.data[0])
  553. avctx->release_buffer(avctx, &s->second_last_frame);
  554. return 0;
  555. }
  556. AVCodec interplay_video_decoder = {
  557. "interplayvideo",
  558. CODEC_TYPE_VIDEO,
  559. CODEC_ID_INTERPLAY_VIDEO,
  560. sizeof(IpvideoContext),
  561. ipvideo_decode_init,
  562. NULL,
  563. ipvideo_decode_end,
  564. ipvideo_decode_frame,
  565. CODEC_CAP_DR1,
  566. .long_name = NULL_IF_CONFIG_SMALL("Interplay MVE video"),
  567. };