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

Commit a9a4db39 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "C2 decoders: Workaround for cases where RGBA1010102 isn't supported"...

Merge "C2 decoders: Workaround for cases where RGBA1010102 isn't supported" am: f527d432 am: 71ffb2ee am: 02263f2c

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1923361

Change-Id: I5a2dff7c1605d7a1e083ad11c1f96573cabccc1f
parents 26b224f6 02263f2c
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#include <C2Debug.h>
#include <C2PlatformSupport.h>
#include <Codec2BufferUtils.h>
#include <Codec2Mapper.h>
#include <SimpleC2Interface.h>
#include <log/log.h>
@@ -338,6 +339,7 @@ C2SoftGav1Dec::C2SoftGav1Dec(const char *name, c2_node_id_t id,
          std::make_shared<SimpleInterface<IntfImpl>>(name, id, intfImpl)),
      mIntf(intfImpl),
      mCodecCtx(nullptr) {
  mIsFormatR10G10B10A2Supported = IsFormatR10G10B10A2SupportedForLegacyRendering();
  gettimeofday(&mTimeStart, nullptr);
  gettimeofday(&mTimeEnd, nullptr);
}
@@ -790,9 +792,16 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
        work->workletsProcessed = 1u;
        return false;
      }
      // 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};

  c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight, format,
+1 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ struct C2SoftGav1Dec : public SimpleC2Component {

  struct timeval mTimeStart;  // Time at the start of decode()
  struct timeval mTimeEnd;    // Time at the end of decode()
  bool mIsFormatR10G10B10A2Supported;

  bool initDecoder();
  void getVuiParams(const libgav1::DecoderBuffer *buffer);
+10 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@

#include <C2Debug.h>
#include <C2PlatformSupport.h>
#include <Codec2BufferUtils.h>
#include <SimpleC2Interface.h>

#include "C2SoftVpxDec.h"
@@ -351,6 +352,7 @@ C2SoftVpxDec::C2SoftVpxDec(
      mCodecCtx(nullptr),
      mCoreCount(1),
      mQueue(new Mutexed<ConversionQueue>) {
      mIsFormatR10G10B10A2Supported = IsFormatR10G10B10A2SupportedForLegacyRendering();
}

C2SoftVpxDec::~C2SoftVpxDec() {
@@ -804,9 +806,16 @@ status_t C2SoftVpxDec::outputBuffer(
        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;
            }
        }
    }
    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) {
+1 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ struct C2SoftVpxDec : public SimpleC2Component {
    };
    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,
+16 −0
Original line number Diff line number Diff line
@@ -118,6 +118,22 @@ static status_t _ImageCopy(View &view, const MediaImage2 *img, ImagePixel *imgBa

}  // namespace

bool IsFormatR10G10B10A2SupportedForLegacyRendering() {
    const AHardwareBuffer_Desc desc = {
        .width = 320,
        .height = 240,
        .format = AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM,
        .layers = 1,
        .usage = AHARDWAREBUFFER_USAGE_CPU_READ_RARELY | AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN |
                 AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE,
        .stride = 0,
        .rfu0 = 0,
        .rfu1 = 0,
    };

    return AHardwareBuffer_isSupported(&desc);
}

status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView &view) {
    if (view.crop().width != img->mWidth || view.crop().height != img->mHeight) {
        return BAD_VALUE;
Loading