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.

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