Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f732e8d2 authored by Wonsik Kim's avatar Wonsik Kim Committed by Automerger Merge Worker
Browse files

Merge "c2 av1, vp9: Add support for P010 format" am: 5f5b70ef

parents 05db1ab8 5f5b70ef
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -32,6 +32,13 @@ namespace android {
constexpr uint8_t kNeutralUVBitDepth8 = 128;
constexpr uint8_t kNeutralUVBitDepth8 = 128;
constexpr uint16_t kNeutralUVBitDepth10 = 512;
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,
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,
                                const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride,
                                size_t srcUStride, size_t srcVStride, size_t dstYStride,
                                size_t srcUStride, size_t srcVStride, size_t dstYStride,
@@ -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
    // Save supported hal pixel formats for bit depth of 10, the first time this is called
    if (!mBitDepth10HalPixelFormats.size()) {
    if (!mBitDepth10HalPixelFormats.size()) {
        std::vector<int> halPixelFormats;
        std::vector<int> halPixelFormats;
        // TODO(b/178229371) Enable HAL_PIXEL_FORMAT_YCBCR_P010 once framework supports it
        if (isAtLeastT()) {
        // halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010);
            halPixelFormats.push_back(HAL_PIXEL_FORMAT_YCBCR_P010);

        }
        // since allowRGBA1010102 can chance in each call, but mBitDepth10HalPixelFormats
        // since allowRGBA1010102 can chance in each call, but mBitDepth10HalPixelFormats
        // is populated only once, allowRGBA1010102 is not considered at this stage.
        // is populated only once, allowRGBA1010102 is not considered at this stage.
        halPixelFormats.push_back(HAL_PIXEL_FORMAT_RGBA_1010102);
        halPixelFormats.push_back(HAL_PIXEL_FORMAT_RGBA_1010102);
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@
#include <media/stagefright/foundation/Mutexed.h>
#include <media/stagefright/foundation/Mutexed.h>


namespace android {
namespace android {

bool isAtLeastT();
void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, const uint8_t *srcY,
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,
                                const uint8_t *srcU, const uint8_t *srcV, size_t srcYStride,
                                size_t srcUStride, size_t srcVStride, size_t dstYStride,
                                size_t srcUStride, size_t srcVStride, size_t dstYStride,
+30 −4
Original line number Original line Diff line number Diff line
@@ -189,10 +189,17 @@ class C2SoftGav1Dec::IntfImpl : public SimpleInterface<void>::BaseParams {
              .withSetter(ColorAspectsSetter, mDefaultColorAspects, mCodedColorAspects)
              .withSetter(ColorAspectsSetter, mDefaultColorAspects, mCodedColorAspects)
              .build());
              .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?
    // TODO: support more formats?
    addParameter(DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
    addParameter(
                     .withConstValue(new C2StreamPixelFormatInfo::output(
            DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
            .withDefault(new C2StreamPixelFormatInfo::output(
                              0u, HAL_PIXEL_FORMAT_YCBCR_420_888))
                              0u, HAL_PIXEL_FORMAT_YCBCR_420_888))
            .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)})
            .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps))
            .build());
            .build());
  }
  }


@@ -402,6 +409,7 @@ static int GetCPUCoreCount() {
bool C2SoftGav1Dec::initDecoder() {
bool C2SoftGav1Dec::initDecoder() {
  mSignalledError = false;
  mSignalledError = false;
  mSignalledOutputEos = false;
  mSignalledOutputEos = false;
  mHalPixelFormat = HAL_PIXEL_FORMAT_YV12;
  mCodecCtx.reset(new libgav1::Decoder());
  mCodecCtx.reset(new libgav1::Decoder());


  if (mCodecCtx == nullptr) {
  if (mCodecCtx == nullptr) {
@@ -647,6 +655,24 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
      return false;
      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};
  C2MemoryUsage usage = {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE};


  c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format,
  c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format,
+1 −0
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ struct C2SoftGav1Dec : public SimpleC2Component {
  std::shared_ptr<IntfImpl> mIntf;
  std::shared_ptr<IntfImpl> mIntf;
  std::unique_ptr<libgav1::Decoder> mCodecCtx;
  std::unique_ptr<libgav1::Decoder> mCodecCtx;


  uint32_t mHalPixelFormat;
  uint32_t mWidth;
  uint32_t mWidth;
  uint32_t mHeight;
  uint32_t mHeight;
  bool mSignalledOutputEos;
  bool mSignalledOutputEos;
+30 −4
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@
#include <log/log.h>
#include <log/log.h>


#include <algorithm>
#include <algorithm>

#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/MediaDefs.h>
#include <media/stagefright/foundation/MediaDefs.h>


@@ -218,11 +217,20 @@ public:
                .build());
                .build());


        // TODO: support more formats?
        // 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(
        addParameter(
                DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
                DefineParam(mPixelFormat, C2_PARAMKEY_PIXEL_FORMAT)
                .withConstValue(new C2StreamPixelFormatInfo::output(
                .withDefault(new C2StreamPixelFormatInfo::output(
                                  0u, HAL_PIXEL_FORMAT_YCBCR_420_888))
                                  0u, HAL_PIXEL_FORMAT_YCBCR_420_888))
                .withFields({C2F(mPixelFormat, value).oneOf(pixelFormats)})
                .withSetter((Setter<decltype(*mPixelFormat)>::StrictValueWithNoDeps))
                .build());
                .build());

    }
    }


    static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,
    static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,
@@ -424,7 +432,7 @@ status_t C2SoftVpxDec::initDecoder() {
#else
#else
    mMode = MODE_VP8;
    mMode = MODE_VP8;
#endif
#endif

    mHalPixelFormat = HAL_PIXEL_FORMAT_YV12;
    mWidth = 320;
    mWidth = 320;
    mHeight = 240;
    mHeight = 240;
    mFrameParallelMode = false;
    mFrameParallelMode = false;
@@ -690,6 +698,24 @@ status_t C2SoftVpxDec::outputBuffer(
        }
        }
        format = getHalPixelFormatForBitDepth10(allowRGBA1010102);
        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 };
    C2MemoryUsage usage = { C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE };
    c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block);
    c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format, usage, &block);
    if (err != C2_OK) {
    if (err != C2_OK) {
Loading