Loading media/codec2/components/base/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,11 @@ cc_library { "libsfplugin_ccodec_utils", ], header_libs: [ "libarect_headers", "libnativewindow_headers", ], shared_libs: [ "libcutils", // for properties "liblog", // for ALOG Loading Loading @@ -61,6 +66,11 @@ cc_defaults { "libsfplugin_ccodec_utils", ], header_libs: [ "libarect_headers", "libnativewindow_headers", ], shared_libs: [ "libcodec2_soft_common", "libcutils", // for properties Loading media/codec2/components/base/SimpleC2Component.cpp +6 −21 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define LOG_TAG "SimpleC2Component" #include <log/log.h> #include <android/hardware_buffer.h> #include <cutils/properties.h> #include <media/stagefright/foundation/AMessage.h> Loading @@ -26,19 +27,14 @@ #include <C2Config.h> #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <SimpleC2Component.h> 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 @@ -885,25 +881,14 @@ 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; 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); for (int halPixelFormat : halPixelFormats) { std::shared_ptr<C2GraphicBlock> block; uint32_t gpuConsumerFlags = halPixelFormat == HAL_PIXEL_FORMAT_RGBA_1010102 ? C2AndroidMemoryUsage::HW_TEXTURE_READ : 0; C2MemoryUsage usage = {C2MemoryUsage::CPU_READ | gpuConsumerFlags, C2MemoryUsage::CPU_WRITE}; // TODO(b/214411172) Use AHardwareBuffer_isSupported once it supports P010 c2_status_t status = mOutputBlockPool->fetchGraphicBlock(320, 240, halPixelFormat, usage, &block); if (status == C2_OK) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)halPixelFormat)) { mBitDepth10HalPixelFormats.push_back(halPixelFormat); } } Loading media/codec2/components/base/include/SimpleC2Component.h +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #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 +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <Codec2Mapper.h> #include <SimpleC2Interface.h> #include <log/log.h> Loading Loading @@ -190,7 +191,7 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams { .build()); std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; if (isAtLeastT()) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // TODO: support more formats? Loading media/codec2/components/vpx/C2SoftVpxDec.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <SimpleC2Interface.h> #include "C2SoftVpxDec.h" Loading Loading @@ -219,7 +220,7 @@ public: // TODO: support more formats? std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; #ifdef VP9 if (isAtLeastT()) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } #endif Loading Loading
media/codec2/components/base/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,11 @@ cc_library { "libsfplugin_ccodec_utils", ], header_libs: [ "libarect_headers", "libnativewindow_headers", ], shared_libs: [ "libcutils", // for properties "liblog", // for ALOG Loading Loading @@ -61,6 +66,11 @@ cc_defaults { "libsfplugin_ccodec_utils", ], header_libs: [ "libarect_headers", "libnativewindow_headers", ], shared_libs: [ "libcodec2_soft_common", "libcutils", // for properties Loading
media/codec2/components/base/SimpleC2Component.cpp +6 −21 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define LOG_TAG "SimpleC2Component" #include <log/log.h> #include <android/hardware_buffer.h> #include <cutils/properties.h> #include <media/stagefright/foundation/AMessage.h> Loading @@ -26,19 +27,14 @@ #include <C2Config.h> #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <SimpleC2Component.h> 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 @@ -885,25 +881,14 @@ 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; 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); for (int halPixelFormat : halPixelFormats) { std::shared_ptr<C2GraphicBlock> block; uint32_t gpuConsumerFlags = halPixelFormat == HAL_PIXEL_FORMAT_RGBA_1010102 ? C2AndroidMemoryUsage::HW_TEXTURE_READ : 0; C2MemoryUsage usage = {C2MemoryUsage::CPU_READ | gpuConsumerFlags, C2MemoryUsage::CPU_WRITE}; // TODO(b/214411172) Use AHardwareBuffer_isSupported once it supports P010 c2_status_t status = mOutputBlockPool->fetchGraphicBlock(320, 240, halPixelFormat, usage, &block); if (status == C2_OK) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)halPixelFormat)) { mBitDepth10HalPixelFormats.push_back(halPixelFormat); } } Loading
media/codec2/components/base/include/SimpleC2Component.h +0 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ #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 +2 −1 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <Codec2Mapper.h> #include <SimpleC2Interface.h> #include <log/log.h> Loading Loading @@ -190,7 +191,7 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams { .build()); std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; if (isAtLeastT()) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } // TODO: support more formats? Loading
media/codec2/components/vpx/C2SoftVpxDec.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include <C2Debug.h> #include <C2PlatformSupport.h> #include <Codec2BufferUtils.h> #include <Codec2CommonUtils.h> #include <SimpleC2Interface.h> #include "C2SoftVpxDec.h" Loading Loading @@ -219,7 +220,7 @@ public: // TODO: support more formats? std::vector<uint32_t> pixelFormats = {HAL_PIXEL_FORMAT_YCBCR_420_888}; #ifdef VP9 if (isAtLeastT()) { if (isHalPixelFormatSupported((AHardwareBuffer_Format)HAL_PIXEL_FORMAT_YCBCR_P010)) { pixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010); } #endif Loading