diff options
author | Johns <johns98@gmx.net> | 2012-02-21 22:24:28 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2012-02-21 22:36:10 +0100 |
commit | 2f869884baa4f7487196fc73922437effa7c5d71 (patch) | |
tree | 9350f679049f065660a274a5248c27560715f638 | |
parent | 5d8dea1b6b9e15048f425f13b349e785a494cdb3 (diff) | |
download | vdr-plugin-softhddevice-2f869884baa4f7487196fc73922437effa7c5d71.tar.gz vdr-plugin-softhddevice-2f869884baa4f7487196fc73922437effa7c5d71.tar.bz2 |
Support downmix of AC-3 to stero.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | README.txt | 5 | ||||
-rw-r--r-- | codec.c | 21 | ||||
-rw-r--r-- | softhddevice.cpp | 12 |
4 files changed, 36 insertions, 3 deletions
@@ -1,6 +1,7 @@ User johns Date: + Support downmix of AC-3 to stero. New audio PES packet parser. Fix bug: Grabbing a JPG image fails while suspended. Add support for hot keys. @@ -139,12 +139,17 @@ Setup: /etc/vdr/setup.conf softhddevice.AudioDelay = 0 +n or -n ms + delay audio or delay video softhddevice.AudioPassthrough = 0 0 = none, 1 = AC-3 for AC-3 the pass-through device is used. + softhddevice.AudioDownmix = 0 + 0 = none, 1 = downmix + downmix AC-3 to stero. + softhddevice.AutoCrop.Interval = 0 0 disables auto-crop n each 'n' frames auto-crop is checked. @@ -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; diff --git a/softhddevice.cpp b/softhddevice.cpp index 962d8d1..5b9c1e7 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -38,6 +38,7 @@ extern "C" #include "video.h" extern void AudioPoller(void); extern void CodecSetAudioPassthrough(int); + extern void CodecSetAudioDownmix(int); } ////////////////////////////////////////////////////////////////////////////// @@ -84,6 +85,7 @@ static int ConfigVideoScaling[RESOLUTIONS]; static int ConfigVideoAudioDelay; ///< config audio delay static int ConfigAudioPassthrough; ///< config audio pass-through +static int ConfigAudioDownmix; ///< config audio downmix static int ConfigAutoCropInterval; ///< auto crop detection interval static int ConfigAutoCropDelay; ///< auto crop detection delay @@ -414,6 +416,7 @@ class cMenuSetupSoft:public cMenuSetupPage int Sharpen[RESOLUTIONS]; int AudioDelay; int AudioPassthrough; + int AudioDownmix; int AutoCropInterval; int AutoCropDelay; int AutoCropTolerance; @@ -511,6 +514,9 @@ cMenuSetupSoft::cMenuSetupSoft(void) AudioPassthrough = ConfigAudioPassthrough; Add(new cMenuEditStraItem(tr("Audio pass-through"), &AudioPassthrough, 2, passthrough)); + AudioDownmix = ConfigAudioDownmix; + Add(new cMenuEditBoolItem(tr("Enable AC-3 downmix"), &AudioDownmix, + trVDR("no"), trVDR("yes"))); // // auto-crop // @@ -581,6 +587,8 @@ void cMenuSetupSoft::Store(void) VideoSetAudioDelay(ConfigVideoAudioDelay); SetupStore("AudioPassthrough", ConfigAudioPassthrough = AudioPassthrough); CodecSetAudioPassthrough(ConfigAudioPassthrough); + SetupStore("AudioDownmix", ConfigAudioDownmix = AudioDownmix); + CodecSetAudioDownmix(ConfigAudioDownmix); SetupStore("AutoCrop.Interval", ConfigAutoCropInterval = AutoCropInterval); SetupStore("AutoCrop.Delay", ConfigAutoCropDelay = AutoCropDelay); @@ -1527,6 +1535,10 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value) CodecSetAudioPassthrough(ConfigAudioPassthrough = atoi(value)); return true; } + if (!strcmp(name, "AudioDownmix")) { + CodecSetAudioDownmix(ConfigAudioDownmix = atoi(value)); + return true; + } if (!strcmp(name, "AutoCrop.Interval")) { VideoSetAutoCrop(ConfigAutoCropInterval = |