Codec2: align C2PlanarLayout definition to framework impl
Move the code part which is specific for passing handle and plane information
to VDA adaptor (or adaptor proxy) from allocator to component, i.e. swapping
offsets for YCrCb, and combining CbCr planes for semi-planar format.
For allocator itself follows the same definition of C2PlanarLayout as
C2AllocatorGralloc implementation provided by framework.
Bug: None
Test: run native tests for C2VDAComponent on ARC++N
Change-Id: I1dc9b207283b3313f0322bd93182b8a804b26a9a
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index a67a07e..8228136 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -160,9 +160,7 @@
supportedProfile.max_resolution.ToString().c_str());
}
- auto insertParam = [& params = mParams](C2Param* param) {
- params[param->index()] = param;
- };
+ auto insertParam = [& params = mParams](C2Param* param) { params[param->index()] = param; };
insertParam(&mDomainInfo);
insertParam(&mOutputColorFormat);
@@ -985,7 +983,19 @@
offsets[i] = static_cast<uint32_t>(planeAddress - baseAddress);
}
- for (uint32_t i = 0; i < layout.numPlanes; ++i) {
+ if (layout.numPlanes == 3 &&
+ offsets[C2PlanarLayout::PLANE_U] > offsets[C2PlanarLayout::PLANE_V]) {
+ // YCrCb format
+ std::swap(offsets[C2PlanarLayout::PLANE_U], offsets[C2PlanarLayout::PLANE_V]);
+ }
+
+ uint32_t passedNumPlanes = layout.numPlanes;
+ if (layout.planes[C2PlanarLayout::PLANE_U].colInc == 2) { // chroma_step
+ // Semi-planar format
+ passedNumPlanes--;
+ }
+
+ for (uint32_t i = 0; i < passedNumPlanes; ++i) {
ALOGV("plane %u: stride: %d, offset: %u", i, layout.planes[i].rowInc, offsets[i]);
}
@@ -996,7 +1006,7 @@
return;
}
std::vector<VideoFramePlane> passedPlanes;
- for (uint32_t i = 0; i < layout.numPlanes; ++i) {
+ for (uint32_t i = 0; i < passedNumPlanes; ++i) {
CHECK_GT(layout.planes[i].rowInc, 0);
passedPlanes.push_back({offsets[i], static_cast<uint32_t>(layout.planes[i].rowInc)});
}