Loading media/codec2/components/base/SimpleC2Component.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -32,6 +32,13 @@ namespace android { constexpr uint8_t kNeutralUVBitDepth8 = 128; constexpr uint16_t kNeutralUVBitDepth10 = 512; bool isAtLeastT() { char deviceCodeName[PROP_VALUE_MAX]; __system_property_get("ro.build.version.codename", deviceCodeName); return android_get_device_api_level() >= __ANDROID_API_T__ || !strcmp(deviceCodeName, "Tiramisu"); } void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride, size_t srcUStride, size_t srcVStride, size_t dstYStride, Loading Loading @@ -767,9 +774,9 @@ int SimpleC2Component::getHalPixelFormatForBitDepth10(bool allowRGBA1010102) { // Save supported hal pixel formats for bit depth of 10, the first time this is called if (!mBitDepth10HalPixelFormats.size()) { std::vector<int> halPixelFormats; // TODO(b/178229371) Enable HAL_PIXEL_FORMAT_YCBCR_P010 once framework supports it // halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); if (isAtLeastT()) { halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // since allowRGBA1010102 can chance in each call, but mBitDepth10HalPixelFormats // is populated only once, allowRGBA1010102 is not considered at this stage. halPixelFormats.push_back(HAL_PIXEL_FORMAT_RGBA_1010102); Loading media/codec2/components/base/include/SimpleC2Component.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ #include <media/stagefright/foundation/Mutexed.h> namespace android { bool isAtLeastT(); void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride, size_t srcUStride, size_t srcVStride, size_t dstYStride, Loading media/codec2/components/gav1/C2SoftGav1Dec.cpp +30 −4 Original line number Diff line number Diff line Loading @@ -189,10 +189,17 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams { .withSetter(ColorAspectsSetter, mDefaultColorAspects, mCodedColorAspects) .build()); std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; if (isAtLeastT()) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // TODO: support more formats? addParameter(DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withConstValue(new C2StreamPixelFormatInfo::output( addParameter( DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withDefault(new C2StreamPixelFormatInfo::output( 0u, HAL_PIXEL_FORMAT_YCBCR_420_888)) .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)}) .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps)) .build()); } Loading Loading @@ -402,6 +409,7 @@ static int GetCPUCoreCount() { bool C2SoftGav1Dec::initDecoder() { mSignalledError = false; mSignalledOutputEos = false; mHalPixelFormat = HAL_PIXEL_FORMAT_YV12; mCodecCtx.reset(new libgav1::Decoder()); if (mCodecCtx == nullptr) { Loading Loading @@ -647,6 +655,24 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool, return false; } } if (mHalPixelFormat != format) { C2StreamPixelFormatInfo::output pixelFormat(0u, format); std::vector<std::unique_ptr<C2SettingResult>> failures; c2_status_t err = mIntf->config({&pixelFormat }, C2_MAY_BLOCK, &failures); if (err == C2_OK) { work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(pixelFormat)); } else { ALOGE("Config update pixelFormat failed"); mSignalledError = true; work->workletsProcessed = 1u; work->result = C2_CORRUPTED; return UNKNOWN_ERROR; } mHalPixelFormat = format; } C2MemoryUsage usage = {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}; c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, Loading media/codec2/components/gav1/C2SoftGav1Dec.h +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ struct C2SoftGav1Dec : public SimpleC2Component { std::shared_ptr<IntfImpl> mIntf; std::unique_ptr<libgav1::Decoder> mCodecCtx; uint32_t mHalPixelFormat; uint32_t mWidth; uint32_t mHeight; bool mSignalledOutputEos; Loading media/codec2/components/vpx/C2SoftVpxDec.cpp +30 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <log/log.h> #include <algorithm> #include <media/stagefright/foundation/AUtils.h> #include <media/stagefright/foundation/MediaDefs.h> Loading Loading @@ -218,11 +217,20 @@ public: .build()); // TODO: support more formats? std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; #ifdef VP9 if (isAtLeastT()) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } #endif addParameter( DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withConstValue(new C2StreamPixelFormatInfo::output( .withDefault(new C2StreamPixelFormatInfo::output( 0u, HAL_PIXEL_FORMAT_YCBCR_420_888)) .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)}) .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps)) .build()); } static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe, Loading Loading @@ -424,7 +432,7 @@ status_t C2SoftVpxDec::initDecoder() { #else mMode = MODE_VP8; #endif mHalPixelFormat = HAL_PIXEL_FORMAT_YV12; mWidth = 320; mHeight = 240; mFrameParallelMode = false; Loading Loading @@ -690,6 +698,24 @@ status_t C2SoftVpxDec::outputBuffer( } format = getHalPixelFormatForBitDepth10(allowRGBA1010102); } if (mHalPixelFormat != format) { C2StreamPixelFormatInfo::output pixelFormat(0u, format); std::vector<std::unique_ptr<C2SettingResult>> failures; c2_status_t err = mIntf->config({&pixelFormat }, C2_MAY_BLOCK, &failures); if (err == C2_OK) { work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(pixelFormat)); } else { ALOGE("Config update pixelFormat failed"); mSignalledError = true; work->workletsProcessed = 1u; work->result = C2_CORRUPTED; return UNKNOWN_ERROR; } mHalPixelFormat = format; } C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE }; c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block); if (err != C2_OK) { Loading Loading
media/codec2/components/base/SimpleC2Component.cpp +10 −3 Original line number Diff line number Diff line Loading @@ -32,6 +32,13 @@ namespace android { constexpr uint8_t kNeutralUVBitDepth8 = 128; constexpr uint16_t kNeutralUVBitDepth10 = 512; bool isAtLeastT() { char deviceCodeName[PROP_VALUE_MAX]; __system_property_get("ro.build.version.codename", deviceCodeName); return android_get_device_api_level() >= __ANDROID_API_T__ || !strcmp(deviceCodeName, "Tiramisu"); } void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride, size_t srcUStride, size_t srcVStride, size_t dstYStride, Loading Loading @@ -767,9 +774,9 @@ int SimpleC2Component::getHalPixelFormatForBitDepth10(bool allowRGBA1010102) { // Save supported hal pixel formats for bit depth of 10, the first time this is called if (!mBitDepth10HalPixelFormats.size()) { std::vector<int> halPixelFormats; // TODO(b/178229371) Enable HAL_PIXEL_FORMAT_YCBCR_P010 once framework supports it // halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); if (isAtLeastT()) { halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // since allowRGBA1010102 can chance in each call, but mBitDepth10HalPixelFormats // is populated only once, allowRGBA1010102 is not considered at this stage. halPixelFormats.push_back(HAL_PIXEL_FORMAT_RGBA_1010102); Loading
media/codec2/components/base/include/SimpleC2Component.h +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ #include <media/stagefright/foundation/Mutexed.h> namespace android { bool isAtLeastT(); void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride, size_t srcUStride, size_t srcVStride, size_t dstYStride, Loading
media/codec2/components/gav1/C2SoftGav1Dec.cpp +30 −4 Original line number Diff line number Diff line Loading @@ -189,10 +189,17 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams { .withSetter(ColorAspectsSetter, mDefaultColorAspects, mCodedColorAspects) .build()); std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; if (isAtLeastT()) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // TODO: support more formats? addParameter(DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withConstValue(new C2StreamPixelFormatInfo::output( addParameter( DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withDefault(new C2StreamPixelFormatInfo::output( 0u, HAL_PIXEL_FORMAT_YCBCR_420_888)) .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)}) .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps)) .build()); } Loading Loading @@ -402,6 +409,7 @@ static int GetCPUCoreCount() { bool C2SoftGav1Dec::initDecoder() { mSignalledError = false; mSignalledOutputEos = false; mHalPixelFormat = HAL_PIXEL_FORMAT_YV12; mCodecCtx.reset(new libgav1::Decoder()); if (mCodecCtx == nullptr) { Loading Loading @@ -647,6 +655,24 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool, return false; } } if (mHalPixelFormat != format) { C2StreamPixelFormatInfo::output pixelFormat(0u, format); std::vector<std::unique_ptr<C2SettingResult>> failures; c2_status_t err = mIntf->config({&pixelFormat }, C2_MAY_BLOCK, &failures); if (err == C2_OK) { work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(pixelFormat)); } else { ALOGE("Config update pixelFormat failed"); mSignalledError = true; work->workletsProcessed = 1u; work->result = C2_CORRUPTED; return UNKNOWN_ERROR; } mHalPixelFormat = format; } C2MemoryUsage usage = {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}; c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, Loading
media/codec2/components/gav1/C2SoftGav1Dec.h +1 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ struct C2SoftGav1Dec : public SimpleC2Component { std::shared_ptr<IntfImpl> mIntf; std::unique_ptr<libgav1::Decoder> mCodecCtx; uint32_t mHalPixelFormat; uint32_t mWidth; uint32_t mHeight; bool mSignalledOutputEos; Loading
media/codec2/components/vpx/C2SoftVpxDec.cpp +30 −4 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ #include <log/log.h> #include <algorithm> #include <media/stagefright/foundation/AUtils.h> #include <media/stagefright/foundation/MediaDefs.h> Loading Loading @@ -218,11 +217,20 @@ public: .build()); // TODO: support more formats? std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; #ifdef VP9 if (isAtLeastT()) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } #endif addParameter( DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT) .withConstValue(new C2StreamPixelFormatInfo::output( .withDefault(new C2StreamPixelFormatInfo::output( 0u, HAL_PIXEL_FORMAT_YCBCR_420_888)) .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)}) .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps)) .build()); } static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe, Loading Loading @@ -424,7 +432,7 @@ status_t C2SoftVpxDec::initDecoder() { #else mMode = MODE_VP8; #endif mHalPixelFormat = HAL_PIXEL_FORMAT_YV12; mWidth = 320; mHeight = 240; mFrameParallelMode = false; Loading Loading @@ -690,6 +698,24 @@ status_t C2SoftVpxDec::outputBuffer( } format = getHalPixelFormatForBitDepth10(allowRGBA1010102); } if (mHalPixelFormat != format) { C2StreamPixelFormatInfo::output pixelFormat(0u, format); std::vector<std::unique_ptr<C2SettingResult>> failures; c2_status_t err = mIntf->config({&pixelFormat }, C2_MAY_BLOCK, &failures); if (err == C2_OK) { work->worklets.front()->output.configUpdate.push_back( C2Param::Copy(pixelFormat)); } else { ALOGE("Config update pixelFormat failed"); mSignalledError = true; work->workletsProcessed = 1u; work->result = C2_CORRUPTED; return UNKNOWN_ERROR; } mHalPixelFormat = format; } C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE }; c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block); if (err != C2_OK) { Loading