summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authornanahi <130121847+na-na-hi@users.noreply.github.com>2024-02-24 02:07:28 -0500
committerDudemanguy <random342@airmail.cc>2024-02-25 18:23:57 +0000
commit2872e23aea5cca8d30d33b3cea897dd1cfd94d05 (patch)
tree6fe11321a85161da2ecd4ffa5864388f614c9feb /audio
parentab3a63285a44e6b41e171e737950d8d266ca79db (diff)
downloadmpv-2872e23aea5cca8d30d33b3cea897dd1cfd94d05.tar.bz2
mpv-2872e23aea5cca8d30d33b3cea897dd1cfd94d05.tar.xz
ao: don't clip floating point formats at non-unity gain
Currently, the softvol gain control attempts to clip floating point ao formats within -1 and +1. However, this is "optimized out" at unity gain, where no clipping is applied. This results in inconsistent behavior when the source audio is already out of -1 and +1 range, where a gain of 0.99 results in clipping, but not at exactly 1. Since a big advantage of floating point audio data is that they do not lose information through out-of-range data because the ao sink can apply suitable negative gain to prevent clipping before converting them to integer formats, clipping should not be performed on these data. Fix this by removing the existing clipping behavior. It now results in a simple multiplication, which faciliates compiler auto-vectorization of this operation over audio data.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index a5aa3a9402..3c61ee786c 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -612,7 +612,7 @@ void ao_set_gain(struct ao *ao, float gain)
#define MUL_GAIN_f(d, num_samples, gain) \
for (int n = 0; n < (num_samples); n++) \
- (d)[n] = MPCLAMP(((d)[n]) * (gain), -1.0, 1.0)
+ (d)[n] = (d)[n] * (gain)
static void process_plane(struct ao *ao, void *data, int num_samples)
{