C2 Decoders: Add a function to choose hal pixel format for 10 bit decode

Added a function which will return supported hal pixel format
when decoding streams with bit depth of 10 for VP9 and AV1.

P010, RGBA1010102 (for specific color aspects) and YV12 is the order
in which formats are tried.

P010 format will be enabled once framework supports it

AHardwareBuffer_isSupported() doesn't handle P010 format and hence
fetchGraphicBlock() call is used to determine which are formats are
supported.

Bug: 178229371
Test: atest CtsMediaV2TestCases -- --module-arg \
 CtsMediaV2TestCases:instrumentation-arg:codec-prefix:=c2.android.

Change-Id: I6503ecf49934f7d0fb8d8ffcf95e3aa4905741d8
diff --git a/media/codec2/components/vpx/C2SoftVpxDec.cpp b/media/codec2/components/vpx/C2SoftVpxDec.cpp
index 0a27821..5fc89be 100644
--- a/media/codec2/components/vpx/C2SoftVpxDec.cpp
+++ b/media/codec2/components/vpx/C2SoftVpxDec.cpp
@@ -352,7 +352,6 @@
       mCodecCtx(nullptr),
       mCoreCount(1),
       mQueue(new Mutexed<ConversionQueue>) {
-      mIsFormatR10G10B10A2Supported = IsFormatR10G10B10A2SupportedForLegacyRendering();
 }
 
 C2SoftVpxDec::~C2SoftVpxDec() {
@@ -683,19 +682,13 @@
     if (img->fmt == VPX_IMG_FMT_I42016) {
         IntfImpl::Lock lock = mIntf->lock();
         std::shared_ptr<C2StreamColorAspectsTuning::output> defaultColorAspects = mIntf->getDefaultColorAspects_l();
-
+        bool allowRGBA1010102 = false;
         if (defaultColorAspects->primaries == C2Color::PRIMARIES_BT2020 &&
             defaultColorAspects->matrix == C2Color::MATRIX_BT2020 &&
             defaultColorAspects->transfer == C2Color::TRANSFER_ST2084) {
-            // 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;
-            }
+            allowRGBA1010102 = true;
         }
+        format = getHalPixelFormatForBitDepth10(allowRGBA1010102);
     }
     C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
     c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block);