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.

637 lines
20KB

  1. /*
  2. * Interplay MVE File Demuxer
  3. * Copyright (c) 2003 The ffmpeg Project
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. /**
  20. * @file ipmovie.c
  21. * Interplay MVE file demuxer
  22. * by Mike Melanson (melanson@pcisys.net)
  23. * For more information regarding the Interplay MVE file format, visit:
  24. * http://www.pcisys.net/~melanson/codecs/
  25. * The aforementioned site also contains a command line utility for parsing
  26. * IP MVE files so that you can get a good idea of the typical structure of
  27. * such files. This demuxer is not the best example to use if you are trying
  28. * to write your own as it uses a rather roundabout approach for splitting
  29. * up and sending out the chunks.
  30. */
  31. #include "avformat.h"
  32. /* debugging support: #define DEBUG_IPMOVIE as non-zero to see extremely
  33. * verbose information about the demux process */
  34. #define DEBUG_IPMOVIE 0
  35. #if DEBUG_IPMOVIE
  36. #define debug_ipmovie printf
  37. #else
  38. static inline void debug_ipmovie(const char *format, ...) { }
  39. #endif
  40. #define IPMOVIE_SIGNATURE "Interplay MVE File\x1A\0"
  41. #define IPMOVIE_SIGNATURE_SIZE 20
  42. #define CHUNK_PREAMBLE_SIZE 4
  43. #define OPCODE_PREAMBLE_SIZE 4
  44. #define CHUNK_INIT_AUDIO 0x0000
  45. #define CHUNK_AUDIO_ONLY 0x0001
  46. #define CHUNK_INIT_VIDEO 0x0002
  47. #define CHUNK_VIDEO 0x0003
  48. #define CHUNK_SHUTDOWN 0x0004
  49. #define CHUNK_END 0x0005
  50. /* these last types are used internally */
  51. #define CHUNK_DONE 0xFFFC
  52. #define CHUNK_NOMEM 0xFFFD
  53. #define CHUNK_EOF 0xFFFE
  54. #define CHUNK_BAD 0xFFFF
  55. #define OPCODE_END_OF_STREAM 0x00
  56. #define OPCODE_END_OF_CHUNK 0x01
  57. #define OPCODE_CREATE_TIMER 0x02
  58. #define OPCODE_INIT_AUDIO_BUFFERS 0x03
  59. #define OPCODE_START_STOP_AUDIO 0x04
  60. #define OPCODE_INIT_VIDEO_BUFFERS 0x05
  61. #define OPCODE_UNKNOWN_06 0x06
  62. #define OPCODE_SEND_BUFFER 0x07
  63. #define OPCODE_AUDIO_FRAME 0x08
  64. #define OPCODE_SILENCE_FRAME 0x09
  65. #define OPCODE_INIT_VIDEO_MODE 0x0A
  66. #define OPCODE_CREATE_GRADIENT 0x0B
  67. #define OPCODE_SET_PALETTE 0x0C
  68. #define OPCODE_SET_PALETTE_COMPRESSED 0x0D
  69. #define OPCODE_UNKNOWN_0E 0x0E
  70. #define OPCODE_SET_DECODING_MAP 0x0F
  71. #define OPCODE_UNKNOWN_10 0x10
  72. #define OPCODE_VIDEO_DATA 0x11
  73. #define OPCODE_UNKNOWN_12 0x12
  74. #define OPCODE_UNKNOWN_13 0x13
  75. #define OPCODE_UNKNOWN_14 0x14
  76. #define OPCODE_UNKNOWN_15 0x15
  77. #define PALETTE_COUNT 256
  78. typedef struct IPMVEContext {
  79. unsigned char *buf;
  80. int buf_size;
  81. float fps;
  82. int frame_pts_inc;
  83. unsigned int video_width;
  84. unsigned int video_height;
  85. int64_t video_pts;
  86. unsigned int audio_bits;
  87. unsigned int audio_channels;
  88. unsigned int audio_sample_rate;
  89. unsigned int audio_type;
  90. unsigned int audio_frame_count;
  91. int video_stream_index;
  92. int audio_stream_index;
  93. offset_t audio_chunk_offset;
  94. int audio_chunk_size;
  95. offset_t video_chunk_offset;
  96. int video_chunk_size;
  97. offset_t decode_map_chunk_offset;
  98. int decode_map_chunk_size;
  99. offset_t next_chunk_offset;
  100. AVPaletteControl palette_control;
  101. } IPMVEContext;
  102. static int load_ipmovie_packet(IPMVEContext *s, ByteIOContext *pb,
  103. AVPacket *pkt) {
  104. int chunk_type;
  105. int64_t audio_pts = 0;
  106. if (s->audio_chunk_offset) {
  107. /* adjust for PCM audio by skipping chunk header */
  108. if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
  109. s->audio_chunk_offset += 6;
  110. s->audio_chunk_size -= 6;
  111. }
  112. url_fseek(pb, s->audio_chunk_offset, SEEK_SET);
  113. s->audio_chunk_offset = 0;
  114. /* figure out the audio pts */
  115. audio_pts = 90000;
  116. audio_pts *= s->audio_frame_count;
  117. audio_pts /= s->audio_sample_rate;
  118. if (av_new_packet(pkt, s->audio_chunk_size))
  119. return CHUNK_NOMEM;
  120. pkt->stream_index = s->audio_stream_index;
  121. pkt->pts = audio_pts;
  122. if (get_buffer(pb, pkt->data, s->audio_chunk_size) !=
  123. s->audio_chunk_size) {
  124. av_free_packet(pkt);
  125. return CHUNK_EOF;
  126. }
  127. /* audio frame maintenance */
  128. if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
  129. s->audio_frame_count +=
  130. (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
  131. else
  132. s->audio_frame_count +=
  133. (s->audio_chunk_size - 6) / s->audio_channels;
  134. debug_ipmovie("sending audio frame with pts %lld (%d audio frames)\n",
  135. audio_pts, s->audio_frame_count);
  136. chunk_type = CHUNK_VIDEO;
  137. } else if (s->decode_map_chunk_offset) {
  138. /* send both the decode map and the video data together */
  139. if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size))
  140. return CHUNK_NOMEM;
  141. url_fseek(pb, s->decode_map_chunk_offset, SEEK_SET);
  142. s->decode_map_chunk_offset = 0;
  143. if (get_buffer(pb, pkt->data, s->decode_map_chunk_size) !=
  144. s->decode_map_chunk_size) {
  145. av_free_packet(pkt);
  146. return CHUNK_EOF;
  147. }
  148. url_fseek(pb, s->video_chunk_offset, SEEK_SET);
  149. s->video_chunk_offset = 0;
  150. if (get_buffer(pb, pkt->data + s->decode_map_chunk_size,
  151. s->video_chunk_size) != s->video_chunk_size) {
  152. av_free_packet(pkt);
  153. return CHUNK_EOF;
  154. }
  155. pkt->stream_index = s->video_stream_index;
  156. pkt->pts = s->video_pts;
  157. debug_ipmovie("sending video frame with pts %lld\n",
  158. pkt->pts);
  159. s->video_pts += s->frame_pts_inc;
  160. chunk_type = CHUNK_VIDEO;
  161. } else {
  162. url_fseek(pb, s->next_chunk_offset, SEEK_SET);
  163. chunk_type = CHUNK_DONE;
  164. }
  165. return chunk_type;
  166. }
  167. /* This function loads and processes a single chunk in an IP movie file.
  168. * It returns the type of chunk that was processed. */
  169. static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
  170. AVPacket *pkt)
  171. {
  172. unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
  173. int chunk_type;
  174. int chunk_size;
  175. unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
  176. unsigned char opcode_type;
  177. unsigned char opcode_version;
  178. int opcode_size;
  179. unsigned char scratch[1024];
  180. int i, j;
  181. int first_color, last_color;
  182. int audio_flags;
  183. unsigned char r, g, b;
  184. /* see if there are any pending packets */
  185. chunk_type = load_ipmovie_packet(s, pb, pkt);
  186. if ((chunk_type == CHUNK_VIDEO) && (chunk_type != CHUNK_DONE))
  187. return chunk_type;
  188. /* read the next chunk, wherever the file happens to be pointing */
  189. if (url_feof(pb))
  190. return CHUNK_EOF;
  191. if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
  192. CHUNK_PREAMBLE_SIZE)
  193. return CHUNK_BAD;
  194. chunk_size = LE_16(&chunk_preamble[0]);
  195. chunk_type = LE_16(&chunk_preamble[2]);
  196. debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
  197. switch (chunk_type) {
  198. case CHUNK_INIT_AUDIO:
  199. debug_ipmovie("initialize audio\n");
  200. break;
  201. case CHUNK_AUDIO_ONLY:
  202. debug_ipmovie("audio only\n");
  203. break;
  204. case CHUNK_INIT_VIDEO:
  205. debug_ipmovie("initialize video\n");
  206. break;
  207. case CHUNK_VIDEO:
  208. debug_ipmovie("video (and audio)\n");
  209. break;
  210. case CHUNK_SHUTDOWN:
  211. debug_ipmovie("shutdown\n");
  212. break;
  213. case CHUNK_END:
  214. debug_ipmovie("end\n");
  215. break;
  216. default:
  217. debug_ipmovie("invalid chunk\n");
  218. chunk_type = CHUNK_BAD;
  219. break;
  220. }
  221. while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
  222. /* read the next chunk, wherever the file happens to be pointing */
  223. if (url_feof(pb)) {
  224. chunk_type = CHUNK_EOF;
  225. break;
  226. }
  227. if (get_buffer(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
  228. CHUNK_PREAMBLE_SIZE) {
  229. chunk_type = CHUNK_BAD;
  230. break;
  231. }
  232. opcode_size = LE_16(&opcode_preamble[0]);
  233. opcode_type = opcode_preamble[2];
  234. opcode_version = opcode_preamble[3];
  235. chunk_size -= OPCODE_PREAMBLE_SIZE;
  236. chunk_size -= opcode_size;
  237. if (chunk_size < 0) {
  238. debug_ipmovie("chunk_size countdown just went negative\n");
  239. chunk_type = CHUNK_BAD;
  240. break;
  241. }
  242. debug_ipmovie(" opcode type %02X, version %d, 0x%04X bytes: ",
  243. opcode_type, opcode_version, opcode_size);
  244. switch (opcode_type) {
  245. case OPCODE_END_OF_STREAM:
  246. debug_ipmovie("end of stream\n");
  247. url_fseek(pb, opcode_size, SEEK_CUR);
  248. break;
  249. case OPCODE_END_OF_CHUNK:
  250. debug_ipmovie("end of chunk\n");
  251. url_fseek(pb, opcode_size, SEEK_CUR);
  252. break;
  253. case OPCODE_CREATE_TIMER:
  254. debug_ipmovie("create timer\n");
  255. if ((opcode_version > 0) || (opcode_size > 6)) {
  256. debug_ipmovie("bad create_timer opcode\n");
  257. chunk_type = CHUNK_BAD;
  258. break;
  259. }
  260. if (get_buffer(pb, scratch, opcode_size) !=
  261. opcode_size) {
  262. chunk_type = CHUNK_BAD;
  263. break;
  264. }
  265. s->fps = 1000000.0 / (LE_32(&scratch[0]) * LE_16(&scratch[4]));
  266. s->frame_pts_inc = 90000 / s->fps;
  267. debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n",
  268. s->fps, LE_32(&scratch[0]), LE_16(&scratch[4]));
  269. break;
  270. case OPCODE_INIT_AUDIO_BUFFERS:
  271. debug_ipmovie("initialize audio buffers\n");
  272. if ((opcode_version > 1) || (opcode_size > 10)) {
  273. debug_ipmovie("bad init_audio_buffers opcode\n");
  274. chunk_type = CHUNK_BAD;
  275. break;
  276. }
  277. if (get_buffer(pb, scratch, opcode_size) !=
  278. opcode_size) {
  279. chunk_type = CHUNK_BAD;
  280. break;
  281. }
  282. s->audio_sample_rate = LE_16(&scratch[4]);
  283. audio_flags = LE_16(&scratch[2]);
  284. /* bit 0 of the flags: 0 = mono, 1 = stereo */
  285. s->audio_channels = (audio_flags & 1) + 1;
  286. /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
  287. s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
  288. /* bit 2 indicates compressed audio in version 1 opcode */
  289. if ((opcode_version == 1) && (audio_flags & 0x4))
  290. s->audio_type = CODEC_ID_INTERPLAY_DPCM;
  291. else if (s->audio_bits == 16)
  292. s->audio_type = CODEC_ID_PCM_S16LE;
  293. else
  294. s->audio_type = CODEC_ID_PCM_U8;
  295. debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n",
  296. s->audio_bits,
  297. s->audio_sample_rate,
  298. (s->audio_channels == 2) ? "stereo" : "mono",
  299. (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
  300. "Interplay audio" : "PCM");
  301. break;
  302. case OPCODE_START_STOP_AUDIO:
  303. debug_ipmovie("start/stop audio\n");
  304. url_fseek(pb, opcode_size, SEEK_CUR);
  305. break;
  306. case OPCODE_INIT_VIDEO_BUFFERS:
  307. debug_ipmovie("initialize video buffers\n");
  308. if ((opcode_version > 2) || (opcode_size > 8)) {
  309. debug_ipmovie("bad init_video_buffers opcode\n");
  310. chunk_type = CHUNK_BAD;
  311. break;
  312. }
  313. if (get_buffer(pb, scratch, opcode_size) !=
  314. opcode_size) {
  315. chunk_type = CHUNK_BAD;
  316. break;
  317. }
  318. s->video_width = LE_16(&scratch[0]) * 8;
  319. s->video_height = LE_16(&scratch[2]) * 8;
  320. debug_ipmovie("video resolution: %d x %d\n",
  321. s->video_width, s->video_height);
  322. break;
  323. case OPCODE_UNKNOWN_06:
  324. case OPCODE_UNKNOWN_0E:
  325. case OPCODE_UNKNOWN_10:
  326. case OPCODE_UNKNOWN_12:
  327. case OPCODE_UNKNOWN_13:
  328. case OPCODE_UNKNOWN_14:
  329. case OPCODE_UNKNOWN_15:
  330. debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type);
  331. url_fseek(pb, opcode_size, SEEK_CUR);
  332. break;
  333. case OPCODE_SEND_BUFFER:
  334. debug_ipmovie("send buffer\n");
  335. url_fseek(pb, opcode_size, SEEK_CUR);
  336. break;
  337. case OPCODE_AUDIO_FRAME:
  338. debug_ipmovie("audio frame\n");
  339. /* log position and move on for now */
  340. s->audio_chunk_offset = url_ftell(pb);
  341. s->audio_chunk_size = opcode_size;
  342. url_fseek(pb, opcode_size, SEEK_CUR);
  343. break;
  344. case OPCODE_SILENCE_FRAME:
  345. debug_ipmovie("silence frame\n");
  346. url_fseek(pb, opcode_size, SEEK_CUR);
  347. break;
  348. case OPCODE_INIT_VIDEO_MODE:
  349. debug_ipmovie("initialize video mode\n");
  350. url_fseek(pb, opcode_size, SEEK_CUR);
  351. break;
  352. case OPCODE_CREATE_GRADIENT:
  353. debug_ipmovie("create gradient\n");
  354. url_fseek(pb, opcode_size, SEEK_CUR);
  355. break;
  356. case OPCODE_SET_PALETTE:
  357. debug_ipmovie("set palette\n");
  358. /* check for the logical maximum palette size
  359. * (3 * 256 + 4 bytes) */
  360. if (opcode_size > 0x304) {
  361. debug_ipmovie("demux_ipmovie: set_palette opcode too large\n");
  362. chunk_type = CHUNK_BAD;
  363. break;
  364. }
  365. if (get_buffer(pb, scratch, opcode_size) != opcode_size) {
  366. chunk_type = CHUNK_BAD;
  367. break;
  368. }
  369. /* load the palette into internal data structure */
  370. first_color = LE_16(&scratch[0]);
  371. last_color = first_color + LE_16(&scratch[2]) - 1;
  372. /* sanity check (since they are 16 bit values) */
  373. if ((first_color > 0xFF) || (last_color > 0xFF)) {
  374. debug_ipmovie("demux_ipmovie: set_palette indices out of range (%d -> %d)\n",
  375. first_color, last_color);
  376. chunk_type = CHUNK_BAD;
  377. break;
  378. }
  379. j = 4; /* offset of first palette data */
  380. for (i = first_color; i <= last_color; i++) {
  381. /* the palette is stored as a 6-bit VGA palette, thus each
  382. * component is shifted up to a 8-bit range */
  383. r = scratch[j++] * 4;
  384. g = scratch[j++] * 4;
  385. b = scratch[j++] * 4;
  386. s->palette_control.palette[i] = (r << 16) | (g << 8) | (b);
  387. }
  388. /* indicate a palette change */
  389. s->palette_control.palette_changed = 1;
  390. break;
  391. case OPCODE_SET_PALETTE_COMPRESSED:
  392. debug_ipmovie("set palette compressed\n");
  393. url_fseek(pb, opcode_size, SEEK_CUR);
  394. break;
  395. case OPCODE_SET_DECODING_MAP:
  396. debug_ipmovie("set decoding map\n");
  397. /* log position and move on for now */
  398. s->decode_map_chunk_offset = url_ftell(pb);
  399. s->decode_map_chunk_size = opcode_size;
  400. url_fseek(pb, opcode_size, SEEK_CUR);
  401. break;
  402. case OPCODE_VIDEO_DATA:
  403. debug_ipmovie("set video data\n");
  404. /* log position and move on for now */
  405. s->video_chunk_offset = url_ftell(pb);
  406. s->video_chunk_size = opcode_size;
  407. url_fseek(pb, opcode_size, SEEK_CUR);
  408. break;
  409. default:
  410. debug_ipmovie("*** unknown opcode type\n");
  411. chunk_type = CHUNK_BAD;
  412. break;
  413. }
  414. }
  415. /* make a note of where the stream is sitting */
  416. s->next_chunk_offset = url_ftell(pb);
  417. /* dispatch the first of any pending packets */
  418. if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
  419. chunk_type = load_ipmovie_packet(s, pb, pkt);
  420. return chunk_type;
  421. }
  422. static int ipmovie_probe(AVProbeData *p)
  423. {
  424. if (p->buf_size < IPMOVIE_SIGNATURE_SIZE)
  425. return 0;
  426. if (strncmp(p->buf, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0)
  427. return 0;
  428. return AVPROBE_SCORE_MAX;
  429. }
  430. static int ipmovie_read_header(AVFormatContext *s,
  431. AVFormatParameters *ap)
  432. {
  433. IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
  434. ByteIOContext *pb = &s->pb;
  435. AVPacket pkt;
  436. AVStream *st;
  437. unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
  438. int chunk_type;
  439. /* initialize private context members */
  440. ipmovie->video_pts = ipmovie->audio_frame_count = 0;
  441. ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
  442. ipmovie->decode_map_chunk_offset = 0;
  443. /* on the first read, this will position the stream at the first chunk */
  444. ipmovie->next_chunk_offset = IPMOVIE_SIGNATURE_SIZE + 6;
  445. /* process the first chunk which should be CHUNK_INIT_VIDEO */
  446. if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
  447. return AVERROR_INVALIDDATA;
  448. /* peek ahead to the next chunk-- if it is an init audio chunk, process
  449. * it; if it is the first video chunk, this is a silent file */
  450. if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
  451. CHUNK_PREAMBLE_SIZE)
  452. return -EIO;
  453. chunk_type = LE_16(&chunk_preamble[2]);
  454. url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
  455. if (chunk_type == CHUNK_VIDEO)
  456. ipmovie->audio_type = 0; /* no audio */
  457. else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
  458. return AVERROR_INVALIDDATA;
  459. /* set the pts reference (1 pts = 1/90000) */
  460. s->pts_num = 1;
  461. s->pts_den = 90000;
  462. /* initialize the stream decoders */
  463. st = av_new_stream(s, 0);
  464. if (!st)
  465. return AVERROR_NOMEM;
  466. ipmovie->video_stream_index = st->index;
  467. st->codec.codec_type = CODEC_TYPE_VIDEO;
  468. st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO;
  469. st->codec.codec_tag = 0; /* no fourcc */
  470. st->codec.width = ipmovie->video_width;
  471. st->codec.height = ipmovie->video_height;
  472. /* palette considerations */
  473. st->codec.palctrl = &ipmovie->palette_control;
  474. if (ipmovie->audio_type) {
  475. st = av_new_stream(s, 0);
  476. if (!st)
  477. return AVERROR_NOMEM;
  478. ipmovie->audio_stream_index = st->index;
  479. st->codec.codec_type = CODEC_TYPE_AUDIO;
  480. st->codec.codec_id = ipmovie->audio_type;
  481. st->codec.codec_tag = 0; /* no tag */
  482. st->codec.channels = ipmovie->audio_channels;
  483. st->codec.sample_rate = ipmovie->audio_sample_rate;
  484. st->codec.bits_per_sample = ipmovie->audio_bits;
  485. st->codec.bit_rate = st->codec.channels * st->codec.sample_rate *
  486. st->codec.bits_per_sample;
  487. if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM)
  488. st->codec.bit_rate /= 2;
  489. st->codec.block_align = st->codec.channels * st->codec.bits_per_sample;
  490. }
  491. return 0;
  492. }
  493. static int ipmovie_read_packet(AVFormatContext *s,
  494. AVPacket *pkt)
  495. {
  496. IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
  497. ByteIOContext *pb = &s->pb;
  498. int ret;
  499. ret = process_ipmovie_chunk(ipmovie, pb, pkt);
  500. if (ret == CHUNK_BAD)
  501. ret = AVERROR_INVALIDDATA;
  502. else if (ret == CHUNK_EOF)
  503. ret = -EIO;
  504. else if (ret == CHUNK_NOMEM)
  505. ret = AVERROR_NOMEM;
  506. else
  507. ret = 0;
  508. return ret;
  509. }
  510. static int ipmovie_read_close(AVFormatContext *s)
  511. {
  512. // IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
  513. return 0;
  514. }
  515. static AVInputFormat ipmovie_iformat = {
  516. "ipmovie",
  517. "Interplay MVE format",
  518. sizeof(IPMVEContext),
  519. ipmovie_probe,
  520. ipmovie_read_header,
  521. ipmovie_read_packet,
  522. ipmovie_read_close,
  523. };
  524. int ipmovie_init(void)
  525. {
  526. av_register_input_format(&ipmovie_iformat);
  527. return 0;
  528. }