codec2: Fix width and height when output is cropped
Return cropped width and height instead of block's width
and height
Test: cts-tradefed run cts -m CtsMediaBitstreamsTestCases \
-t android.media.cts.bitstreams.H264Yuv420_8bitBpBitstreamsTest
Bug: 132042537
Change-Id: I72538248fff4aeb9f0ad51e6e0d8844f66f20f92
diff --git a/media/codec2/sfplugin/CCodec.cpp b/media/codec2/sfplugin/CCodec.cpp
index f5a4d94..1b6266f 100644
--- a/media/codec2/sfplugin/CCodec.cpp
+++ b/media/codec2/sfplugin/CCodec.cpp
@@ -1739,7 +1739,7 @@
// block.width(), block.height());
updates.emplace_back(new C2StreamCropRectInfo::output(stream, block.crop()));
updates.emplace_back(new C2StreamPictureSizeInfo::output(
- stream, block.width(), block.height()));
+ stream, block.crop().width, block.crop().height));
break; // for now only do the first block
}
++stream;
diff --git a/media/codec2/sfplugin/Codec2Buffer.cpp b/media/codec2/sfplugin/Codec2Buffer.cpp
index c6cbad3..d2b31ee 100644
--- a/media/codec2/sfplugin/Codec2Buffer.cpp
+++ b/media/codec2/sfplugin/Codec2Buffer.cpp
@@ -391,8 +391,8 @@
return;
}
mediaImage->mNumPlanes = layout.numPlanes;
- mediaImage->mWidth = mWidth;
- mediaImage->mHeight = mHeight;
+ mediaImage->mWidth = view.crop().width;
+ mediaImage->mHeight = view.crop().height;
mediaImage->mBitDepth = bitDepth;
mediaImage->mBitDepthAllocated = mAllocatedDepth;
diff --git a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
index 6b8663f..1e884ef 100644
--- a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
+++ b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
@@ -118,7 +118,7 @@
} // namespace
status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView &view) {
- if (view.width() != img->mWidth || view.height() != img->mHeight) {
+ if (view.crop().width != img->mWidth || view.crop().height != img->mHeight) {
return BAD_VALUE;
}
if ((IsNV12(view) && IsI420(img)) || (IsI420(view) && IsNV12(img))) {
@@ -153,7 +153,7 @@
}
status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage2 *img) {
- if (view.width() != img->mWidth || view.height() != img->mHeight) {
+ if (view.crop().width != img->mWidth || view.crop().height != img->mHeight) {
return BAD_VALUE;
}
if ((IsNV12(img) && IsI420(view)) || (IsI420(img) && IsNV12(view))) {