Camera2: fix data copy array out of bound issue
We assumed that the Y stride was always larger or equal to chroma stride for YUV.
This isn't a reasonable assumption as the chroma stride could be larger for
interleaved UV format. This change uses the max row stride across all planes
as the intermediate array size.
Bug: 17913095
Change-Id: Idb390d27c39c364265f3a55c6ac4eaaa0b26bcf5
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
index eef99a2..0c36832 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -413,7 +413,13 @@
int offset = 0;
data = new byte[width * height * ImageFormat.getBitsPerPixel(format) / 8];
- byte[] rowData = new byte[planes[0].getRowStride()];
+ int maxRowSize = planes[0].getRowStride();
+ for (int i = 0; i < planes.length; i++) {
+ if (maxRowSize < planes[i].getRowStride()) {
+ maxRowSize = planes[i].getRowStride();
+ }
+ }
+ byte[] rowData = new byte[maxRowSize];
if(VERBOSE) Log.v(TAG, "get data from " + planes.length + " planes");
for (int i = 0; i < planes.length; i++) {
buffer = planes[i].getBuffer();