diff options
author | Anssi Hannula <anssi.hannula@iki.fi> | 2013-12-17 23:04:31 +0200 |
---|---|---|
committer | fritsch <Peter.Fruehberger@gmail.com> | 2013-12-19 18:54:24 +0100 |
commit | bc7cf68febd1f632d30c976279f506cf3aba81a9 (patch) | |
tree | 1f26086b9b4161d429bc285289b15f097579fa4e /lib | |
parent | 54c1782ceca0e6fc1176ab1f7c1077e0134dabef (diff) |
[ffmpeg] - backport - avcodec/aacdec: default to non-wide 7.1 in non-strict mode
Upstream commit e10fccf62a36e09b54ad6ea3d5fa6638f298d5ae, for
http://trac.xbmc.org/ticket/13758.
AAC specification has 7.1(wide) as a default layout for 8-channel
streams (channel config 7). However, at least Nero AAC encoder encodes
non-wide 7.1 streams using the default channel config 7, mapping the
side channels of the original audio stream to the second
AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD decodes
the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding
the incorrect streams as if they were correct (and as the encoder
intended).
FFmpeg currently decodes such files by-the-spec, i.e. after decoding the
original front pair will be in AV_CH_FRONT_x_OF_CENTER and the original
side pair will be in AV_CH_FRONT_x.
As actual intended 7.1(wide) streams are very rare while misencoded 7.1
files actually exist in the wild, default to assuming a 7.1 layout was
intended unless in strict mode.
Fixes playback of e.g. 8_Channel_ID.m4a in samples.
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffmpeg/libavcodec/aacdec.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/ffmpeg/libavcodec/aacdec.c b/lib/ffmpeg/libavcodec/aacdec.c index 7a871c4022..12dbfcfcf2 100644 --- a/lib/ffmpeg/libavcodec/aacdec.c +++ b/lib/ffmpeg/libavcodec/aacdec.c @@ -505,6 +505,25 @@ static int set_default_channel_config(AVCodecContext *avctx, } *tags = tags_per_config[channel_config]; memcpy(layout_map, aac_channel_layout_map[channel_config-1], *tags * sizeof(*layout_map)); + + /* + * AAC specification has 7.1(wide) as a default layout for 8-channel streams. + * However, at least Nero AAC encoder encodes 7.1 streams using the default + * channel config 7, mapping the side channels of the original audio stream + * to the second AAC_CHANNEL_FRONT pair in the AAC stream. Similarly, e.g. FAAD + * decodes the second AAC_CHANNEL_FRONT pair as side channels, therefore decoding + * the incorrect streams as if they were correct (and as the encoder intended). + * + * As actual intended 7.1(wide) streams are very rare, default to assuming a + * 7.1 layout was intended. + */ + if (channel_config == 7 && avctx->strict_std_compliance < FF_COMPLIANCE_STRICT) { + av_log(avctx, AV_LOG_INFO, "Assuming an incorrectly encoded 7.1 channel layout" + " instead of a spec-compliant 7.1(wide) layout, use -strict %d to decode" + " according to the specification instead.\n", FF_COMPLIANCE_STRICT); + layout_map[2][2] = AAC_CHANNEL_SIDE; + } + return 0; } |