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.
This commit is contained in:
wm4 2017-04-27 00:21:17 +02:00
parent 90a1ca02a2
commit afead7a356
4 changed files with 10 additions and 12 deletions

View File

@ -1182,12 +1182,9 @@ Audio
Since mpv 0.18.1, this always controls the internal mixer (aka "softvol"). Since mpv 0.18.1, this always controls the internal mixer (aka "softvol").
``--replaygain-track=<yes|no>`` ``--replaygain=<no|track|album>``
Adjust volume gain according to the track-gain replaygain value stored Adjust volume gain according to the track-gain or album-gain replaygain
in the file metadata. value stored in the file metadata (default: no replaygain).
``--replaygain-album=<yes|no>``
Like replaygain-track, but using the album-gain value instead.
``--replaygain-preamp=<db>`` ``--replaygain-preamp=<db>``
Pre-amplification gain in dB to apply to the selected replaygain gain Pre-amplification gain in dB to apply to the selected replaygain gain

View File

@ -550,8 +550,10 @@ const m_option_t mp_opts[] = {
({"no", 0}, ({"no", 0},
{"auto", 0}, {"auto", 0},
{"yes", 1})), {"yes", 1})),
OPT_FLAG("replaygain-track", rgain_track, UPDATE_VOL), OPT_CHOICE("replaygain", rgain_mode, UPDATE_VOL,
OPT_FLAG("replaygain-album", rgain_album, UPDATE_VOL), ({"no", 0},
{"track", 1},
{"album", 2})),
OPT_FLOATRANGE("replaygain-preamp", rgain_preamp, UPDATE_VOL, -15, 15), OPT_FLOATRANGE("replaygain-preamp", rgain_preamp, UPDATE_VOL, -15, 15),
OPT_FLAG("replaygain-clip", rgain_clip, UPDATE_VOL), OPT_FLAG("replaygain-clip", rgain_clip, UPDATE_VOL),
OPT_FLOATRANGE("replaygain-fallback", rgain_fallback, UPDATE_VOL, -200, 60), OPT_FLOATRANGE("replaygain-fallback", rgain_fallback, UPDATE_VOL, -200, 60),

View File

@ -101,8 +101,7 @@ typedef struct MPOpts {
int force_vo; int force_vo;
int softvol; int softvol;
float softvol_volume; float softvol_volume;
int rgain_track; // Enable/disable track based replaygain int rgain_mode;
int rgain_album; // Enable/disable album based replaygain
float rgain_preamp; // Set replaygain pre-amplification float rgain_preamp; // Set replaygain pre-amplification
int rgain_clip; // Enable/disable clipping prevention int rgain_clip; // Enable/disable clipping prevention
float rgain_fallback; float rgain_fallback;

View File

@ -136,13 +136,13 @@ static float compute_replaygain(struct MPContext *mpctx)
float rgain = 1.0; float rgain = 1.0;
struct replaygain_data *rg = ao_c->af->replaygain_data; 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", MP_VERBOSE(mpctx, "Replaygain: Track=%f/%f Album=%f/%f\n",
rg->track_gain, rg->track_peak, rg->track_gain, rg->track_peak,
rg->album_gain, rg->album_peak); rg->album_gain, rg->album_peak);
float gain, peak; float gain, peak;
if (opts->rgain_track) { if (opts->rgain_mode == 1) {
gain = rg->track_gain; gain = rg->track_gain;
peak = rg->track_peak; peak = rg->track_peak;
} else { } else {