Originally committed as revision 10934 to svn://svn.ffmpeg.org/ffmpeg/trunk
Ronald S. Bultje authored on 2007/11/07 01:02:33... | ... |
@@ -188,6 +188,75 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, |
188 | 188 |
return 0; |
189 | 189 |
} |
190 | 190 |
|
191 |
+static int |
|
192 |
+ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st) |
|
193 |
+{ |
|
194 |
+ ByteIOContext *pb = &s->pb; |
|
195 |
+ unsigned int v; |
|
196 |
+ int codec_data_size, size, res = -1; |
|
197 |
+ int64_t codec_pos; |
|
198 |
+ |
|
199 |
+ codec_data_size = get_be32(pb); |
|
200 |
+ codec_pos = url_ftell(pb); |
|
201 |
+ v = get_be32(pb); |
|
202 |
+ if (v == MKTAG(0xfd, 'a', 'r', '.')) { |
|
203 |
+ /* ra type header */ |
|
204 |
+ if (rm_read_audio_stream_info(s, st, 0)) |
|
205 |
+ return -1; |
|
206 |
+ } else { |
|
207 |
+ int fps, fps2; |
|
208 |
+ if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { |
|
209 |
+ fail1: |
|
210 |
+ av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); |
|
211 |
+ goto skip; |
|
212 |
+ } |
|
213 |
+ st->codec->codec_tag = get_le32(pb); |
|
214 |
+// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); |
|
215 |
+ if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') |
|
216 |
+ && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') |
|
217 |
+ && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') |
|
218 |
+ && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) |
|
219 |
+ goto fail1; |
|
220 |
+ st->codec->width = get_be16(pb); |
|
221 |
+ st->codec->height = get_be16(pb); |
|
222 |
+ st->codec->time_base.num= 1; |
|
223 |
+ fps= get_be16(pb); |
|
224 |
+ st->codec->codec_type = CODEC_TYPE_VIDEO; |
|
225 |
+ get_be32(pb); |
|
226 |
+ fps2= get_be16(pb); |
|
227 |
+ get_be16(pb); |
|
228 |
+ |
|
229 |
+ st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); |
|
230 |
+ |
|
231 |
+ if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ |
|
232 |
+ //check is redundant as get_buffer() will catch this |
|
233 |
+ av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n"); |
|
234 |
+ return -1; |
|
235 |
+ } |
|
236 |
+ st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
237 |
+ get_buffer(pb, st->codec->extradata, st->codec->extradata_size); |
|
238 |
+ |
|
239 |
+// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); |
|
240 |
+ st->codec->time_base.den = fps * st->codec->time_base.num; |
|
241 |
+ switch(((uint8_t*)st->codec->extradata)[4]>>4){ |
|
242 |
+ case 1: st->codec->codec_id = CODEC_ID_RV10; break; |
|
243 |
+ case 2: st->codec->codec_id = CODEC_ID_RV20; break; |
|
244 |
+ case 3: st->codec->codec_id = CODEC_ID_RV30; break; |
|
245 |
+ case 4: st->codec->codec_id = CODEC_ID_RV40; break; |
|
246 |
+ default: goto fail1; |
|
247 |
+ } |
|
248 |
+ } |
|
249 |
+ |
|
250 |
+ res = 0; |
|
251 |
+skip: |
|
252 |
+ /* skip codec info */ |
|
253 |
+ size = url_ftell(pb) - codec_pos; |
|
254 |
+ url_fskip(pb, codec_data_size - size); |
|
255 |
+ |
|
256 |
+ return res; |
|
257 |
+} |
|
258 |
+ |
|
259 |
+ |
|
191 | 260 |
static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap) |
192 | 261 |
{ |
193 | 262 |
RMContext *rm = s->priv_data; |
... | ... |
@@ -205,9 +274,8 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) |
205 | 205 |
RMContext *rm = s->priv_data; |
206 | 206 |
AVStream *st; |
207 | 207 |
ByteIOContext *pb = &s->pb; |
208 |
- unsigned int tag, v; |
|
209 |
- int tag_size, size, codec_data_size, i; |
|
210 |
- int64_t codec_pos; |
|
208 |
+ unsigned int tag; |
|
209 |
+ int tag_size, i; |
|
211 | 210 |
unsigned int start_time, duration; |
212 | 211 |
char buf[128]; |
213 | 212 |
int flags = 0; |
... | ... |
@@ -279,63 +347,10 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) |
279 | 279 |
st->duration = duration; |
280 | 280 |
get_str8(pb, buf, sizeof(buf)); /* desc */ |
281 | 281 |
get_str8(pb, buf, sizeof(buf)); /* mimetype */ |
282 |
- codec_data_size = get_be32(pb); |
|
283 |
- codec_pos = url_ftell(pb); |
|
284 | 282 |
st->codec->codec_type = CODEC_TYPE_DATA; |
285 | 283 |
av_set_pts_info(st, 64, 1, 1000); |
286 |
- |
|
287 |
- v = get_be32(pb); |
|
288 |
- if (v == MKTAG(0xfd, 'a', 'r', '.')) { |
|
289 |
- /* ra type header */ |
|
290 |
- if (rm_read_audio_stream_info(s, st, 0)) |
|
291 |
- return -1; |
|
292 |
- } else { |
|
293 |
- int fps, fps2; |
|
294 |
- if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { |
|
295 |
- fail1: |
|
296 |
- av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); |
|
297 |
- goto skip; |
|
298 |
- } |
|
299 |
- st->codec->codec_tag = get_le32(pb); |
|
300 |
-// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); |
|
301 |
- if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') |
|
302 |
- && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') |
|
303 |
- && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') |
|
304 |
- && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) |
|
305 |
- goto fail1; |
|
306 |
- st->codec->width = get_be16(pb); |
|
307 |
- st->codec->height = get_be16(pb); |
|
308 |
- st->codec->time_base.num= 1; |
|
309 |
- fps= get_be16(pb); |
|
310 |
- st->codec->codec_type = CODEC_TYPE_VIDEO; |
|
311 |
- get_be32(pb); |
|
312 |
- fps2= get_be16(pb); |
|
313 |
- get_be16(pb); |
|
314 |
- |
|
315 |
- st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); |
|
316 |
- |
|
317 |
- if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ |
|
318 |
- //check is redundant as get_buffer() will catch this |
|
319 |
- av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n"); |
|
320 |
- return -1; |
|
321 |
- } |
|
322 |
- st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
323 |
- get_buffer(pb, st->codec->extradata, st->codec->extradata_size); |
|
324 |
- |
|
325 |
-// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); |
|
326 |
- st->codec->time_base.den = fps * st->codec->time_base.num; |
|
327 |
- switch(((uint8_t*)st->codec->extradata)[4]>>4){ |
|
328 |
- case 1: st->codec->codec_id = CODEC_ID_RV10; break; |
|
329 |
- case 2: st->codec->codec_id = CODEC_ID_RV20; break; |
|
330 |
- case 3: st->codec->codec_id = CODEC_ID_RV30; break; |
|
331 |
- case 4: st->codec->codec_id = CODEC_ID_RV40; break; |
|
332 |
- default: goto fail1; |
|
333 |
- } |
|
334 |
- } |
|
335 |
-skip: |
|
336 |
- /* skip codec info */ |
|
337 |
- size = url_ftell(pb) - codec_pos; |
|
338 |
- url_fskip(pb, codec_data_size - size); |
|
284 |
+ if (ff_rm_read_mdpr_codecdata(s, st) < 0) |
|
285 |
+ return -1; |
|
339 | 286 |
break; |
340 | 287 |
case MKTAG('D', 'A', 'T', 'A'): |
341 | 288 |
goto header_end; |