029bb429ff290eae8dd09b60631b694881d74236
[libav.git] / libavformat / avidec.c
1 /*
2 * AVI decoder.
3 * Copyright (c) 2001 Fabrice Bellard.
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 #include "avformat.h"
20 #include "avi.h"
21 #include "dv.h"
22
23 //#define DEBUG
24 //#define DEBUG_SEEK
25
26 typedef struct AVIIndexEntry {
27 unsigned int flags;
28 unsigned int pos;
29 unsigned int cum_len; /* sum of all lengths before this packet */
30 } AVIIndexEntry;
31
32 typedef struct AVIStream {
33 AVIIndexEntry *index_entries;
34 int nb_index_entries;
35 int index_entries_allocated_size;
36 int frame_offset; /* current frame (video) or byte (audio) counter
37 (used to compute the pts) */
38 int scale;
39 int rate;
40 int sample_size; /* audio only data */
41 int start;
42
43 int new_frame_offset; /* temporary storage (used during seek) */
44 int cum_len; /* temporary storage (used during seek) */
45 } AVIStream;
46
47 typedef struct {
48 int64_t riff_end;
49 int64_t movi_end;
50 offset_t movi_list;
51 int index_loaded;
52 DVDemuxContext* dv_demux;
53 } AVIContext;
54
55 static int avi_load_index(AVFormatContext *s);
56
57 #ifdef DEBUG
58 static void print_tag(const char *str, unsigned int tag, int size)
59 {
60 printf("%s: tag=%c%c%c%c size=0x%x\n",
61 str, tag & 0xff,
62 (tag >> 8) & 0xff,
63 (tag >> 16) & 0xff,
64 (tag >> 24) & 0xff,
65 size);
66 }
67 #endif
68
69 static int get_riff(AVIContext *avi, ByteIOContext *pb)
70 {
71 uint32_t tag;
72 /* check RIFF header */
73 tag = get_le32(pb);
74
75 if (tag != MKTAG('R', 'I', 'F', 'F'))
76 return -1;
77 avi->riff_end = get_le32(pb); /* RIFF chunk size */
78 avi->riff_end += url_ftell(pb); /* RIFF chunk end */
79 tag = get_le32(pb);
80 if (tag != MKTAG('A', 'V', 'I', ' ') && tag != MKTAG('A', 'V', 'I', 'X'))
81 return -1;
82
83 return 0;
84 }
85
86 static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
87 {
88 AVIContext *avi = s->priv_data;
89 ByteIOContext *pb = &s->pb;
90 uint32_t tag, tag1, handler;
91 int codec_type, stream_index, frame_period, bit_rate, scale, rate;
92 unsigned int size, nb_frames;
93 int i, n;
94 AVStream *st;
95 AVIStream *ast;
96 int xan_video = 0; /* hack to support Xan A/V */
97
98 if (get_riff(avi, pb) < 0)
99 return -1;
100
101 /* first list tag */
102 stream_index = -1;
103 codec_type = -1;
104 frame_period = 0;
105 for(;;) {
106 if (url_feof(pb))
107 goto fail;
108 tag = get_le32(pb);
109 size = get_le32(pb);
110 #ifdef DEBUG
111 print_tag("tag", tag, size);
112 #endif
113
114 switch(tag) {
115 case MKTAG('L', 'I', 'S', 'T'):
116 /* ignored, except when start of video packets */
117 tag1 = get_le32(pb);
118 #ifdef DEBUG
119 print_tag("list", tag1, 0);
120 #endif
121 if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
122 avi->movi_list = url_ftell(pb) - 4;
123 avi->movi_end = avi->movi_list + size;
124 #ifdef DEBUG
125 printf("movi end=%Lx\n", avi->movi_end);
126 #endif
127 goto end_of_header;
128 }
129 break;
130 case MKTAG('a', 'v', 'i', 'h'):
131 /* avi header */
132 /* using frame_period is bad idea */
133 frame_period = get_le32(pb);
134 bit_rate = get_le32(pb) * 8;
135 url_fskip(pb, 4 * 4);
136 n = get_le32(pb);
137 for(i=0;i<n;i++) {
138 AVIStream *ast;
139 st = av_new_stream(s, i);
140 if (!st)
141 goto fail;
142
143 ast = av_mallocz(sizeof(AVIStream));
144 if (!ast)
145 goto fail;
146 st->priv_data = ast;
147 }
148 url_fskip(pb, size - 7 * 4);
149 break;
150 case MKTAG('s', 't', 'r', 'h'):
151 /* stream header */
152 stream_index++;
153 tag1 = get_le32(pb);
154 handler = get_le32(pb); /* codec tag */
155 #ifdef DEBUG
156 print_tag("strh", tag1, -1);
157 #endif
158 switch(tag1) {
159 case MKTAG('i', 'a', 'v', 's'):
160 case MKTAG('i', 'v', 'a', 's'):
161 /*
162 * After some consideration -- I don't think we
163 * have to support anything but DV in a type1 AVIs.
164 */
165 if (s->nb_streams != 1)
166 goto fail;
167
168 if (handler != MKTAG('d', 'v', 's', 'd') &&
169 handler != MKTAG('d', 'v', 'h', 'd') &&
170 handler != MKTAG('d', 'v', 's', 'l'))
171 goto fail;
172
173 av_freep(&s->streams[0]->codec.extradata);
174 av_freep(&s->streams[0]);
175 s->nb_streams = 0;
176 avi->dv_demux = dv_init_demux(s);
177 if (!avi->dv_demux)
178 goto fail;
179 stream_index = s->nb_streams - 1;
180 url_fskip(pb, size - 8);
181 break;
182 case MKTAG('v', 'i', 'd', 's'):
183 codec_type = CODEC_TYPE_VIDEO;
184
185 if (stream_index >= s->nb_streams) {
186 url_fskip(pb, size - 8);
187 break;
188 }
189
190 st = s->streams[stream_index];
191 ast = st->priv_data;
192 st->codec.stream_codec_tag= handler;
193
194 get_le32(pb); /* flags */
195 get_le16(pb); /* priority */
196 get_le16(pb); /* language */
197 get_le32(pb); /* XXX: initial frame ? */
198 scale = get_le32(pb); /* scale */
199 rate = get_le32(pb); /* rate */
200
201 if(scale && rate){
202 }else if(frame_period){
203 rate = 1000000;
204 scale = frame_period;
205 }else{
206 rate = 25;
207 scale = 1;
208 }
209 ast->rate = rate;
210 ast->scale = scale;
211 av_set_pts_info(st, 64, scale, rate);
212 st->codec.frame_rate = rate;
213 st->codec.frame_rate_base = scale;
214 get_le32(pb); /* start */
215 nb_frames = get_le32(pb);
216 st->start_time = 0;
217 st->duration = av_rescale(nb_frames,
218 st->codec.frame_rate_base * AV_TIME_BASE,
219 st->codec.frame_rate);
220 url_fskip(pb, size - 9 * 4);
221 break;
222 case MKTAG('a', 'u', 'd', 's'):
223 {
224 unsigned int length;
225
226 codec_type = CODEC_TYPE_AUDIO;
227
228 if (stream_index >= s->nb_streams) {
229 url_fskip(pb, size - 8);
230 break;
231 }
232 st = s->streams[stream_index];
233 ast = st->priv_data;
234
235 get_le32(pb); /* flags */
236 get_le16(pb); /* priority */
237 get_le16(pb); /* language */
238 get_le32(pb); /* initial frame */
239 ast->scale = get_le32(pb); /* scale */
240 ast->rate = get_le32(pb);
241 av_set_pts_info(st, 64, ast->scale, ast->rate);
242 ast->start= get_le32(pb); /* start */
243 length = get_le32(pb); /* length, in samples or bytes */
244 get_le32(pb); /* buffer size */
245 get_le32(pb); /* quality */
246 ast->sample_size = get_le32(pb); /* sample ssize */
247 //av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d\n", ast->scale, ast->rate, ast->sample_size, ast->start);
248 st->start_time = 0;
249 if (ast->rate != 0)
250 st->duration = (int64_t)length * AV_TIME_BASE / ast->rate;
251 url_fskip(pb, size - 12 * 4);
252 }
253 break;
254 case MKTAG('t', 'x', 't', 's'):
255 //FIXME
256 codec_type = CODEC_TYPE_DATA; //CODEC_TYPE_SUB ? FIXME
257 url_fskip(pb, size - 8);
258 break;
259 default:
260 goto fail;
261 }
262 break;
263 case MKTAG('s', 't', 'r', 'f'):
264 /* stream header */
265 if (stream_index >= s->nb_streams || avi->dv_demux) {
266 url_fskip(pb, size);
267 } else {
268 st = s->streams[stream_index];
269 switch(codec_type) {
270 case CODEC_TYPE_VIDEO:
271 get_le32(pb); /* size */
272 st->codec.width = get_le32(pb);
273 st->codec.height = get_le32(pb);
274 get_le16(pb); /* panes */
275 st->codec.bits_per_sample= get_le16(pb); /* depth */
276 tag1 = get_le32(pb);
277 get_le32(pb); /* ImageSize */
278 get_le32(pb); /* XPelsPerMeter */
279 get_le32(pb); /* YPelsPerMeter */
280 get_le32(pb); /* ClrUsed */
281 get_le32(pb); /* ClrImportant */
282
283 st->codec.extradata_size= size - 10*4;
284 st->codec.extradata= av_malloc(st->codec.extradata_size);
285 get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
286
287 if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly
288 get_byte(pb);
289
290 /* Extract palette from extradata if bpp <= 8 */
291 /* This code assumes that extradata contains only palette */
292 /* This is true for all paletted codecs implemented in ffmpeg */
293 if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) {
294 st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl));
295 #ifdef WORDS_BIGENDIAN
296 for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++)
297 st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]);
298 #else
299 memcpy(st->codec.palctrl->palette, st->codec.extradata,
300 FFMIN(st->codec.extradata_size, AVPALETTE_SIZE));
301 #endif
302 st->codec.palctrl->palette_changed = 1;
303 }
304
305 #ifdef DEBUG
306 print_tag("video", tag1, 0);
307 #endif
308 st->codec.codec_type = CODEC_TYPE_VIDEO;
309 st->codec.codec_tag = tag1;
310 st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
311 if (st->codec.codec_id == CODEC_ID_XAN_WC4)
312 xan_video = 1;
313 // url_fskip(pb, size - 5 * 4);
314 break;
315 case CODEC_TYPE_AUDIO:
316 get_wav_header(pb, &st->codec, size);
317 if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
318 url_fskip(pb, 1);
319 /* special case time: To support Xan DPCM, hardcode
320 * the format if Xxan is the video codec */
321 st->need_parsing = 1;
322 /* force parsing as several audio frames can be in
323 one packet */
324 if (xan_video)
325 st->codec.codec_id = CODEC_ID_XAN_DPCM;
326 break;
327 default:
328 st->codec.codec_type = CODEC_TYPE_DATA;
329 st->codec.codec_id= CODEC_ID_NONE;
330 st->codec.codec_tag= 0;
331 url_fskip(pb, size);
332 break;
333 }
334 }
335 break;
336 default:
337 /* skip tag */
338 size += (size & 1);
339 url_fskip(pb, size);
340 break;
341 }
342 }
343 end_of_header:
344 /* check stream number */
345 if (stream_index != s->nb_streams - 1) {
346 fail:
347 for(i=0;i<s->nb_streams;i++) {
348 av_freep(&s->streams[i]->codec.extradata);
349 av_freep(&s->streams[i]);
350 }
351 return -1;
352 }
353
354 assert(!avi->index_loaded);
355 avi_load_index(s);
356 avi->index_loaded = 1;
357
358 return 0;
359 }
360
361 static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
362 {
363 AVIContext *avi = s->priv_data;
364 ByteIOContext *pb = &s->pb;
365 int n, d[8], size, i;
366 void* dstr;
367
368 memset(d, -1, sizeof(int)*8);
369
370 if (avi->dv_demux) {
371 size = dv_get_packet(avi->dv_demux, pkt);
372 if (size >= 0)
373 return size;
374 }
375
376 for(i=url_ftell(pb); !url_feof(pb); i++) {
377 int j;
378
379 if (i >= avi->movi_end) { /* Let's see if it's an OpenDML AVI */
380 uint32_t tag, size, tag2;
381 url_fskip(pb, avi->riff_end - url_ftell(pb));
382 if (get_riff(avi, pb) < 0)
383 return -1;
384
385 tag = get_le32(pb);
386 size = get_le32(pb);
387 tag2 = get_le32(pb);
388 if (tag == MKTAG('L','I','S','T') && tag2 == MKTAG('m','o','v','i'))
389 avi->movi_end = url_ftell(pb) + size - 4;
390 else
391 return -1;
392 }
393
394 for(j=0; j<7; j++)
395 d[j]= d[j+1];
396 d[7]= get_byte(pb);
397
398 size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
399
400 //parse ix##
401 n= (d[2] - '0') * 10 + (d[3] - '0');
402 if( d[2] >= '0' && d[2] <= '9'
403 && d[3] >= '0' && d[3] <= '9'
404 && d[0] == 'i' && d[1] == 'x'
405 && n < s->nb_streams
406 && i + size <= avi->movi_end){
407
408 url_fskip(pb, size);
409 }
410
411 //parse ##dc/##wb
412 n= (d[0] - '0') * 10 + (d[1] - '0');
413 if( d[0] >= '0' && d[0] <= '9'
414 && d[1] >= '0' && d[1] <= '9'
415 && ((d[2] == 'd' && d[3] == 'c') ||
416 (d[2] == 'w' && d[3] == 'b') ||
417 (d[2] == 'd' && d[3] == 'b') ||
418 (d[2] == '_' && d[3] == '_'))
419 && n < s->nb_streams
420 && i + size <= avi->movi_end) {
421
422 av_new_packet(pkt, size);
423 get_buffer(pb, pkt->data, size);
424 if (size & 1) {
425 get_byte(pb);
426 size++;
427 }
428
429 if (avi->dv_demux) {
430 dstr = pkt->destruct;
431 size = dv_produce_packet(avi->dv_demux, pkt,
432 pkt->data, pkt->size);
433 pkt->destruct = dstr;
434 pkt->flags |= PKT_FLAG_KEY;
435 } else {
436 AVStream *st;
437 AVIStream *ast;
438 st = s->streams[n];
439 ast = st->priv_data;
440
441 /* XXX: how to handle B frames in avi ? */
442 pkt->dts = ast->frame_offset;
443 // pkt->dts += ast->start;
444 if(ast->sample_size)
445 pkt->dts /= ast->sample_size;
446 //av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d %d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, AV_TIME_BASE, n, size);
447 pkt->stream_index = n;
448 /* FIXME: We really should read index for that */
449 if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
450 if (ast->frame_offset < ast->nb_index_entries) {
451 if (ast->index_entries[ast->frame_offset].flags & AVIIF_INDEX)
452 pkt->flags |= PKT_FLAG_KEY;
453 } else {
454 /* if no index, better to say that all frames
455 are key frames */
456 pkt->flags |= PKT_FLAG_KEY;
457 }
458 } else {
459 pkt->flags |= PKT_FLAG_KEY;
460 }
461 if(ast->sample_size)
462 ast->frame_offset += pkt->size;
463 else
464 ast->frame_offset++;
465 }
466 return size;
467 }
468 }
469 return -1;
470 }
471
472 /* XXX: we make the implicit supposition that the position are sorted
473 for each stream */
474 static int avi_read_idx1(AVFormatContext *s, int size)
475 {
476 ByteIOContext *pb = &s->pb;
477 int nb_index_entries, i;
478 AVStream *st;
479 AVIStream *ast;
480 AVIIndexEntry *ie, *entries;
481 unsigned int index, tag, flags, pos, len;
482
483 nb_index_entries = size / 16;
484 if (nb_index_entries <= 0)
485 return -1;
486
487 /* read the entries and sort them in each stream component */
488 for(i = 0; i < nb_index_entries; i++) {
489 tag = get_le32(pb);
490 flags = get_le32(pb);
491 pos = get_le32(pb);
492 len = get_le32(pb);
493 #if defined(DEBUG_SEEK) && 0
494 printf("%d: tag=0x%x flags=0x%x pos=0x%x len=%d\n",
495 i, tag, flags, pos, len);
496 #endif
497 index = ((tag & 0xff) - '0') * 10;
498 index += ((tag >> 8) & 0xff) - '0';
499 if (index >= s->nb_streams)
500 continue;
501 st = s->streams[index];
502 ast = st->priv_data;
503
504 entries = av_fast_realloc(ast->index_entries,
505 &ast->index_entries_allocated_size,
506 (ast->nb_index_entries + 1) *
507 sizeof(AVIIndexEntry));
508 if (entries) {
509 ast->index_entries = entries;
510 ie = &entries[ast->nb_index_entries++];
511 ie->flags = flags;
512 ie->pos = pos;
513 ie->cum_len = ast->cum_len;
514 ast->cum_len += len;
515 }
516 }
517 return 0;
518 }
519
520 static int avi_load_index(AVFormatContext *s)
521 {
522 AVIContext *avi = s->priv_data;
523 ByteIOContext *pb = &s->pb;
524 uint32_t tag, size;
525 offset_t pos= url_ftell(pb);
526
527 url_fseek(pb, avi->movi_end, SEEK_SET);
528 #ifdef DEBUG_SEEK
529 printf("movi_end=0x%llx\n", avi->movi_end);
530 #endif
531 for(;;) {
532 if (url_feof(pb))
533 break;
534 tag = get_le32(pb);
535 size = get_le32(pb);
536 #ifdef DEBUG_SEEK
537 printf("tag=%c%c%c%c size=0x%x\n",
538 tag & 0xff,
539 (tag >> 8) & 0xff,
540 (tag >> 16) & 0xff,
541 (tag >> 24) & 0xff,
542 size);
543 #endif
544 switch(tag) {
545 case MKTAG('i', 'd', 'x', '1'):
546 if (avi_read_idx1(s, size) < 0)
547 goto skip;
548 else
549 goto the_end;
550 break;
551 default:
552 skip:
553 size += (size & 1);
554 url_fskip(pb, size);
555 break;
556 }
557 }
558 the_end:
559 url_fseek(pb, pos, SEEK_SET);
560 return 0;
561 }
562
563 /* return the index entry whose position is immediately >= 'wanted_pos' */
564 static int locate_frame_in_index(AVIIndexEntry *entries,
565 int nb_entries, int wanted_pos)
566 {
567 int a, b, m, pos;
568
569 a = 0;
570 b = nb_entries - 1;
571 while (a <= b) {
572 m = (a + b) >> 1;
573 pos = entries[m].pos;
574 if (pos == wanted_pos)
575 goto found;
576 else if (pos > wanted_pos) {
577 b = m - 1;
578 } else {
579 a = m + 1;
580 }
581 }
582 m = a;
583 if (m > 0)
584 m--;
585 found:
586 return m;
587 }
588
589 static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp)
590 {
591 AVIContext *avi = s->priv_data;
592 AVStream *st;
593 AVIStream *ast;
594 int frame_number, i;
595 int64_t pos;
596
597 if (!avi->index_loaded) {
598 /* we only load the index on demand */
599 avi_load_index(s);
600 avi->index_loaded = 1;
601 }
602 if (stream_index < 0) {
603 for(i = 0; i < s->nb_streams; i++) {
604 st = s->streams[i];
605 if (st->codec.codec_type == CODEC_TYPE_VIDEO)
606 goto found;
607 }
608 return -1;
609 found:
610 stream_index = i;
611 }
612
613 st = s->streams[stream_index];
614 if (st->codec.codec_type != CODEC_TYPE_VIDEO)
615 return -1;
616 ast = st->priv_data;
617 /* compute the frame number */
618 frame_number = timestamp;
619 #ifdef DEBUG_SEEK
620 printf("timestamp=%0.3f nb_indexes=%d frame_number=%d\n",
621 (double)timestamp / AV_TIME_BASE,
622 ast->nb_index_entries, frame_number);
623 #endif
624 /* find a closest key frame before */
625 if (frame_number >= ast->nb_index_entries)
626 return -1;
627 while (frame_number >= 0 &&
628 !(ast->index_entries[frame_number].flags & AVIIF_INDEX))
629 frame_number--;
630 if (frame_number < 0)
631 return -1;
632 ast->new_frame_offset = frame_number;
633
634 /* find the position */
635 pos = ast->index_entries[frame_number].pos;
636
637 #ifdef DEBUG_SEEK
638 printf("key_frame_number=%d pos=0x%llx\n",
639 frame_number, pos);
640 #endif
641
642 /* update the frame counters for all the other stream by looking
643 at the positions just after the one found */
644 for(i = 0; i < s->nb_streams; i++) {
645 int j;
646 if (i != stream_index) {
647 st = s->streams[i];
648 ast = st->priv_data;
649 if (ast->nb_index_entries <= 0)
650 return -1;
651 j = locate_frame_in_index(ast->index_entries,
652 ast->nb_index_entries,
653 pos);
654 /* get next frame */
655 if ((j + 1) < ast->nb_index_entries)
656 j++;
657 /* extract the current frame number */
658 if (ast->sample_size==0)
659 ast->new_frame_offset = j;
660 else
661 ast->new_frame_offset = ast->index_entries[j].cum_len;
662 }
663 }
664
665 /* everything is OK now. We can update the frame offsets */
666 for(i = 0; i < s->nb_streams; i++) {
667 st = s->streams[i];
668 ast = st->priv_data;
669 ast->frame_offset = ast->new_frame_offset;
670 #ifdef DEBUG_SEEK
671 printf("%d: frame_offset=%d\n", i,
672 ast->frame_offset);
673 #endif
674 }
675 /* do the seek */
676 pos += avi->movi_list;
677 url_fseek(&s->pb, pos, SEEK_SET);
678 return 0;
679 }
680
681 static int avi_read_close(AVFormatContext *s)
682 {
683 int i;
684 AVIContext *avi = s->priv_data;
685
686 for(i=0;i<s->nb_streams;i++) {
687 AVStream *st = s->streams[i];
688 AVIStream *ast = st->priv_data;
689 if(ast){
690 av_free(ast->index_entries);
691 av_free(ast);
692 }
693 av_free(st->codec.extradata);
694 av_free(st->codec.palctrl);
695 }
696
697 if (avi->dv_demux)
698 av_free(avi->dv_demux);
699
700 return 0;
701 }
702
703 static int avi_probe(AVProbeData *p)
704 {
705 /* check file header */
706 if (p->buf_size <= 32)
707 return 0;
708 if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
709 p->buf[2] == 'F' && p->buf[3] == 'F' &&
710 p->buf[8] == 'A' && p->buf[9] == 'V' &&
711 p->buf[10] == 'I' && p->buf[11] == ' ')
712 return AVPROBE_SCORE_MAX;
713 else
714 return 0;
715 }
716
717 static AVInputFormat avi_iformat = {
718 "avi",
719 "avi format",
720 sizeof(AVIContext),
721 avi_probe,
722 avi_read_header,
723 avi_read_packet,
724 avi_read_close,
725 avi_read_seek,
726 };
727
728 int avidec_init(void)
729 {
730 av_register_input_format(&avi_iformat);
731 return 0;
732 }