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.

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