From a4c078afc3281241351497f9e2605b19cb21a26b Mon Sep 17 00:00:00 2001 From: Erich Seifert Date: Fri, 23 Oct 2026 03:16:10 +0200 Subject: [PATCH] Fix volume filter normalization applying gain to the first sample only Since channel_mask was added, the s16 normalize path read and wrote p[0] for every sample instead of the sample of the current channel. The audio was left unscaled while the first sample was multiplied repeatedly, and whenever the gain was above 1 every sample was replaced by a value derived from that first sample, which turned the signal into a near constant. Regressed in 3412c3fa. --- src/modules/normalize/filter_volume.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/normalize/filter_volume.c b/src/modules/normalize/filter_volume.c index dbf92be7bd..387fcc9b60 100644 --- a/src/modules/normalize/filter_volume.c +++ b/src/modules/normalize/filter_volume.c @@ -1,6 +1,6 @@ /* * filter_volume.c -- adjust audio volume - * Copyright (C) 2003-2025 Meltytech, LLC + * Copyright (C) 2003-2026 Meltytech, LLC * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -254,13 +254,13 @@ static int filter_get_audio(mlt_frame frame, for (j = 0; j < *channels; j++) { if (channel_mask & (1 << j)) for (i = 0; i < *samples; i++) { + int16_t *s = &p[*channels * i + j]; g = gain + i * gain_step; - sample = p[0] * g; - p[0] = ROUND(sample); + sample = *s * g; + *s = ROUND(sample); if (g > 1.0 && normalize) { /* use limiter function instead of clipping */ - p[*channels * i + j] = ROUND( - samplemax * limiter(sample / (double) samplemax, limiter_level)); + *s = ROUND(samplemax * limiter(sample / (double) samplemax, limiter_level)); } } }