VT: Rx side of CVO implementation to CCodec.
[Problem] video rotation is not working with CCodec in VT scenario.
[Cause] video rotation should be applied if cvo exists in
meta() of MediaCodecBuffer.
[Solution] C2StreamRotationInfo of outputbuffer will be updated
if cvo exist in inputbuffer.
Bug: 167935079
Signed-off-by: Byeongjo Park <bjo.park@samsung.com>
Change-Id: Ib03bde00cefbeb4ac6ea4ea9eff150c686780c38
Merged-In: Ib03bde00cefbeb4ac6ea4ea9eff150c686780c38
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index ba1d178..7386c7d 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -253,6 +253,16 @@
usesFrameReassembler = true;
input->frameReassembler.process(buffer, &items);
} else {
+ int32_t cvo = 0;
+ if (buffer->meta()->findInt32("cvo", &cvo)) {
+ int32_t rotation = cvo % 360;
+ // change rotation to counter-clock wise.
+ rotation = ((rotation <= 0) ? 0 : 360) - rotation;
+
+ Mutexed<OutputSurface>::Locked output(mOutputSurface);
+ uint64_t frameIndex = work->input.ordinal.frameIndex.peeku();
+ output->rotation[frameIndex] = rotation;
+ }
work->input.buffers.push_back(c2buffer);
if (encryptedBlock) {
work->input.infoBuffers.emplace_back(C2InfoBuffer::CreateLinearBuffer(
@@ -747,6 +757,22 @@
c2Buffer->getInfo(C2StreamRotationInfo::output::PARAM_TYPE));
bool flip = rotation && (rotation->flip & 1);
uint32_t quarters = ((rotation ? rotation->value : 0) / 90) & 3;
+
+ {
+ Mutexed<OutputSurface>::Locked output(mOutputSurface);
+ if (output->surface == nullptr) {
+ ALOGI("[%s] cannot render buffer without surface", mName);
+ return OK;
+ }
+ int64_t frameIndex;
+ buffer->meta()->findInt64("frameIndex", &frameIndex);
+ if (output->rotation.count(frameIndex) != 0) {
+ auto it = output->rotation.find(frameIndex);
+ quarters = (it->second / 90) & 3;
+ output->rotation.erase(it);
+ }
+ }
+
uint32_t transform = 0;
switch (quarters) {
case 0: // no rotation
@@ -790,14 +816,6 @@
hdr10PlusInfo.reset();
}
- {
- Mutexed<OutputSurface>::Locked output(mOutputSurface);
- if (output->surface == nullptr) {
- ALOGI("[%s] cannot render buffer without surface", mName);
- return OK;
- }
- }
-
std::vector<C2ConstGraphicBlock> blocks = c2Buffer->data().graphicBlocks();
if (blocks.size() != 1u) {
ALOGD("[%s] expected 1 graphic block, but got %zu", mName, blocks.size());