From 53d12747e56ae2c742c647595565b003ec4b71c3 Mon Sep 17 00:00:00 2001 From: krocard Date: Wed, 15 Jul 2020 13:57:25 +0100 Subject: [PATCH] Name [-1,1] the "nominal" range of float samples Float values are allowed to be > 0dbfs, it is just not nominal as it will might distort the signal when played without attenuation. This is also consistent with [AudioTrack.write(FloatBuffer)](https://developer.android.com/reference/android/media/AudioTrack#write(float[],%20int,%20int,%20int)) that explicitly allows it up to 3dbfs. PiperOrigin-RevId: 321345077 --- RELEASENOTES.md | 2 ++ .../android/exoplayer2/audio/ResamplingAudioProcessor.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index bfdf17ea79..445f7e157d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -2,6 +2,8 @@ ### 2.11.8 (2020-08-25) ### +* Fix distorted playback of floating point audio when samples exceed the + `[-1, 1]` nominal range. * MP4: Add support for `piff` and `isml` brands ([#7584](https://github.com/google/ExoPlayer/issues/7584)). * FMP4: Fix `saiz` and `senc` sample count checks, resolving a "length diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java index 00d9bb4d1d..a4d2a1b67a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java @@ -116,7 +116,7 @@ import java.nio.ByteBuffer; // 32 bit floating point -> 16 bit resampling. Floating point values are in the range // [-1.0, 1.0], so need to be scaled by Short.MAX_VALUE. for (int i = position; i < limit; i += 4) { - // Clamp to avoid integer overflow if the floating point values exceed their allowed range + // Clamp to avoid integer overflow if the floating point values exceed their nominal range // [Internal ref: b/161204847]. float floatValue = Util.constrainValue(inputBuffer.getFloat(i), /* min= */ -1, /* max= */ 1);