summaryrefslogtreecommitdiff
path: root/codec.c
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-02-21 22:24:28 +0100
committerJohns <johns98@gmx.net>2012-02-21 22:36:10 +0100
commit2f869884baa4f7487196fc73922437effa7c5d71 (patch)
tree9350f679049f065660a274a5248c27560715f638 /codec.c
parent5d8dea1b6b9e15048f425f13b349e785a494cdb3 (diff)
downloadvdr-plugin-softhddevice-2f869884baa4f7487196fc73922437effa7c5d71.tar.gz
vdr-plugin-softhddevice-2f869884baa4f7487196fc73922437effa7c5d71.tar.bz2
Support downmix of AC-3 to stero.
Diffstat (limited to 'codec.c')
-rw-r--r--codec.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/codec.c b/codec.c
index 8a23207..ed9d858 100644
--- a/codec.c
+++ b/codec.c
@@ -628,6 +628,7 @@ static char CodecPassthroughAC3; ///< pass ac3 through
static const int CodecPassthroughAC3 = 0;
#endif
+static char CodecDownmix; ///< enable ac-3 downmix
/**
** Allocate a new audio decoder context.
@@ -678,6 +679,12 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name,
if (!(audio_decoder->AudioCtx = avcodec_alloc_context3(audio_codec))) {
Fatal(_("codec: can't allocate audio codec context\n"));
}
+
+ if (CodecDownmix) {
+ audio_decoder->AudioCtx->request_channels = 2;
+ audio_decoder->AudioCtx->request_channel_layout =
+ AV_CH_LAYOUT_STEREO_DOWNMIX;
+ }
pthread_mutex_lock(&CodecLockMutex);
// open codec
#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(53,5,0)
@@ -749,6 +756,16 @@ void CodecSetAudioPassthrough(int mask)
}
/**
+** Set audio downmix.
+**
+** @param onoff enable/disable downmix.
+*/
+void CodecSetAudioDownmix(int onoff)
+{
+ CodecDownmix = onoff;
+}
+
+/**
** Reorder audio frame.
**
** ffmpeg L R C Ls Rs -> alsa L R Ls Rs C
@@ -889,7 +906,6 @@ void CodecAudioDecodeOld(AudioDecoder * audio_decoder, const AVPacket * avpkt)
audio_decoder->PassthroughAC3 = CodecPassthroughAC3;
// FIXME: use swr_convert from swresample (only in ffmpeg!)
- // FIXME: tell ac3 decoder to use downmix
if (audio_decoder->ReSample) {
audio_resample_close(audio_decoder->ReSample);
audio_decoder->ReSample = NULL;
@@ -1089,7 +1105,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
int buf_sz;
buf_sz = sizeof(buf);
- l = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, (AVPacket *)avpkt);
+ l = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, (AVPacket *) avpkt);
if (l == AVERROR(EAGAIN)) {
Error(_("codec: latm\n"));
break;
@@ -1118,7 +1134,6 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
audio_decoder->PassthroughAC3 = CodecPassthroughAC3;
// FIXME: use swr_convert from swresample (only in ffmpeg!)
- // FIXME: tell ac3 decoder to use downmix
if (audio_decoder->ReSample) {
audio_resample_close(audio_decoder->ReSample);
audio_decoder->ReSample = NULL;