Use C2VDAPixelForamt to resolve pixel format
A function to get supported format from crcb and semiplanar is identical in Android path and ARC++
path. So they can be unified.
The other function is to return pixel format on a platform with zero knowledge. A small
C2AllocationGralloc is allocated inside of the function, and detects its pixel format.
Because C2ArcProtectedGraphicAllocator needs to call these function, the code is located in
device/google/cheets2/.
Bug: 73870167
Test: Play secure videos with ExoPlayer.app
Change-Id: I34975f869b465e347b9ef1521d12998539be5658
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index dd48d33..65656e3 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -13,10 +13,11 @@
#define __C2_GENERATE_GLOBAL_VARS__
#include <C2VDAAllocatorStore.h>
+#include <C2VDAComponent.h>
+#include <C2VDAPixelFormat.h>
+#include <C2VDASupport.h> // to getParamReflector from vda store
#include <C2VdaBqBlockPool.h>
#include <C2VdaPooledBlockPool.h>
-#include <C2VDAComponent.h>
-#include <C2VDASupport.h> // to getParamReflector from vda store
#include <videodev2_custom.h>
@@ -821,11 +822,7 @@
for (uint32_t i = 0; i < passedNumPlanes; ++i) {
ALOGV("plane %u: stride: %d, offset: %u", i, layout.planes[i].rowInc, offsets[i]);
}
-#ifdef V4L2_CODEC2_ARC
- info.mPixelFormat = arc::C2VDAAdaptorProxy::ResolveBufferFormat(crcb, semiplanar);
-#else
- info.mPixelFormat = C2VDAAdaptor::ResolveBufferFormat(crcb, semiplanar);
-#endif
+ info.mPixelFormat = resolveBufferFormat(crcb, semiplanar);
ALOGV("HAL pixel format: 0x%x", static_cast<uint32_t>(info.mPixelFormat));
::base::ScopedFD passedHandle(dup(info.mGraphicBlock->handle()->data[0]));
@@ -857,8 +854,14 @@
return;
}
- // TODO(hiroh): resolve pixel format here.
- android::HalPixelFormat pixelFormat = pixelFormat == android::HalPixelFormat::NV12;
+ android::HalPixelFormat pixelFormat = getPlatformPixelFormat();
+ if (pixelFormat == android::HalPixelFormat::UNKNOWN) {
+ ALOGE("Failed to get pixel format on platform.");
+ reportError(C2_CORRUPTED);
+ return;
+ }
+ CHECK(pixelFormat == android::HalPixelFormat::YV12 ||
+ pixelFormat == android::HalPixelFormat::NV12);
ALOGV("HAL pixel format: 0x%x", static_cast<uint32_t>(pixelFormat));
GraphicBlockInfo info;