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

Commit 406ed31b authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian
Browse files

gav1: Support 444 and 422 for 8bit using libyuv

The android platform includes libyuv and we can use that to support
444 and 422 av1 content using the software decoder. This will enable
444 and 422 support for AVIF images as well.

Bug: 261112792
Change-Id: I2e08fa4b760fcb772a97be6ee62259d8762b2c12
Test: decode images on an oriole device
parent bd6eb57a
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;