aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <cehoyos@ag.or.at>2011-04-14 03:14:05 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2011-04-14 03:33:10 +0200
commit939a12e25d956850613f9c6c416e12de305f444b (patch)
tree4c14fe8bbfa7efc8f3d86eb448c13a3393e10214
parent19de9d5646ad9f1a5f5951d0c15353014808aea4 (diff)
downloadffmpeg-939a12e25d956850613f9c6c416e12de305f444b.tar.gz
Fix channel order for some MLP samples.
-rw-r--r--libavcodec/mlpdec.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index a655b3d4a9..71b26af3e0 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -133,6 +133,9 @@ typedef struct MLPDecodeContext {
//! Index of the last substream to decode - further substreams are skipped.
uint8_t max_decoded_substream;
+ //! Stream needs channel reordering to comply with FFmpeg's channel order
+ uint8_t needs_reordering;
+
//! number of PCM samples contained in each frame
int access_unit_size;
//! next power of two above the number of samples in each frame
@@ -326,6 +329,8 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb)
for (substr = 0; substr < MAX_SUBSTREAMS; substr++)
m->substream[substr].restart_seen = 0;
+ m->needs_reordering = mh.channels_mlp >= 18 && mh.channels_mlp <= 20;
+
return 0;
}
@@ -436,6 +441,19 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
s->ch_assign[ch_assign] = ch;
}
+ if (m->avctx->codec_id == CODEC_ID_MLP && m->needs_reordering) {
+ if (m->avctx->channel_layout == (AV_CH_LAYOUT_2_2|AV_CH_LOW_FREQUENCY) ||
+ m->avctx->channel_layout == AV_CH_LAYOUT_5POINT0) {
+ int i = s->ch_assign[4];
+ s->ch_assign[4] = s->ch_assign[3];
+ s->ch_assign[3] = s->ch_assign[2];
+ s->ch_assign[2] = i;
+ } else if (m->avctx->channel_layout == AV_CH_LAYOUT_5POINT1) {
+ FFSWAP(int, s->ch_assign[2], s->ch_assign[4]);
+ FFSWAP(int, s->ch_assign[3], s->ch_assign[5]);
+ }
+ }
+
checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
if (checksum != get_bits(gbp, 8))