Correct crop size for software encoders
When using surface crop size may be set to incorrect
value and cause errors when copying buffers.
To prevent that, encoders will set crop size to expected
image size.
Bug: b/232396154
Test: android.mediav2.cts.CodecEncoderSurfaceTest
android.mediav2.cts.CodecEncoderTest
Change-Id: Iafa4f9f1a49760c2b5345b8768b476a2fd7510f6
diff --git a/media/codec2/components/hevc/C2SoftHevcEnc.cpp b/media/codec2/components/hevc/C2SoftHevcEnc.cpp
index 60d5875..9c26c02 100644
--- a/media/codec2/components/hevc/C2SoftHevcEnc.cpp
+++ b/media/codec2/components/hevc/C2SoftHevcEnc.cpp
@@ -1109,14 +1109,14 @@
}
}
- std::shared_ptr<const C2GraphicView> view;
+ std::shared_ptr<C2GraphicView> view;
std::shared_ptr<C2Buffer> inputBuffer = nullptr;
bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0);
if (eos) mSignalledEos = true;
if (!work->input.buffers.empty()) {
inputBuffer = work->input.buffers[0];
- view = std::make_shared<const C2GraphicView>(
+ view = std::make_shared<C2GraphicView>(
inputBuffer->data().graphicBlocks().front().map().get());
if (view->error() != C2_OK) {
ALOGE("graphic view map err = %d", view->error());
@@ -1125,6 +1125,9 @@
work->workletsProcessed = 1u;
return;
}
+ //(b/232396154)
+ //workaround for incorrect crop size in view when using surface mode
+ view->setCrop_be(C2Rect(mSize->width, mSize->height));
}
IHEVCE_PLUGIN_STATUS_T err = IHEVCE_EOK;