C2 decoders: Workaround for cases where RGBA1010102 isn't supported
On devices that do not support HAL_PIXEL_FORMAT_RGBA_1010102,
HAL_PIXEL_FORMAT_YV12 is used even for HDR content as a temporary
work around.
Bug: 201787956
Bug: 205749237
Test: Test HDR clip using c2.android.vp9.decoder
Test: atest CtsMediaV2TestCases:DecoderColorAspectsTest
Change-Id: Ibe5c9e0463bec1e254b38829ee18e490a0968b64
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.cpp b/media/codec2/components/vpx/C2SoftVpxDec.cpp
index 45e2ca8..2da9d5b 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxDec.cpp
@@ -25,6 +25,7 @@
#include <C2Debug.h>
#include <C2PlatformSupport.h>
+#include <Codec2BufferUtils.h>
#include <SimpleC2Interface.h>
#include "C2SoftVpxDec.h"
@@ -351,6 +352,7 @@
mCodecCtx(nullptr),
mCoreCount(1),
mQueue(new Mutexed<ConversionQueue>) {
+ mIsFormatR10G10B10A2Supported = IsFormatR10G10B10A2SupportedForLegacyRendering();
}
C2SoftVpxDec::~C2SoftVpxDec() {
@@ -804,7 +806,14 @@
if (defaultColorAspects->primaries == C2Color::PRIMARIES_BT2020 &&
defaultColorAspects->matrix == C2Color::MATRIX_BT2020 &&
defaultColorAspects->transfer == C2Color::TRANSFER_ST2084) {
- format = HAL_PIXEL_FORMAT_RGBA_1010102;
+ // TODO (b/201787956) For devices that do not support HAL_PIXEL_FORMAT_RGBA_1010102,
+ // HAL_PIXEL_FORMAT_YV12 is used as a temporary work around.
+ if (!mIsFormatR10G10B10A2Supported) {
+ ALOGE("HAL_PIXEL_FORMAT_RGBA_1010102 isn't supported");
+ format = HAL_PIXEL_FORMAT_YV12;
+ } else {
+ format = HAL_PIXEL_FORMAT_RGBA_1010102;
+ }
}
}
C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.h b/media/codec2/components/vpx/C2SoftVpxDec.h
index 2065165..ade162d 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.h
+++ b/media/codec2/components/vpx/C2SoftVpxDec.h
@@ -80,7 +80,7 @@
};
std::shared_ptr<Mutexed<ConversionQueue>> mQueue;
std::vector<sp<ConverterThread>> mConverterThreads;
-
+ bool mIsFormatR10G10B10A2Supported;
status_t initDecoder();
status_t destroyDecoder();
void finishWork(uint64_t index, const std::unique_ptr<C2Work> &work,