annotate avidec.c @ 291:b19f70a6d60f libavformat

1/0 fix by (Tim Allen <tim at proximity dot com dot au>)
author michael
date Tue, 28 Oct 2003 10:55:15 +0000
parents f174d9c00bce
children 252946de6d3f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
1 /*
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
2 * AVI decoder.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
18 */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
19 #include "avformat.h"
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 #include "avi.h"
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
21 #include "dv.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
23 //#define DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
25 typedef struct AVIIndex {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
26 unsigned char tag[4];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
27 unsigned int flags, pos, len;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
28 struct AVIIndex *next;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
29 } AVIIndex;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
30
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
31 typedef struct {
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
32 int64_t riff_end;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
33 int64_t movi_end;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
34 offset_t movi_list;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
35 AVIIndex *first, *last;
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
36 void* dv_demux;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
37 } AVIContext;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
38
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
39 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
40 static void print_tag(const char *str, unsigned int tag, int size)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
41 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
42 printf("%s: tag=%c%c%c%c size=0x%x\n",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
43 str, tag & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
44 (tag >> 8) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
45 (tag >> 16) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
46 (tag >> 24) & 0xff,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
47 size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
48 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
49 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
50
92
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
51 static int get_riff(AVIContext *avi, ByteIOContext *pb)
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
52 {
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
53 uint32_t tag;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
54 /* check RIFF header */
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
55 tag = get_le32(pb);
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
56
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
57 if (tag != MKTAG('R', 'I', 'F', 'F'))
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
58 return -1;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
59 avi->riff_end = get_le32(pb); /* RIFF chunk size */
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
60 avi->riff_end += url_ftell(pb); /* RIFF chunk end */
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
61 tag = get_le32(pb);
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
62 if (tag != MKTAG('A', 'V', 'I', ' ') && tag != MKTAG('A', 'V', 'I', 'X'))
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
63 return -1;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
64
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
65 return 0;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
66 }
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
67
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
68 static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
69 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
70 AVIContext *avi = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
71 ByteIOContext *pb = &s->pb;
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
72 uint32_t tag, tag1, handler;
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
73 int codec_type, stream_index, frame_period, bit_rate, scale, rate;
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
74 unsigned int size, nb_frames;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
75 int i, n;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
76 AVStream *st;
227
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
77 int xan_video = 0; /* hack to support Xan A/V */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
78
92
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
79 if (get_riff(avi, pb) < 0)
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
80 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
81
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
82 /* first list tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
83 stream_index = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
84 codec_type = -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
85 frame_period = 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
86 for(;;) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
87 if (url_feof(pb))
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
88 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
89 tag = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
90 size = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
91 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
92 print_tag("tag", tag, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
93 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
94
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
95 switch(tag) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
96 case MKTAG('L', 'I', 'S', 'T'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
97 /* ignored, except when start of video packets */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
98 tag1 = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
99 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
100 print_tag("list", tag1, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
101 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
102 if (tag1 == MKTAG('m', 'o', 'v', 'i')) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
103 avi->movi_end = url_ftell(pb) + size - 4;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
104 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
105 printf("movi end=%Lx\n", avi->movi_end);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
106 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
107 goto end_of_header;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
108 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
109 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
110 case MKTAG('a', 'v', 'i', 'h'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
111 /* avi header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
112 /* using frame_period is bad idea */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
113 frame_period = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
114 bit_rate = get_le32(pb) * 8;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
115 url_fskip(pb, 4 * 4);
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
116 n = get_le32(pb);
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
117 for(i=0;i<n;i++) {
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
118 st = av_new_stream(s, i);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
119 if (!st)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
120 goto fail;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
121 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
122 url_fskip(pb, size - 7 * 4);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
123 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
124 case MKTAG('s', 't', 'r', 'h'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
125 /* stream header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
126 stream_index++;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
127 tag1 = get_le32(pb);
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
128 handler = get_le32(pb); /* codec tag */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
129 switch(tag1) {
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
130 case MKTAG('i', 'a', 'v', 's'):
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
131 case MKTAG('i', 'v', 'a', 's'):
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
132 /*
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
133 * After some consideration -- I don't think we
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
134 * have to support anything but DV in a type1 AVIs.
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
135 */
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
136 if (s->nb_streams != 1)
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
137 goto fail;
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
138
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
139 if (handler != MKTAG('d', 'v', 's', 'd') &&
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
140 handler != MKTAG('d', 'v', 'h', 'd') &&
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
141 handler != MKTAG('d', 'v', 's', 'l'))
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
142 goto fail;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
143
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
144 avi->dv_demux = dv_init_demux(s, stream_index, stream_index + 1);
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
145 if (!avi->dv_demux)
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
146 goto fail;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
147 stream_index++;
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
148 case MKTAG('v', 'i', 'd', 's'):
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
149 codec_type = CODEC_TYPE_VIDEO;
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
150
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
151 if (stream_index >= s->nb_streams) {
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
152 url_fskip(pb, size - 8);
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
153 break;
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
154 }
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
155
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
156 st = s->streams[stream_index];
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
157
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
158 get_le32(pb); /* flags */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
159 get_le16(pb); /* priority */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
160 get_le16(pb); /* language */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
161 get_le32(pb); /* XXX: initial frame ? */
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
162 scale = get_le32(pb); /* scale */
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
163 rate = get_le32(pb); /* rate */
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
164
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
165 if(scale && rate){
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
166 st->codec.frame_rate = rate;
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
167 st->codec.frame_rate_base = scale;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
168 }else if(frame_period){
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
169 st->codec.frame_rate = 1000000;
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
170 st->codec.frame_rate_base = frame_period;
85
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
171 }else{
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
172 st->codec.frame_rate = 25;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
173 st->codec.frame_rate_base = 1;
25062c9b1f86 per context frame_rate_base, this should finally fix frame_rate related av sync issues
michaelni
parents: 84
diff changeset
174 }
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
175 get_le32(pb); /* start */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
176 nb_frames = get_le32(pb);
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
177 st->start_time = 0;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
178 st->duration = (double)nb_frames *
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
179 st->codec.frame_rate_base * AV_TIME_BASE /
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
180 st->codec.frame_rate;
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
181
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
182 url_fskip(pb, size - 9 * 4);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
183 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
184 case MKTAG('a', 'u', 'd', 's'):
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
185 {
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
186 unsigned int length, rate;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
187
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
188 codec_type = CODEC_TYPE_AUDIO;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
189
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
190 if (stream_index >= s->nb_streams) {
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
191 url_fskip(pb, size - 8);
188
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
192 break;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
193 }
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
194 st = s->streams[stream_index];
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
195
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
196 get_le32(pb); /* flags */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
197 get_le16(pb); /* priority */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
198 get_le16(pb); /* language */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
199 get_le32(pb); /* initial frame */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
200 get_le32(pb); /* scale */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
201 rate = get_le32(pb);
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
202 get_le32(pb); /* start */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
203 length = get_le32(pb); /* length, in samples or bytes */
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
204 st->start_time = 0;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
205 if (rate != 0)
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
206 st->duration = (int64_t)length * AV_TIME_BASE / rate;
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
207 url_fskip(pb, size - 9 * 4);
6c9d6422a2f6 update duration and start_time - add av_new_stream() usage
bellard
parents: 149
diff changeset
208 }
73
d40ddc73858a reversing not yet reversed changes from r1.7 -> r1.8 except the static/const stuff
michaelni
parents: 65
diff changeset
209 break;
d40ddc73858a reversing not yet reversed changes from r1.7 -> r1.8 except the static/const stuff
michaelni
parents: 65
diff changeset
210 default:
d40ddc73858a reversing not yet reversed changes from r1.7 -> r1.8 except the static/const stuff
michaelni
parents: 65
diff changeset
211 goto fail;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
212 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
213 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
214 case MKTAG('s', 't', 'r', 'f'):
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
215 /* stream header */
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
216 if (stream_index >= s->nb_streams || avi->dv_demux) {
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
217 url_fskip(pb, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
218 } else {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
219 st = s->streams[stream_index];
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
220 switch(codec_type) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
221 case CODEC_TYPE_VIDEO:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
222 get_le32(pb); /* size */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
223 st->codec.width = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
224 st->codec.height = get_le32(pb);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
225 get_le16(pb); /* panes */
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
226 st->codec.bits_per_sample= get_le16(pb); /* depth */
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
227 tag1 = get_le32(pb);
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
228 get_le32(pb); /* ImageSize */
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
229 get_le32(pb); /* XPelsPerMeter */
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
230 get_le32(pb); /* YPelsPerMeter */
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
231 get_le32(pb); /* ClrUsed */
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
232 get_le32(pb); /* ClrImportant */
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
233
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
234 st->codec.extradata_size= size - 10*4;
110
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
235 st->codec.extradata= av_malloc(st->codec.extradata_size);
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
236 get_buffer(pb, st->codec.extradata, st->codec.extradata_size);
76
d03c70b7b50d huffyuv encoding fixed
michaelni
parents: 75
diff changeset
237
d03c70b7b50d huffyuv encoding fixed
michaelni
parents: 75
diff changeset
238 if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly
d03c70b7b50d huffyuv encoding fixed
michaelni
parents: 75
diff changeset
239 get_byte(pb);
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
240
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
241 #ifdef DEBUG
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
242 print_tag("video", tag1, 0);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
243 #endif
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
244 st->codec.codec_type = CODEC_TYPE_VIDEO;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
245 st->codec.codec_tag = tag1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
246 st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1);
227
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
247 if (st->codec.codec_id == CODEC_ID_XAN_WC4)
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
248 xan_video = 1;
75
78bec272ce3a read BITMAPINFOHEADER extra stuff (huffyuv decoding fixed)
michaelni
parents: 73
diff changeset
249 // url_fskip(pb, size - 5 * 4);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
250 break;
73
d40ddc73858a reversing not yet reversed changes from r1.7 -> r1.8 except the static/const stuff
michaelni
parents: 65
diff changeset
251 case CODEC_TYPE_AUDIO:
84
0068a6902911 correct AUDIO strf parsing patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 82
diff changeset
252 get_wav_header(pb, &st->codec, size);
13
8a5285a0ca2f Fix for odd strf tag in Stargate SG-1 - 3x18 - Shades of Grey.avi
mmu_man
parents: 5
diff changeset
253 if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
8a5285a0ca2f Fix for odd strf tag in Stargate SG-1 - 3x18 - Shades of Grey.avi
mmu_man
parents: 5
diff changeset
254 url_fskip(pb, 1);
227
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
255 /* special case time: To support Xan DPCM, hardcode
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
256 * the format if Xxan is the video codec */
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
257 if (xan_video)
b0d2d719ae41 hacks to support Xan AVI files
tmmm
parents: 188
diff changeset
258 st->codec.codec_id = CODEC_ID_XAN_DPCM;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
259 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
260 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
261 url_fskip(pb, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
262 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
263 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
264 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
265 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
266 default:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
267 /* skip tag */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
268 size += (size & 1);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
269 url_fskip(pb, size);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
270 break;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
271 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
272 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
273 end_of_header:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
274 /* check stream number */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
275 if (stream_index != s->nb_streams - 1) {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
276 fail:
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
277 for(i=0;i<s->nb_streams;i++) {
80
michaelni
parents: 78
diff changeset
278 av_freep(&s->streams[i]->codec.extradata);
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
279 av_freep(&s->streams[i]);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
280 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
281 return -1;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
282 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
283
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
284 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
285 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
286
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
287 static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
288 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
289 AVIContext *avi = s->priv_data;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
290 ByteIOContext *pb = &s->pb;
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
291 int n, d[8], size, i;
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
292 void* dstr;
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
293
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
294 memset(d, -1, sizeof(int)*8);
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
295
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
296 if (avi->dv_demux) {
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
297 size = dv_get_packet(avi->dv_demux, pkt);
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
298 if (size >= 0)
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
299 return size;
149
f4de8f9c39bd use custom packet allocation only for DV
bellard
parents: 119
diff changeset
300 }
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
301
92
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
302 for(i=url_ftell(pb); !url_feof(pb); i++) {
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
303 int j;
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
304
92
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
305 if (i >= avi->movi_end) { /* Let's see if it's an OpenDML AVI */
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
306 uint32_t tag, size, tag2;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
307 url_fskip(pb, avi->riff_end - url_ftell(pb));
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
308 if (get_riff(avi, pb) < 0)
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
309 return -1;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
310
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
311 tag = get_le32(pb);
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
312 size = get_le32(pb);
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
313 tag2 = get_le32(pb);
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
314 if (tag == MKTAG('L','I','S','T') && tag2 == MKTAG('m','o','v','i'))
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
315 avi->movi_end = url_ftell(pb) + size - 4;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
316 else
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
317 return -1;
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
318 }
5a4b5f03d13e OpenDML AVI > 2Gb support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 91
diff changeset
319
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
320 for(j=0; j<7; j++)
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
321 d[j]= d[j+1];
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
322 d[7]= get_byte(pb);
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
323
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
324 size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
325
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
326 //parse ix##
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
327 n= (d[2] - '0') * 10 + (d[3] - '0');
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
328 if( d[2] >= '0' && d[2] <= '9'
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
329 && d[3] >= '0' && d[3] <= '9'
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
330 && d[0] == 'i' && d[1] == 'x'
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
331 && n < s->nb_streams
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
332 && i + size <= avi->movi_end){
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
333
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
334 url_fskip(pb, size);
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
335 }
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
336
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
337 //parse ##dc/##wb
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
338 n= (d[0] - '0') * 10 + (d[1] - '0');
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
339 if( d[0] >= '0' && d[0] <= '9'
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
340 && d[1] >= '0' && d[1] <= '9'
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
341 && ((d[2] == 'd' && d[3] == 'c') ||
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
342 (d[2] == 'w' && d[3] == 'b') ||
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
343 (d[2] == 'd' && d[3] == 'b') ||
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
344 (d[2] == '_' && d[3] == '_'))
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
345 && n < s->nb_streams
98
cae6ddfadf51 AVI type 1 support patch by (Roman Shaposhnick <rvs at sun dot com>)
michaelni
parents: 92
diff changeset
346 && i + size <= avi->movi_end) {
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
347
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
348 av_new_packet(pkt, size);
149
f4de8f9c39bd use custom packet allocation only for DV
bellard
parents: 119
diff changeset
349 get_buffer(pb, pkt->data, size);
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
350 if (size & 1) {
149
f4de8f9c39bd use custom packet allocation only for DV
bellard
parents: 119
diff changeset
351 get_byte(pb);
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
352 size++;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
353 }
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
354
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
355 if (avi->dv_demux) {
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
356 dstr = pkt->destruct;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
357 size = dv_produce_packet(avi->dv_demux, pkt,
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
358 pkt->data, pkt->size);
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
359 pkt->destruct = dstr;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
360 } else {
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
361 pkt->stream_index = n;
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
362 pkt->flags |= PKT_FLAG_KEY; // FIXME: We really should read
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
363 // index for that
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
364 }
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
365 return size;
82
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
366 }
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
367 }
33753bc4869e fixing parsing of opendml avis
michaelni
parents: 80
diff changeset
368 return -1;
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
369 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
370
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
371 static int avi_read_close(AVFormatContext *s)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
372 {
110
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
373 int i;
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
374 AVIContext *avi = s->priv_data;
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
375
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
376 for(i=0;i<s->nb_streams;i++) {
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
377 AVStream *st = s->streams[i];
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
378 // av_free(st->priv_data);
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
379 av_free(st->codec.extradata);
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
380 }
9fd9b0f9e9d8 memleaks
michaelni
parents: 98
diff changeset
381
262
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
382 if (avi->dv_demux)
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
383 av_free(avi->dv_demux);
f174d9c00bce * DV handling was streamlined for both muxing/demuxing and
romansh
parents: 227
diff changeset
384
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
385 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
386 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
387
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
388 static int avi_probe(AVProbeData *p)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
389 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
390 /* check file header */
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
391 if (p->buf_size <= 32)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
392 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
393 if (p->buf[0] == 'R' && p->buf[1] == 'I' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
394 p->buf[2] == 'F' && p->buf[3] == 'F' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
395 p->buf[8] == 'A' && p->buf[9] == 'V' &&
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
396 p->buf[10] == 'I' && p->buf[11] == ' ')
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
397 return AVPROBE_SCORE_MAX;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
398 else
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
399 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
400 }
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
401
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
402 static AVInputFormat avi_iformat = {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
403 "avi",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
404 "avi format",
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
405 sizeof(AVIContext),
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
406 avi_probe,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
407 avi_read_header,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
408 avi_read_packet,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
409 avi_read_close,
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
410 };
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
411
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
412 int avidec_init(void)
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
413 {
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
414 av_register_input_format(&avi_iformat);
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
415 return 0;
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
416 }