diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-08-10 22:52:35 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-08-10 22:52:35 +0300 |
commit | ca9065b93fefea57423c376b28de1137c641223c (patch) | |
tree | ddda0de96984e835a972ead6622329acfc0df845 /libmpdemux | |
parent | d4b8d1486a69ee5bbd96a2758f56c1bbc6242bfb (diff) | |
download | mpv-ca9065b93fefea57423c376b28de1137c641223c.tar.bz2 mpv-ca9065b93fefea57423c376b28de1137c641223c.tar.xz |
demux_lavf: don't interpret MPEG codec tags as generic tags
Don't interpret native MPEG codec tags using our generic
format-agnostic codec tag tables. MPEG may use tag 3 for MP3, whereas
the generic tables map 3 to uncompressed PCM. Make the code ignore the
codec_tag field for the "mpeg" and "mpegts" libavformat demuxers and
rely on the codec_id value provided by lavf only.
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_lavf.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 2da898bf5c..bab8186f51 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -294,8 +294,13 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) int stream_id; AVMetadataTag *lang = av_metadata_get(st->metadata, "language", NULL, 0); AVMetadataTag *title = av_metadata_get(st->metadata, "title", NULL, 0); - int g, override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists, - codec->codec_id); + // Don't use native MPEG codec tag values with our generic tag tables. + // May contain for example value 3 for MP3, which we'd map to PCM audio. + if (matches_avinputformat_name(priv, "mpeg") || + matches_avinputformat_name(priv, "mpegts")) + codec->codec_tag = 0; + int override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists, + codec->codec_id); // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag if (override_tag) codec->codec_tag = override_tag; @@ -334,7 +339,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) sh_audio->audio.dwScale = codec->block_align ? codec->block_align * 8 : 8; sh_audio->audio.dwRate = codec->bit_rate; } - g = av_gcd(sh_audio->audio.dwScale, sh_audio->audio.dwRate); + int g = av_gcd(sh_audio->audio.dwScale, sh_audio->audio.dwRate); sh_audio->audio.dwScale /= g; sh_audio->audio.dwRate /= g; // printf("sca:%d rat:%d fs:%d sr:%d ba:%d\n", sh_audio->audio.dwScale, sh_audio->audio.dwRate, codec->frame_size, codec->sample_rate, codec->block_align); |