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

Commit d37141ea authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian Committed by Android (Google) Code Review
Browse files

Merge "gav1: Support 444 and 422 for 8bit using libyuv"

parents b018314b 406ed31b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -21,7 +21,10 @@ cc_library {
    ],

    srcs: ["C2SoftGav1Dec.cpp"],
    static_libs: ["libgav1"],
    static_libs: [
        "libgav1",
        "libyuv_static",
    ],

    apex_available: [
        "//apex_available:platform",
+19 −5
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <Codec2CommonUtils.h>
#include <Codec2Mapper.h>
#include <SimpleC2Interface.h>
#include <libyuv.h>
#include <log/log.h>
#include <media/stagefright/foundation/AUtils.h>
#include <media/stagefright/foundation/MediaDefs.h>
@@ -771,14 +772,16 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
  getHDRStaticParams(buffer, work);
  getHDR10PlusInfoData(buffer, work);

  if (!(buffer->image_format == libgav1::kImageFormatYuv420 ||
  if (buffer->bitdepth == 10 &&
      !(buffer->image_format == libgav1::kImageFormatYuv420 ||
        buffer->image_format == libgav1::kImageFormatMonochrome400)) {
    ALOGE("image_format %d not supported", buffer->image_format);
    ALOGE("image_format %d not supported for 10bit", buffer->image_format);
    mSignalledError = true;
    work->workletsProcessed = 1u;
    work->result = C2_CORRUPTED;
    return false;
  }

  const bool isMonochrome =
      buffer->image_format == libgav1::kImageFormatMonochrome400;

@@ -884,10 +887,21 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
    const uint8_t *srcY = (const uint8_t *)buffer->plane[0];
    const uint8_t *srcU = (const uint8_t *)buffer->plane[1];
    const uint8_t *srcV = (const uint8_t *)buffer->plane[2];

    if (buffer->image_format == libgav1::kImageFormatYuv444) {
        libyuv::I444ToI420(srcY, srcYStride, srcU, srcUStride, srcV, srcVStride,
                           dstY, dstYStride, dstU, dstUStride, dstV, dstVStride,
                           mWidth, mHeight);
    } else if (buffer->image_format == libgav1::kImageFormatYuv422) {
        libyuv::I422ToI420(srcY, srcYStride, srcU, srcUStride, srcV, srcVStride,
                           dstY, dstYStride, dstU, dstUStride, dstV, dstVStride,
                           mWidth, mHeight);
    } else {
        convertYUV420Planar8ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride,
                                   srcVStride, dstYStride, dstUStride, dstVStride, mWidth, mHeight,
                                   isMonochrome);
    }
  }
  finishWork(buffer->user_private_data, work, std::move(block));
  block = nullptr;
  return true;