codec2: set crop window of C2GraphicBlock passed to framework
Crop window (a.k.a. visible size) is a parameter of output pictures which is
different than coded size (the real size of a graphic buffer). For a encoded
stream, crop window is fixed while coded size could vary by codec driver (crop
window must be not larger than coded size)).
Crop window information should be filled when the component shared
C2ConstGraphicBlock instance and passed to framework.
Bug: 77941729
Test: native tests on eve-arcnext
Test: adb shell /data/local/tmp/C2VDAComponent_test/C2VDAComponent_test -i /data/local/tmp/C2VDAComponent_test/bear.mp4:c2.vda.avc.decoder:640:360:82:84
Change-Id: I3fd33f66e95df569fd4d35b66179f9d4de7adc33
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 7718229..8a25388 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -458,7 +458,7 @@
class C2VDAGraphicBuffer : public C2Buffer {
public:
- C2VDAGraphicBuffer(const std::shared_ptr<C2GraphicBlock>& block,
+ C2VDAGraphicBuffer(const std::shared_ptr<C2GraphicBlock>& block, const media::Rect& visibleRect,
const base::Closure& releaseCB);
~C2VDAGraphicBuffer() override;
@@ -467,8 +467,9 @@
};
C2VDAGraphicBuffer::C2VDAGraphicBuffer(const std::shared_ptr<C2GraphicBlock>& block,
+ const media::Rect& visibleRect,
const base::Closure& releaseCB)
- : C2Buffer({block->share(C2Rect(block->width(), block->height()), C2Fence())}),
+ : C2Buffer({block->share(C2Rect(visibleRect.width(), visibleRect.height()), C2Fence())}),
mReleaseCB(releaseCB) {}
C2VDAGraphicBuffer::~C2VDAGraphicBuffer() {
@@ -703,8 +704,9 @@
// Attach output buffer to the work corresponded to bitstreamId.
work->worklets.front()->output.buffers.emplace_back(std::make_shared<C2VDAGraphicBuffer>(
- info->mGraphicBlock, base::Bind(&C2VDAComponent::returnOutputBuffer,
- mWeakThisFactory.GetWeakPtr(), pictureBufferId)));
+ info->mGraphicBlock, mOutputFormat.mVisibleRect,
+ base::Bind(&C2VDAComponent::returnOutputBuffer, mWeakThisFactory.GetWeakPtr(),
+ pictureBufferId)));
// TODO: this does not work for timestamps as they can wrap around
int64_t currentTimestamp = base::checked_cast<int64_t>(work->input.ordinal.timestamp.peek());
@@ -1093,9 +1095,9 @@
void C2VDAComponent::setOutputFormatCrop(const media::Rect& cropRect) {
ALOGV("setOutputFormatCrop(%dx%d)", cropRect.width(), cropRect.height());
+ // This visible rect should be set as crop window for each C2ConstGraphicBlock passed to
+ // framework.
mOutputFormat.mVisibleRect = cropRect;
- // TODO(johnylin): what else do we need to do? crop rect could be an info requested from
- // framework by requestedInfos in worklets.
}
c2_status_t C2VDAComponent::queue_nb(std::list<std::unique_ptr<C2Work>>* const items) {