aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-02-12 15:06:58 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2012-02-22 20:07:02 -0500
commit3798205a77ce275613098ecb48645e6029811f14 (patch)
tree41ad2274e8fe47a7546bb8ea301280090b66e2ac
parent1254022ea717fba6f189d6a66841e0ba204ed80a (diff)
downloadffmpeg-3798205a77ce275613098ecb48645e6029811f14.tar.gz
mov: set channel layout for AC-3 streams based on the 'dac3' atom info
fixes Bug 225
-rw-r--r--libavcodec/Makefile2
-rw-r--r--libavcodec/ac3_parser.c2
-rw-r--r--libavcodec/ac3dec.c2
-rw-r--r--libavcodec/ac3tab.c2
-rw-r--r--libavcodec/ac3tab.h2
-rw-r--r--libavformat/mov.c5
6 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 93ff7d4a67..a98ff5b52a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -556,7 +556,7 @@ OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o mpeg4audio.o \
flacdec.o flacdata.o flac.o \
mpegaudiodata.o
OBJS-$(CONFIG_MP3_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
-OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
+OBJS-$(CONFIG_MOV_DEMUXER) += mpeg4audio.o mpegaudiodata.o ac3tab.o
OBJS-$(CONFIG_MOV_MUXER) += mpeg4audio.o mpegaudiodata.o
OBJS-$(CONFIG_MPEGTS_MUXER) += mpegvideo.o mpeg4audio.o
OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 067b4f9879..d9ba1fd70b 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -134,7 +134,7 @@ int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
(hdr->num_blocks * 256.0));
hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on;
}
- hdr->channel_layout = ff_ac3_channel_layout_tab[hdr->channel_mode];
+ hdr->channel_layout = avpriv_ac3_channel_layout_tab[hdr->channel_mode];
if (hdr->lfe_on)
hdr->channel_layout |= AV_CH_LOW_FREQUENCY;
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index c0d7488d84..a8bc48ab6e 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1378,7 +1378,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
avctx->request_channels < s->channels) {
s->out_channels = avctx->request_channels;
s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;
- s->channel_layout = ff_ac3_channel_layout_tab[s->output_mode];
+ s->channel_layout = avpriv_ac3_channel_layout_tab[s->output_mode];
}
avctx->channels = s->out_channels;
avctx->channel_layout = s->channel_layout;
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
index 7df3d828fb..951a1014ce 100644
--- a/libavcodec/ac3tab.c
+++ b/libavcodec/ac3tab.c
@@ -84,7 +84,7 @@ const uint8_t ff_ac3_channels_tab[8] = {
/**
* Map audio coding mode (acmod) to channel layout mask.
*/
-const uint16_t ff_ac3_channel_layout_tab[8] = {
+const uint16_t avpriv_ac3_channel_layout_tab[8] = {
AV_CH_LAYOUT_STEREO,
AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO,
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index e5cd368bb7..8ed50520e6 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -33,7 +33,7 @@
extern const uint16_t ff_ac3_frame_size_tab[38][3];
extern const uint8_t ff_ac3_channels_tab[8];
-extern const uint16_t ff_ac3_channel_layout_tab[8];
+extern const uint16_t avpriv_ac3_channel_layout_tab[8];
extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
extern const uint16_t ff_ac3_sample_rate_tab[3];
diff --git a/libavformat/mov.c b/libavformat/mov.c
index c2f13b6316..b11e0bfef7 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -25,11 +25,13 @@
//#define DEBUG
//#define MOV_EXPORT_ALL_METADATA
+#include "libavutil/audioconvert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
+#include "libavcodec/ac3tab.h"
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
@@ -552,6 +554,9 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
acmod = (ac3info >> 11) & 0x7;
lfeon = (ac3info >> 10) & 0x1;
st->codec->channels = ((int[]){2,1,2,3,3,4,4,5})[acmod] + lfeon;
+ st->codec->channel_layout = avpriv_ac3_channel_layout_tab[acmod];
+ if (lfeon)
+ st->codec->channel_layout |= AV_CH_LOW_FREQUENCY;
st->codec->audio_service_type = bsmod;
if (st->codec->channels > 1 && bsmod == 0x7)
st->codec->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;