diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2b85f2e7c47..0d982d340e9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -90,7 +90,8 @@ * Prevent seeking when ICY metadata is present to prevent playback problems ([#5658](https://github.com/google/ExoPlayer/issues/5658)). * Use full BCP 47 language tags in `Format`. -* Select audio track based on system language if no preference is provided. +* Take byte offset into account when unsynchronizing an id3 frame + ([#5673](https://github.com/google/ExoPlayer/issues/5673)). ### 2.9.6 ### diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java index 4bc864935f0..fff0828b3a5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java @@ -713,9 +713,11 @@ private static BinaryFrame decodeBinaryFrame(ParsableByteArray id3Data, int fram */ private static int removeUnsynchronization(ParsableByteArray data, int length) { byte[] bytes = data.data; - for (int i = data.getPosition(); i + 1 < length; i++) { + int startPosition = data.getPosition(); + for (int i = startPosition; i + 1 < startPosition + length; i++) { if ((bytes[i] & 0xFF) == 0xFF && bytes[i + 1] == 0x00) { - System.arraycopy(bytes, i + 2, bytes, i + 1, length - i - 2); + int relativePosition = i - startPosition; + System.arraycopy(bytes, i + 2, bytes, i + 1, length - relativePosition - 2); length--; } }