Merge "Camera: fix more image copy/compare logic" into pie-cts-dev
am: a1720f0e35
Change-Id: Ic01470845c21634958ba08b7f1107d1528dc69af
diff --git a/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java
index 47a5003..9254ea9 100644
--- a/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/camera/utils/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -1919,6 +1919,7 @@
} else {
Size effectivePlaneSize = getEffectivePlaneSizeForImage(src, i);
int srcRowByteCount = srcRowStride;
+ int dstRowByteCount = dstRowStride;
byte[] srcDataRow = new byte[srcRowByteCount];
if (srcPixStride == dstPixStride) {
@@ -1934,11 +1935,11 @@
}
}
srcBuffer.get(srcDataRow, /*offset*/0, srcRowByteCount);
- dstBuffer.put(srcDataRow, /*offset*/0, srcRowByteCount);
+ dstBuffer.put(srcDataRow, /*offset*/0,
+ Math.min(srcRowByteCount, dstRowByteCount));
}
} else {
// Row by row per pixel copy case
- int dstRowByteCount = dstRowStride;
byte[] dstDataRow = new byte[dstRowByteCount];
for (int row = 0; row < effectivePlaneSize.getHeight(); row++) {
if (row == effectivePlaneSize.getHeight() - 1) {
@@ -2057,12 +2058,12 @@
rhsBuffer = rhsPlanes[i].getBuffer();
lhsBuffer.rewind();
rhsBuffer.rewind();
- // Special case for YUV420_888 buffer with different chroma layout
- if (lhsImg.getFormat() == ImageFormat.YUV_420_888 && (i != 0) &&
+ // Special case for YUV420_888 buffer with different layout
+ if (lhsImg.getFormat() == ImageFormat.YUV_420_888 &&
(lhsPlanes[i].getPixelStride() != rhsPlanes[i].getPixelStride() ||
lhsPlanes[i].getRowStride() != rhsPlanes[i].getRowStride())) {
- int width = lhsImg.getWidth() / 2;
- int height = lhsImg.getHeight() / 2;
+ int width = getEffectivePlaneSizeForImage(lhsImg, i).getWidth();
+ int height = getEffectivePlaneSizeForImage(lhsImg, i).getHeight();
int rowSizeL = lhsPlanes[i].getRowStride();
int rowSizeR = rhsPlanes[i].getRowStride();
byte[] lhsRow = new byte[rowSizeL];