From afead7a3566e455cd2ceec54010a95387b7b022f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Apr 2017 00:21:17 +0200 Subject: audio: merge --replaygain-track and --replaygain-album into one option This is probably better than separate options. For example, the user does not have to guess which one is applied if both options are enabled. --- DOCS/man/options.rst | 9 +++------ options/options.c | 6 ++++-- options/options.h | 3 +-- player/audio.c | 4 ++-- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 1f66b77225..cb6f62f94c 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -1182,12 +1182,9 @@ Audio Since mpv 0.18.1, this always controls the internal mixer (aka "softvol"). -``--replaygain-track=`` - Adjust volume gain according to the track-gain replaygain value stored - in the file metadata. - -``--replaygain-album=`` - Like replaygain-track, but using the album-gain value instead. +``--replaygain=`` + Adjust volume gain according to the track-gain or album-gain replaygain + value stored in the file metadata (default: no replaygain). ``--replaygain-preamp=`` Pre-amplification gain in dB to apply to the selected replaygain gain diff --git a/options/options.c b/options/options.c index 42c4828b56..1540dcbbf4 100644 --- a/options/options.c +++ b/options/options.c @@ -550,8 +550,10 @@ const m_option_t mp_opts[] = { ({"no", 0}, {"auto", 0}, {"yes", 1})), - OPT_FLAG("replaygain-track", rgain_track, UPDATE_VOL), - OPT_FLAG("replaygain-album", rgain_album, UPDATE_VOL), + OPT_CHOICE("replaygain", rgain_mode, UPDATE_VOL, + ({"no", 0}, + {"track", 1}, + {"album", 2})), OPT_FLOATRANGE("replaygain-preamp", rgain_preamp, UPDATE_VOL, -15, 15), OPT_FLAG("replaygain-clip", rgain_clip, UPDATE_VOL), OPT_FLOATRANGE("replaygain-fallback", rgain_fallback, UPDATE_VOL, -200, 60), diff --git a/options/options.h b/options/options.h index 0d288be586..bfe7d42bcf 100644 --- a/options/options.h +++ b/options/options.h @@ -101,8 +101,7 @@ typedef struct MPOpts { int force_vo; int softvol; float softvol_volume; - int rgain_track; // Enable/disable track based replaygain - int rgain_album; // Enable/disable album based replaygain + int rgain_mode; float rgain_preamp; // Set replaygain pre-amplification int rgain_clip; // Enable/disable clipping prevention float rgain_fallback; diff --git a/player/audio.c b/player/audio.c index ea013b02e2..0922db804c 100644 --- a/player/audio.c +++ b/player/audio.c @@ -136,13 +136,13 @@ static float compute_replaygain(struct MPContext *mpctx) float rgain = 1.0; struct replaygain_data *rg = ao_c->af->replaygain_data; - if ((opts->rgain_track || opts->rgain_album) && rg) { + if (opts->rgain_mode && rg) { MP_VERBOSE(mpctx, "Replaygain: Track=%f/%f Album=%f/%f\n", rg->track_gain, rg->track_peak, rg->album_gain, rg->album_peak); float gain, peak; - if (opts->rgain_track) { + if (opts->rgain_mode == 1) { gain = rg->track_gain; peak = rg->track_peak; } else { -- cgit v1.2.3