CodecTestBase: add support to read dimensions from crop rectangle
Bug: 158263262
Bug: 158577170
Test: cts android.mediav2.cts.CodecDecoderSurfaceTest
Change-Id: I56b3f804c4f68096db7229c8e5b17ba157106efa
diff --git a/tests/media/jni/NativeCodecTestBase.cpp b/tests/media/jni/NativeCodecTestBase.cpp
index 750abe6..b07c1c3 100644
--- a/tests/media/jni/NativeCodecTestBase.cpp
+++ b/tests/media/jni/NativeCodecTestBase.cpp
@@ -528,10 +528,11 @@
int CodecTestBase::getWidth(AMediaFormat* format) {
int width = -1;
- int cropLeft, cropRight;
+ int cropLeft, cropRight, cropTop, cropBottom;
AMediaFormat_getInt32(format, AMEDIAFORMAT_KEY_WIDTH, &width);
- if (AMediaFormat_getInt32(format, "crop-left", &cropLeft) &&
- AMediaFormat_getInt32(format, "crop-right", &cropRight)) {
+ if (AMediaFormat_getRect(format, "crop", &cropLeft, &cropTop, &cropRight, &cropBottom) ||
+ (AMediaFormat_getInt32(format, "crop-left", &cropLeft) &&
+ AMediaFormat_getInt32(format, "crop-right", &cropRight))) {
width = cropRight + 1 - cropLeft;
}
return width;
@@ -539,10 +540,11 @@
int CodecTestBase::getHeight(AMediaFormat* format) {
int height = -1;
- int cropTop, cropBottom;
+ int cropLeft, cropRight, cropTop, cropBottom;
AMediaFormat_getInt32(format, AMEDIAFORMAT_KEY_HEIGHT, &height);
- if (AMediaFormat_getInt32(format, "crop-top", &cropTop) &&
- AMediaFormat_getInt32(format, "crop-bottom", &cropBottom)) {
+ if (AMediaFormat_getRect(format, "crop", &cropLeft, &cropTop, &cropRight, &cropBottom) ||
+ (AMediaFormat_getInt32(format, "crop-top", &cropTop) &&
+ AMediaFormat_getInt32(format, "crop-bottom", &cropBottom))) {
height = cropBottom + 1 - cropTop;
}
return height;