aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-26 12:44:29 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-26 12:44:29 +0200
commitf5a0c205d91d049a663f704dda606a5562055efb (patch)
tree307a3a4a025dee98bd9fd7578cf48f01660c331e
parent8d679bc7e665d23ffabee93554ee90212b7a7c20 (diff)
parentbf9856250584228678963ce8f11c54f85005d783 (diff)
downloadffmpeg-f5a0c205d91d049a663f704dda606a5562055efb.tar.gz
Merge commit 'bf9856250584228678963ce8f11c54f85005d783'
* commit 'bf9856250584228678963ce8f11c54f85005d783': mov: Refactor codec id selection in mov_codec_id Conflicts: libavformat/mov.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/mov.c56
1 files changed, 34 insertions, 22 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 44b7f9b695..bd43ba8d46 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1238,6 +1238,39 @@ enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags)
return ff_get_pcm_codec_id(bps, flags & 1, flags & 2, flags & 4 ? -1 : 0);
}
+static int mov_codec_id(AVStream *st, uint32_t format)
+{
+ int id = ff_codec_get_id(ff_codec_movaudio_tags, format);
+
+ if (id <= 0 &&
+ ((format & 0xFFFF) == 'm' + ('s' << 8) ||
+ (format & 0xFFFF) == 'T' + ('S' << 8)))
+ id = ff_codec_get_id(ff_codec_wav_tags, av_bswap32(format) & 0xFFFF);
+
+ if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) {
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ } else if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO &&
+ /* skip old asf mpeg4 tag */
+ format && format != MKTAG('m','p','4','s')) {
+ id = ff_codec_get_id(ff_codec_movvideo_tags, format);
+ if (id <= 0)
+ id = ff_codec_get_id(ff_codec_bmp_tags, format);
+ if (id > 0)
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ else if (st->codec->codec_type == AVMEDIA_TYPE_DATA ||
+ (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
+ st->codec->codec_id == AV_CODEC_ID_NONE)) {
+ id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
+ if (id > 0)
+ st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ }
+ }
+
+ st->codec->codec_tag = format;
+
+ return id;
+}
+
int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
{
AVStream *st;
@@ -1287,28 +1320,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
sc->pseudo_stream_id = st->codec->codec_tag ? -1 : pseudo_stream_id;
sc->dref_id= dref_id;
- st->codec->codec_tag = format;
- id = ff_codec_get_id(ff_codec_movaudio_tags, format);
- if (id<=0 && ((format&0xFFFF) == 'm'+('s'<<8) || (format&0xFFFF) == 'T'+('S'<<8)))
- id = ff_codec_get_id(ff_codec_wav_tags, av_bswap32(format)&0xFFFF);
-
- if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO && id > 0) {
- st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- } else if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO && /* do not overwrite codec type */
- format && format != MKTAG('m','p','4','s')) { /* skip old asf mpeg4 tag */
- id = ff_codec_get_id(ff_codec_movvideo_tags, format);
- if (id <= 0)
- id = ff_codec_get_id(ff_codec_bmp_tags, format);
- if (id > 0)
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- else if (st->codec->codec_type == AVMEDIA_TYPE_DATA ||
- (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
- st->codec->codec_id == AV_CODEC_ID_NONE)){
- id = ff_codec_get_id(ff_codec_movsubtitle_tags, format);
- if (id > 0)
- st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
- }
- }
+ id = mov_codec_id(st, format);
av_dlog(c->fc, "size=%"PRId64" 4CC= %c%c%c%c codec_type=%d\n", size,
(format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,