From 361e80f40c07dfd69ed17c241dd73d4dc77e4d60 Mon Sep 17 00:00:00 2001 From: ibaker Date: Mon, 11 Jan 2021 10:22:27 +0000 Subject: [PATCH] Fix usage of ParsableByteArray in `PgsDecoder` This is a partial revert of https://github.com/google/ExoPlayer/commit/46598a46fd3c13a9be906abd6c673b9487ba5d50 The change from reset(int) to setPosition/Limit() in this file was incorrect, the reset(int) call is important because it ensures `bitmapData` is large enough for the `buffer.readBytes` call on L188. Issue: #8417 PiperOrigin-RevId: 351110038 --- .../com/google/android/exoplayer2/text/pgs/PgsDecoder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java index ee0899af82..47dd6e2fdf 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java @@ -177,8 +177,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder { } bitmapWidth = buffer.readUnsignedShort(); bitmapHeight = buffer.readUnsignedShort(); - bitmapData.setPosition(0); - bitmapData.setLimit(totalLength - 4); + bitmapData.reset(totalLength - 4); sectionLength -= 7; }