summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-03-31 04:24:53 +0200
committerwm4 <wm4@nowhere>2013-04-13 04:21:30 +0200
commit071a8f50b96758ced05e1eef3aba5ce915a56479 (patch)
treeea1541a6d08d3a9c98f515a8c9c6b8b96ff2f929
parent0d939a6847b139a29aaa21bd0b73d5fa28c6fb03 (diff)
downloadmpv-071a8f50b96758ced05e1eef3aba5ce915a56479.tar.bz2
mpv-071a8f50b96758ced05e1eef3aba5ce915a56479.tar.xz
options: add option to prevent decoder audio downmixing
Also rename --a52drc to --ad-lavc-ac3drc, and add --ad-lavc-o.
-rw-r--r--DOCS/man/en/changes.rst1
-rw-r--r--DOCS/man/en/options.rst27
-rw-r--r--audio/decode/ad_lavc.c27
-rw-r--r--core/cfg-mplayer.h5
-rw-r--r--core/defaultopts.c5
-rw-r--r--core/mplayer.c4
-rw-r--r--core/options.h7
7 files changed, 59 insertions, 17 deletions
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst
index 1e5bb74a2c..20f6be553a 100644
--- a/DOCS/man/en/changes.rst
+++ b/DOCS/man/en/changes.rst
@@ -124,6 +124,7 @@ Command line switches
-afm hwac3 --ad=spdif:ac3,spdif:dts
-x W, -y H --geometry=WxH + --no-keepaspect
-xy W --autofit=W
+ -a52drc level --ad-lavc-ac3drc=level
=================================== ===================================
*NOTE*: ``-opt val`` becomes ``--opt=val``.
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 5c71dd977a..03f09b2efc 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1,11 +1,3 @@
---a52drc=<level>
- Select the Dynamic Range Compression level for AC-3 audio streams. <level>
- is a float value ranging from 0 to 1, where 0 means no compression and 1
- (which is the default) means full compression (make loud passages more
- silent and vice versa). Values up to 2 are also accepted, but are purely
- experimental. This option only shows an effect if the AC-3 stream contains
- the required range compression information.
-
--abs=<value>
(``--ao=oss`` only) (OBSOLETE)
Override audio driver/card buffer size detection.
@@ -37,6 +29,25 @@
``--ad=help``
List all available decoders.
+--ad-lavc-ac3drc=<level>
+ Select the Dynamic Range Compression level for AC-3 audio streams. <level>
+ is a float value ranging from 0 to 1, where 0 means no compression and 1
+ (which is the default) means full compression (make loud passages more
+ silent and vice versa). Values up to 2 are also accepted, but are purely
+ experimental. This option only shows an effect if the AC-3 stream contains
+ the required range compression information.
+
+--ad-lavc-downmix=<yes|no>
+ Whether to request audio channel downmixing from the decoder (default: yes).
+ Some decoders, like AC-3, AAC and DTS, can remix audio on decoding. The
+ requested number of output channels is set with the ``--channels`` option.
+ Useful for playing surround audio on a stereo system.
+
+--ad-lavc-o=<key>=<value>[,<key>=<value>[,...]]
+ Pass AVOptions to libavcodec decoder. Note, a patch to make the o=
+ unneeded and pass all unknown options through the AVOption system is
+ welcome. A full list of AVOptions can be found in the FFmpeg manual.
+
--af=<filter1[=parameter1:parameter2:...],filter2,...>
Specify a list of audio filters to apply to the audio stream. See
`audio_filters` for details and descriptions of the available filters.
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index b7dec6bc71..5c43c68d8a 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -32,6 +32,7 @@
#include "core/codecs.h"
#include "core/mp_msg.h"
#include "core/options.h"
+#include "core/av_opts.h"
#include "ad_internal.h"
#include "audio/reorder_ch.h"
@@ -52,6 +53,15 @@ struct priv {
int previous_data_left; // input demuxer packet data
};
+#define OPT_BASE_STRUCT struct MPOpts
+
+const m_option_t ad_lavc_decode_opts_conf[] = {
+ OPT_FLOATRANGE("ac3drc", ad_lavc_param.ac3drc, 0, 0, 2),
+ OPT_FLAG("downmix", ad_lavc_param.downmix, 0),
+ OPT_STRING("o", ad_lavc_param.avopt, 0),
+ {0}
+};
+
struct pcm_map
{
int tag;
@@ -190,7 +200,8 @@ static void set_from_wf(AVCodecContext *avctx, WAVEFORMATEX *wf)
static int init(sh_audio_t *sh_audio, const char *decoder)
{
- struct MPOpts *opts = sh_audio->opts;
+ struct MPOpts *mpopts = sh_audio->opts;
+ struct ad_lavc_param *opts = &mpopts->ad_lavc_param;
AVCodecContext *lavc_context;
AVCodec *lavc_codec;
@@ -216,12 +227,22 @@ static int init(sh_audio_t *sh_audio, const char *decoder)
lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
lavc_context->codec_id = lavc_codec->id;
- lavc_context->request_channels = opts->audio_output_channels;
+ if (opts->downmix)
+ lavc_context->request_channels = mpopts->audio_output_channels;
// Always try to set - option only exists for AC3 at the moment
- av_opt_set_double(lavc_context, "drc_scale", opts->drc_level,
+ av_opt_set_double(lavc_context, "drc_scale", opts->ac3drc,
AV_OPT_SEARCH_CHILDREN);
+ if (opts->avopt) {
+ if (parse_avopts(lavc_context, opts->avopt) < 0) {
+ mp_msg(MSGT_DECVIDEO, MSGL_ERR,
+ "ad_lavc: setting AVOptions '%s' failed.\n", opts->avopt);
+ uninit(sh_audio);
+ return 0;
+ }
+ }
+
lavc_context->codec_tag = sh_audio->format;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->i_bps * 8;
diff --git a/core/cfg-mplayer.h b/core/cfg-mplayer.h
index 56e606ff8e..6e776f6598 100644
--- a/core/cfg-mplayer.h
+++ b/core/cfg-mplayer.h
@@ -276,6 +276,7 @@ const m_option_t msgl_config[]={
};
extern const m_option_t lavc_decode_opts_conf[];
+extern const m_option_t ad_lavc_decode_opts_conf[];
#define OPT_BASE_STRUCT struct MPOpts
@@ -424,8 +425,6 @@ const m_option_t common_opts[] = {
// ignore header-specified delay (dwStart)
OPT_FLAG("ignore-start", ignore_start, 0),
- OPT_FLOATRANGE("a52drc", drc_level, 0, 0, 2),
-
// ------------------------- codec/vfilter options --------------------
// MP3-only: select stereo/left/right
@@ -466,6 +465,8 @@ const m_option_t common_opts[] = {
{"lavdopts", (void *) lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
{"lavfdopts", (void *) lavfdopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
+
+ {"ad-lavc", (void *) ad_lavc_decode_opts_conf, CONF_TYPE_SUBCONFIG},
// ------------------------- subtitles options --------------------
OPT_STRINGLIST("sub", sub_name, 0),
diff --git a/core/defaultopts.c b/core/defaultopts.c
index 71ce2ed812..75a3b8d226 100644
--- a/core/defaultopts.c
+++ b/core/defaultopts.c
@@ -74,7 +74,6 @@ void set_default_mplayer_options(struct MPOpts *opts)
.audio_output_channels = 2,
.audio_output_format = -1, // AF_FORMAT_UNKNOWN
.playback_speed = 1.,
- .drc_level = 1.,
.movie_aspect = -1.,
.sub_auto = 1,
.osd_bar_visible = 1,
@@ -90,6 +89,10 @@ void set_default_mplayer_options(struct MPOpts *opts)
.workaround_bugs = 1, // autodetect
.error_concealment = 3,
},
+ .ad_lavc_param = {
+ .ac3drc = 1.,
+ .downmix = 1,
+ },
.input = {
.key_fifo_size = 7,
.ar_delay = 100,
diff --git a/core/mplayer.c b/core/mplayer.c
index 7023b6f8f8..64c8e9555d 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -1562,8 +1562,8 @@ void reinit_audio_chain(struct MPContext *mpctx)
mpctx->ao = ao_create(opts, mpctx->input);
mpctx->ao->samplerate = opts->force_srate;
mpctx->ao->format = opts->audio_output_format;
- if (mpctx->sh_audio->channels != opts->audio_output_channels &&
- opts->audio_output_channels == 2)
+ // Automatic downmix
+ if (opts->audio_output_channels == 2 && mpctx->sh_audio->channels != 2)
mpctx->ao->channels = 2;
}
ao = mpctx->ao;
diff --git a/core/options.h b/core/options.h
index 0f57381f30..e72778dbde 100644
--- a/core/options.h
+++ b/core/options.h
@@ -155,7 +155,6 @@ typedef struct MPOpts {
int force_srate;
int dtshd;
float playback_speed;
- float drc_level;
struct m_obj_settings *vf_settings;
float movie_aspect;
int flip;
@@ -204,6 +203,12 @@ typedef struct MPOpts {
char *avopt;
} lavc_param;
+ struct ad_lavc_param {
+ float ac3drc;
+ int downmix;
+ char *avopt;
+ } ad_lavc_param;
+
struct lavfdopts {
int probesize;
int probescore;