options: add option to prevent decoder audio downmixing

Also rename --a52drc to --ad-lavc-ac3drc, and add --ad-lavc-o.
This commit is contained in:
wm4 2013-03-31 04:24:53 +02:00
parent 0d939a6847
commit 071a8f50b9
7 changed files with 59 additions and 17 deletions

View File

@ -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``.

View File

@ -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.

View File

@ -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;

View File

@ -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),

View File

@ -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,

View File

@ -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;

View File

@ -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;