]> git.sesse.net Git - ffmpeg/blob - libavformat/ipmovie.c
matroskaenc: make sure we don't produce invalid file with no codec ID
[ffmpeg] / libavformat / ipmovie.c
1 /*
2  * Interplay MVE File Demuxer
3  * Copyright (c) 2003 The ffmpeg Project
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 /**
23  * @file
24  * Interplay MVE file demuxer
25  * by Mike Melanson (melanson@pcisys.net)
26  * For more information regarding the Interplay MVE file format, visit:
27  *   http://www.pcisys.net/~melanson/codecs/
28  * The aforementioned site also contains a command line utility for parsing
29  * IP MVE files so that you can get a good idea of the typical structure of
30  * such files. This demuxer is not the best example to use if you are trying
31  * to write your own as it uses a rather roundabout approach for splitting
32  * up and sending out the chunks.
33  */
34
35 #include "libavutil/intreadwrite.h"
36 #include "avformat.h"
37
38 /* debugging support: #define DEBUG_IPMOVIE as non-zero to see extremely
39  * verbose information about the demux process */
40 #define DEBUG_IPMOVIE 0
41
42 #if DEBUG_IPMOVIE
43 #undef printf
44 #define debug_ipmovie printf
45 #else
46 static inline void debug_ipmovie(const char *format, ...) { }
47 #endif
48
49 #define CHUNK_PREAMBLE_SIZE 4
50 #define OPCODE_PREAMBLE_SIZE 4
51
52 #define CHUNK_INIT_AUDIO   0x0000
53 #define CHUNK_AUDIO_ONLY   0x0001
54 #define CHUNK_INIT_VIDEO   0x0002
55 #define CHUNK_VIDEO        0x0003
56 #define CHUNK_SHUTDOWN     0x0004
57 #define CHUNK_END          0x0005
58 /* these last types are used internally */
59 #define CHUNK_DONE         0xFFFC
60 #define CHUNK_NOMEM        0xFFFD
61 #define CHUNK_EOF          0xFFFE
62 #define CHUNK_BAD          0xFFFF
63
64 #define OPCODE_END_OF_STREAM           0x00
65 #define OPCODE_END_OF_CHUNK            0x01
66 #define OPCODE_CREATE_TIMER            0x02
67 #define OPCODE_INIT_AUDIO_BUFFERS      0x03
68 #define OPCODE_START_STOP_AUDIO        0x04
69 #define OPCODE_INIT_VIDEO_BUFFERS      0x05
70 #define OPCODE_UNKNOWN_06              0x06
71 #define OPCODE_SEND_BUFFER             0x07
72 #define OPCODE_AUDIO_FRAME             0x08
73 #define OPCODE_SILENCE_FRAME           0x09
74 #define OPCODE_INIT_VIDEO_MODE         0x0A
75 #define OPCODE_CREATE_GRADIENT         0x0B
76 #define OPCODE_SET_PALETTE             0x0C
77 #define OPCODE_SET_PALETTE_COMPRESSED  0x0D
78 #define OPCODE_UNKNOWN_0E              0x0E
79 #define OPCODE_SET_DECODING_MAP        0x0F
80 #define OPCODE_UNKNOWN_10              0x10
81 #define OPCODE_VIDEO_DATA              0x11
82 #define OPCODE_UNKNOWN_12              0x12
83 #define OPCODE_UNKNOWN_13              0x13
84 #define OPCODE_UNKNOWN_14              0x14
85 #define OPCODE_UNKNOWN_15              0x15
86
87 #define PALETTE_COUNT 256
88
89 typedef struct IPMVEContext {
90
91     unsigned char *buf;
92     int buf_size;
93
94     uint64_t frame_pts_inc;
95
96     unsigned int video_bpp;
97     unsigned int video_width;
98     unsigned int video_height;
99     int64_t video_pts;
100     uint32_t     palette[256];
101     int          has_palette;
102
103     unsigned int audio_bits;
104     unsigned int audio_channels;
105     unsigned int audio_sample_rate;
106     enum CodecID audio_type;
107     unsigned int audio_frame_count;
108
109     int video_stream_index;
110     int audio_stream_index;
111
112     int64_t audio_chunk_offset;
113     int audio_chunk_size;
114     int64_t video_chunk_offset;
115     int video_chunk_size;
116     int64_t decode_map_chunk_offset;
117     int decode_map_chunk_size;
118
119     int64_t next_chunk_offset;
120
121 } IPMVEContext;
122
123 static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
124     AVPacket *pkt) {
125
126     int chunk_type;
127
128     if (s->audio_chunk_offset) {
129
130         /* adjust for PCM audio by skipping chunk header */
131         if (s->audio_type != CODEC_ID_INTERPLAY_DPCM) {
132             s->audio_chunk_offset += 6;
133             s->audio_chunk_size -= 6;
134         }
135
136         avio_seek(pb, s->audio_chunk_offset, SEEK_SET);
137         s->audio_chunk_offset = 0;
138
139         if (s->audio_chunk_size != av_get_packet(pb, pkt, s->audio_chunk_size))
140             return CHUNK_EOF;
141
142         pkt->stream_index = s->audio_stream_index;
143         pkt->pts = s->audio_frame_count;
144
145         /* audio frame maintenance */
146         if (s->audio_type != CODEC_ID_INTERPLAY_DPCM)
147             s->audio_frame_count +=
148             (s->audio_chunk_size / s->audio_channels / (s->audio_bits / 8));
149         else
150             s->audio_frame_count +=
151                 (s->audio_chunk_size - 6) / s->audio_channels;
152
153         debug_ipmovie("sending audio frame with pts %"PRId64" (%d audio frames)\n",
154             pkt->pts, s->audio_frame_count);
155
156         chunk_type = CHUNK_VIDEO;
157
158     } else if (s->decode_map_chunk_offset) {
159
160         /* send both the decode map and the video data together */
161
162         if (av_new_packet(pkt, s->decode_map_chunk_size + s->video_chunk_size))
163             return CHUNK_NOMEM;
164
165         if (s->has_palette) {
166             uint8_t *pal;
167
168             pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE,
169                                           AVPALETTE_SIZE);
170             if (pal) {
171                 memcpy(pal, s->palette, AVPALETTE_SIZE);
172                 s->has_palette = 0;
173             }
174         }
175
176         pkt->pos= s->decode_map_chunk_offset;
177         avio_seek(pb, s->decode_map_chunk_offset, SEEK_SET);
178         s->decode_map_chunk_offset = 0;
179
180         if (avio_read(pb, pkt->data, s->decode_map_chunk_size) !=
181             s->decode_map_chunk_size) {
182             av_free_packet(pkt);
183             return CHUNK_EOF;
184         }
185
186         avio_seek(pb, s->video_chunk_offset, SEEK_SET);
187         s->video_chunk_offset = 0;
188
189         if (avio_read(pb, pkt->data + s->decode_map_chunk_size,
190             s->video_chunk_size) != s->video_chunk_size) {
191             av_free_packet(pkt);
192             return CHUNK_EOF;
193         }
194
195         pkt->stream_index = s->video_stream_index;
196         pkt->pts = s->video_pts;
197
198         debug_ipmovie("sending video frame with pts %"PRId64"\n",
199             pkt->pts);
200
201         s->video_pts += s->frame_pts_inc;
202
203         chunk_type = CHUNK_VIDEO;
204
205     } else {
206
207         avio_seek(pb, s->next_chunk_offset, SEEK_SET);
208         chunk_type = CHUNK_DONE;
209
210     }
211
212     return chunk_type;
213 }
214
215 /* This function loads and processes a single chunk in an IP movie file.
216  * It returns the type of chunk that was processed. */
217 static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
218     AVPacket *pkt)
219 {
220     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
221     int chunk_type;
222     int chunk_size;
223     unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
224     unsigned char opcode_type;
225     unsigned char opcode_version;
226     int opcode_size;
227     unsigned char scratch[1024];
228     int i, j;
229     int first_color, last_color;
230     int audio_flags;
231     unsigned char r, g, b;
232
233     /* see if there are any pending packets */
234     chunk_type = load_ipmovie_packet(s, pb, pkt);
235     if (chunk_type != CHUNK_DONE)
236         return chunk_type;
237
238     /* read the next chunk, wherever the file happens to be pointing */
239     if (pb->eof_reached)
240         return CHUNK_EOF;
241     if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
242         CHUNK_PREAMBLE_SIZE)
243         return CHUNK_BAD;
244     chunk_size = AV_RL16(&chunk_preamble[0]);
245     chunk_type = AV_RL16(&chunk_preamble[2]);
246
247     debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
248
249     switch (chunk_type) {
250
251     case CHUNK_INIT_AUDIO:
252         debug_ipmovie("initialize audio\n");
253         break;
254
255     case CHUNK_AUDIO_ONLY:
256         debug_ipmovie("audio only\n");
257         break;
258
259     case CHUNK_INIT_VIDEO:
260         debug_ipmovie("initialize video\n");
261         break;
262
263     case CHUNK_VIDEO:
264         debug_ipmovie("video (and audio)\n");
265         break;
266
267     case CHUNK_SHUTDOWN:
268         debug_ipmovie("shutdown\n");
269         break;
270
271     case CHUNK_END:
272         debug_ipmovie("end\n");
273         break;
274
275     default:
276         debug_ipmovie("invalid chunk\n");
277         chunk_type = CHUNK_BAD;
278         break;
279
280     }
281
282     while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {
283
284         /* read the next chunk, wherever the file happens to be pointing */
285         if (pb->eof_reached) {
286             chunk_type = CHUNK_EOF;
287             break;
288         }
289         if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
290             CHUNK_PREAMBLE_SIZE) {
291             chunk_type = CHUNK_BAD;
292             break;
293         }
294
295         opcode_size = AV_RL16(&opcode_preamble[0]);
296         opcode_type = opcode_preamble[2];
297         opcode_version = opcode_preamble[3];
298
299         chunk_size -= OPCODE_PREAMBLE_SIZE;
300         chunk_size -= opcode_size;
301         if (chunk_size < 0) {
302             debug_ipmovie("chunk_size countdown just went negative\n");
303             chunk_type = CHUNK_BAD;
304             break;
305         }
306
307         debug_ipmovie("  opcode type %02X, version %d, 0x%04X bytes: ",
308             opcode_type, opcode_version, opcode_size);
309         switch (opcode_type) {
310
311         case OPCODE_END_OF_STREAM:
312             debug_ipmovie("end of stream\n");
313             avio_skip(pb, opcode_size);
314             break;
315
316         case OPCODE_END_OF_CHUNK:
317             debug_ipmovie("end of chunk\n");
318             avio_skip(pb, opcode_size);
319             break;
320
321         case OPCODE_CREATE_TIMER:
322             debug_ipmovie("create timer\n");
323             if ((opcode_version > 0) || (opcode_size > 6)) {
324                 debug_ipmovie("bad create_timer opcode\n");
325                 chunk_type = CHUNK_BAD;
326                 break;
327             }
328             if (avio_read(pb, scratch, opcode_size) !=
329                 opcode_size) {
330                 chunk_type = CHUNK_BAD;
331                 break;
332             }
333             s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
334             debug_ipmovie("  %.2f frames/second (timer div = %d, subdiv = %d)\n",
335                 1000000.0/s->frame_pts_inc, AV_RL32(&scratch[0]), AV_RL16(&scratch[4]));
336             break;
337
338         case OPCODE_INIT_AUDIO_BUFFERS:
339             debug_ipmovie("initialize audio buffers\n");
340             if ((opcode_version > 1) || (opcode_size > 10)) {
341                 debug_ipmovie("bad init_audio_buffers opcode\n");
342                 chunk_type = CHUNK_BAD;
343                 break;
344             }
345             if (avio_read(pb, scratch, opcode_size) !=
346                 opcode_size) {
347                 chunk_type = CHUNK_BAD;
348                 break;
349             }
350             s->audio_sample_rate = AV_RL16(&scratch[4]);
351             audio_flags = AV_RL16(&scratch[2]);
352             /* bit 0 of the flags: 0 = mono, 1 = stereo */
353             s->audio_channels = (audio_flags & 1) + 1;
354             /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
355             s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
356             /* bit 2 indicates compressed audio in version 1 opcode */
357             if ((opcode_version == 1) && (audio_flags & 0x4))
358                 s->audio_type = CODEC_ID_INTERPLAY_DPCM;
359             else if (s->audio_bits == 16)
360                 s->audio_type = CODEC_ID_PCM_S16LE;
361             else
362                 s->audio_type = CODEC_ID_PCM_U8;
363             debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n",
364                 s->audio_bits,
365                 s->audio_sample_rate,
366                 (s->audio_channels == 2) ? "stereo" : "mono",
367                 (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
368                 "Interplay audio" : "PCM");
369             break;
370
371         case OPCODE_START_STOP_AUDIO:
372             debug_ipmovie("start/stop audio\n");
373             avio_skip(pb, opcode_size);
374             break;
375
376         case OPCODE_INIT_VIDEO_BUFFERS:
377             debug_ipmovie("initialize video buffers\n");
378             if ((opcode_version > 2) || (opcode_size > 8)) {
379                 debug_ipmovie("bad init_video_buffers opcode\n");
380                 chunk_type = CHUNK_BAD;
381                 break;
382             }
383             if (avio_read(pb, scratch, opcode_size) !=
384                 opcode_size) {
385                 chunk_type = CHUNK_BAD;
386                 break;
387             }
388             s->video_width = AV_RL16(&scratch[0]) * 8;
389             s->video_height = AV_RL16(&scratch[2]) * 8;
390             if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
391                 s->video_bpp = 8;
392             } else {
393                 s->video_bpp = 16;
394             }
395             debug_ipmovie("video resolution: %d x %d\n",
396                 s->video_width, s->video_height);
397             break;
398
399         case OPCODE_UNKNOWN_06:
400         case OPCODE_UNKNOWN_0E:
401         case OPCODE_UNKNOWN_10:
402         case OPCODE_UNKNOWN_12:
403         case OPCODE_UNKNOWN_13:
404         case OPCODE_UNKNOWN_14:
405         case OPCODE_UNKNOWN_15:
406             debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type);
407             avio_skip(pb, opcode_size);
408             break;
409
410         case OPCODE_SEND_BUFFER:
411             debug_ipmovie("send buffer\n");
412             avio_skip(pb, opcode_size);
413             break;
414
415         case OPCODE_AUDIO_FRAME:
416             debug_ipmovie("audio frame\n");
417
418             /* log position and move on for now */
419             s->audio_chunk_offset = avio_tell(pb);
420             s->audio_chunk_size = opcode_size;
421             avio_skip(pb, opcode_size);
422             break;
423
424         case OPCODE_SILENCE_FRAME:
425             debug_ipmovie("silence frame\n");
426             avio_skip(pb, opcode_size);
427             break;
428
429         case OPCODE_INIT_VIDEO_MODE:
430             debug_ipmovie("initialize video mode\n");
431             avio_skip(pb, opcode_size);
432             break;
433
434         case OPCODE_CREATE_GRADIENT:
435             debug_ipmovie("create gradient\n");
436             avio_skip(pb, opcode_size);
437             break;
438
439         case OPCODE_SET_PALETTE:
440             debug_ipmovie("set palette\n");
441             /* check for the logical maximum palette size
442              * (3 * 256 + 4 bytes) */
443             if (opcode_size > 0x304) {
444                 debug_ipmovie("demux_ipmovie: set_palette opcode too large\n");
445                 chunk_type = CHUNK_BAD;
446                 break;
447             }
448             if (avio_read(pb, scratch, opcode_size) != opcode_size) {
449                 chunk_type = CHUNK_BAD;
450                 break;
451             }
452
453             /* load the palette into internal data structure */
454             first_color = AV_RL16(&scratch[0]);
455             last_color = first_color + AV_RL16(&scratch[2]) - 1;
456             /* sanity check (since they are 16 bit values) */
457             if ((first_color > 0xFF) || (last_color > 0xFF)) {
458                 debug_ipmovie("demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
459                     first_color, last_color);
460                 chunk_type = CHUNK_BAD;
461                 break;
462             }
463             j = 4;  /* offset of first palette data */
464             for (i = first_color; i <= last_color; i++) {
465                 /* the palette is stored as a 6-bit VGA palette, thus each
466                  * component is shifted up to a 8-bit range */
467                 r = scratch[j++] * 4;
468                 g = scratch[j++] * 4;
469                 b = scratch[j++] * 4;
470                 s->palette[i] = (r << 16) | (g << 8) | (b);
471             }
472             s->has_palette = 1;
473             break;
474
475         case OPCODE_SET_PALETTE_COMPRESSED:
476             debug_ipmovie("set palette compressed\n");
477             avio_skip(pb, opcode_size);
478             break;
479
480         case OPCODE_SET_DECODING_MAP:
481             debug_ipmovie("set decoding map\n");
482
483             /* log position and move on for now */
484             s->decode_map_chunk_offset = avio_tell(pb);
485             s->decode_map_chunk_size = opcode_size;
486             avio_skip(pb, opcode_size);
487             break;
488
489         case OPCODE_VIDEO_DATA:
490             debug_ipmovie("set video data\n");
491
492             /* log position and move on for now */
493             s->video_chunk_offset = avio_tell(pb);
494             s->video_chunk_size = opcode_size;
495             avio_skip(pb, opcode_size);
496             break;
497
498         default:
499             debug_ipmovie("*** unknown opcode type\n");
500             chunk_type = CHUNK_BAD;
501             break;
502
503         }
504     }
505
506     /* make a note of where the stream is sitting */
507     s->next_chunk_offset = avio_tell(pb);
508
509     /* dispatch the first of any pending packets */
510     if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
511         chunk_type = load_ipmovie_packet(s, pb, pkt);
512
513     return chunk_type;
514 }
515
516 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
517
518 static int ipmovie_probe(AVProbeData *p)
519 {
520     uint8_t *b = p->buf;
521     uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
522     do {
523         if (memcmp(b++, signature, sizeof(signature)) == 0)
524             return AVPROBE_SCORE_MAX;
525     } while (b < b_end);
526
527     return 0;
528 }
529
530 static int ipmovie_read_header(AVFormatContext *s,
531                                AVFormatParameters *ap)
532 {
533     IPMVEContext *ipmovie = s->priv_data;
534     AVIOContext *pb = s->pb;
535     AVPacket pkt;
536     AVStream *st;
537     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
538     int chunk_type;
539     uint8_t signature_buffer[sizeof(signature)];
540
541     avio_read(pb, signature_buffer, sizeof(signature_buffer));
542     while (memcmp(signature_buffer, signature, sizeof(signature))) {
543         memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
544         signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
545         if (pb->eof_reached)
546             return AVERROR_EOF;
547     }
548     /* initialize private context members */
549     ipmovie->video_pts = ipmovie->audio_frame_count = 0;
550     ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
551     ipmovie->decode_map_chunk_offset = 0;
552
553     /* on the first read, this will position the stream at the first chunk */
554     ipmovie->next_chunk_offset = avio_tell(pb) + 4;
555
556     /* process the first chunk which should be CHUNK_INIT_VIDEO */
557     if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
558         return AVERROR_INVALIDDATA;
559
560     /* peek ahead to the next chunk-- if it is an init audio chunk, process
561      * it; if it is the first video chunk, this is a silent file */
562     if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
563         CHUNK_PREAMBLE_SIZE)
564         return AVERROR(EIO);
565     chunk_type = AV_RL16(&chunk_preamble[2]);
566     avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
567
568     if (chunk_type == CHUNK_VIDEO)
569         ipmovie->audio_type = CODEC_ID_NONE;  /* no audio */
570     else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
571         return AVERROR_INVALIDDATA;
572
573     /* initialize the stream decoders */
574     st = av_new_stream(s, 0);
575     if (!st)
576         return AVERROR(ENOMEM);
577     av_set_pts_info(st, 63, 1, 1000000);
578     ipmovie->video_stream_index = st->index;
579     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
580     st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
581     st->codec->codec_tag = 0;  /* no fourcc */
582     st->codec->width = ipmovie->video_width;
583     st->codec->height = ipmovie->video_height;
584     st->codec->bits_per_coded_sample = ipmovie->video_bpp;
585
586     if (ipmovie->audio_type) {
587         st = av_new_stream(s, 0);
588         if (!st)
589             return AVERROR(ENOMEM);
590         av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate);
591         ipmovie->audio_stream_index = st->index;
592         st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
593         st->codec->codec_id = ipmovie->audio_type;
594         st->codec->codec_tag = 0;  /* no tag */
595         st->codec->channels = ipmovie->audio_channels;
596         st->codec->sample_rate = ipmovie->audio_sample_rate;
597         st->codec->bits_per_coded_sample = ipmovie->audio_bits;
598         st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
599             st->codec->bits_per_coded_sample;
600         if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
601             st->codec->bit_rate /= 2;
602         st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
603     }
604
605     return 0;
606 }
607
608 static int ipmovie_read_packet(AVFormatContext *s,
609                                AVPacket *pkt)
610 {
611     IPMVEContext *ipmovie = s->priv_data;
612     AVIOContext *pb = s->pb;
613     int ret;
614
615     ret = process_ipmovie_chunk(ipmovie, pb, pkt);
616     if (ret == CHUNK_BAD)
617         ret = AVERROR_INVALIDDATA;
618     else if (ret == CHUNK_EOF)
619         ret = AVERROR(EIO);
620     else if (ret == CHUNK_NOMEM)
621         ret = AVERROR(ENOMEM);
622     else if (ret == CHUNK_VIDEO)
623         ret = 0;
624     else
625         ret = -1;
626
627     return ret;
628 }
629
630 AVInputFormat ff_ipmovie_demuxer = {
631     "ipmovie",
632     NULL_IF_CONFIG_SMALL("Interplay MVE format"),
633     sizeof(IPMVEContext),
634     ipmovie_probe,
635     ipmovie_read_header,
636     ipmovie_read_packet,
637 };