Commit e612511a by bachinger Committed by Oliver Woodman

take byte offset into account when unsynchronizing an id3 frame

Issue #5673

PiperOrigin-RevId: 241328598
parent 5fd4fddf
...@@ -90,7 +90,8 @@ ...@@ -90,7 +90,8 @@
* Prevent seeking when ICY metadata is present to prevent playback problems * Prevent seeking when ICY metadata is present to prevent playback problems
([#5658](https://github.com/google/ExoPlayer/issues/5658)). ([#5658](https://github.com/google/ExoPlayer/issues/5658)).
* Use full BCP 47 language tags in `Format`. * 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 ### ### 2.9.6 ###
......
...@@ -713,9 +713,11 @@ public final class Id3Decoder implements MetadataDecoder { ...@@ -713,9 +713,11 @@ public final class Id3Decoder implements MetadataDecoder {
*/ */
private static int removeUnsynchronization(ParsableByteArray data, int length) { private static int removeUnsynchronization(ParsableByteArray data, int length) {
byte[] bytes = data.data; 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) { 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--; length--;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment