1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/af_sidechaincompress: fix output gain for rms(default) detection

Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Paul B Mahol 2015-11-29 19:15:43 +01:00
parent 88e498a87e
commit 337b6d3b36

View File

@ -50,6 +50,7 @@ typedef struct SidechainCompressContext {
double knee_start; double knee_start;
double knee_stop; double knee_stop;
double lin_knee_start; double lin_knee_start;
double adj_knee_start;
double compressed_knee_stop; double compressed_knee_stop;
int link; int link;
int detection; int detection;
@ -87,6 +88,7 @@ static av_cold int init(AVFilterContext *ctx)
s->thres = log(s->threshold); s->thres = log(s->threshold);
s->lin_knee_start = s->threshold / sqrt(s->knee); s->lin_knee_start = s->threshold / sqrt(s->knee);
s->adj_knee_start = s->lin_knee_start * s->lin_knee_start;
s->knee_start = log(s->lin_knee_start); s->knee_start = log(s->lin_knee_start);
s->knee_stop = log(s->threshold * sqrt(s->knee)); s->knee_stop = log(s->threshold * sqrt(s->knee));
s->compressed_knee_stop = (s->knee_stop - s->thres) / s->ratio + s->thres; s->compressed_knee_stop = (s->knee_stop - s->thres) / s->ratio + s->thres;
@ -166,7 +168,7 @@ static void compressor(SidechainCompressContext *s,
s->lin_slope += (abs_sample - s->lin_slope) * (abs_sample > s->lin_slope ? s->attack_coeff : s->release_coeff); s->lin_slope += (abs_sample - s->lin_slope) * (abs_sample > s->lin_slope ? s->attack_coeff : s->release_coeff);
if (s->lin_slope > 0.0 && s->lin_slope > s->lin_knee_start) if (s->lin_slope > 0.0 && s->lin_slope > (s->detection ? s->adj_knee_start : s->lin_knee_start))
gain = output_gain(s->lin_slope, s->ratio, s->thres, s->knee, gain = output_gain(s->lin_slope, s->ratio, s->thres, s->knee,
s->knee_start, s->knee_stop, s->knee_start, s->knee_stop,
s->compressed_knee_stop, s->detection); s->compressed_knee_stop, s->detection);