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.

703 lines
22KB

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