avfilter/af_asdr: remove wrong scaling from sdr, and fix sisdr formula

This commit is contained in:
Paul B Mahol 2023-08-14 01:36:34 +02:00
parent 10110a30b5
commit 24c013369d
1 changed files with 2 additions and 2 deletions

View File

@ -225,11 +225,11 @@ static av_cold void uninit(AVFilterContext *ctx)
if (!strcmp(ctx->filter->name, "asdr")) { if (!strcmp(ctx->filter->name, "asdr")) {
for (int ch = 0; ch < s->channels; ch++) for (int ch = 0; ch < s->channels; ch++)
av_log(ctx, AV_LOG_INFO, "SDR ch%d: %g dB\n", ch, 20. * log10(s->chs[ch].u / s->chs[ch].uv)); av_log(ctx, AV_LOG_INFO, "SDR ch%d: %g dB\n", ch, 10. * log10(s->chs[ch].u / s->chs[ch].uv));
} else if (!strcmp(ctx->filter->name, "asisdr")) { } else if (!strcmp(ctx->filter->name, "asisdr")) {
for (int ch = 0; ch < s->channels; ch++) { for (int ch = 0; ch < s->channels; ch++) {
double scale = s->chs[ch].uv / s->chs[ch].v; double scale = s->chs[ch].uv / s->chs[ch].v;
double sisdr = s->chs[ch].u / fmax(0., s->chs[ch].u + scale*scale*s->chs[ch].v - 2.0*scale*s->chs[ch].uv); double sisdr = scale * scale * s->chs[ch].v / fmax(0., s->chs[ch].u + scale*scale*s->chs[ch].v - 2.0*scale*s->chs[ch].uv);
av_log(ctx, AV_LOG_INFO, "SI-SDR ch%d: %g dB\n", ch, 10. * log10(sisdr)); av_log(ctx, AV_LOG_INFO, "SI-SDR ch%d: %g dB\n", ch, 10. * log10(sisdr));
} }