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