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

Commit b36ae378 authored by James Zern's avatar James Zern Committed by Ray Essick
Browse files

C2SoftGav1Dec: sync copyOutput*() w/other codecs

this matches the destination stride fixes in ag/7467361

Bug: 131844219
Bug: 160760307
Bug: 163000757
Test: playback on a sargo device
Change-Id: I61aef91556ece556ca6465f984a1d72aba745d2d
Merged-In: Ib8b283a0fb4bacb9b4f561d83b4d38727a3116d4
Merged-In: I536d32ea78ce278637163e2b64ed24b8c689a40e
parent 6a3cb347
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -470,13 +470,12 @@ void C2SoftGav1Dec::process(const std::unique_ptr<C2Work> &work,
  }
}

static void copyOutputBufferToYV12Frame(uint8_t *dst, const uint8_t *srcY,
static void copyOutputBufferToYuvPlanarFrame(uint8_t *dst, const uint8_t *srcY,
                                             const uint8_t *srcU,
                                             const uint8_t *srcV, size_t srcYStride,
                                             size_t srcUStride, size_t srcVStride,
                                             size_t dstYStride, size_t dstUVStride,
                                             uint32_t width, uint32_t height) {
  const size_t dstYStride = align(width, 16);
  const size_t dstUVStride = align(dstYStride / 2, 16);
  uint8_t *const dstStart = dst;

  for (size_t i = 0; i < height; ++i) {
@@ -570,10 +569,10 @@ static void convertYUV420Planar16ToY410(uint32_t *dst, const uint16_t *srcY,
static void convertYUV420Planar16ToYUV420Planar(
    uint8_t *dst, const uint16_t *srcY, const uint16_t *srcU,
    const uint16_t *srcV, size_t srcYStride, size_t srcUStride,
    size_t srcVStride, size_t dstStride, size_t width, size_t height) {
    size_t srcVStride, size_t dstYStride, size_t dstUVStride,
    size_t width, size_t height) {
  uint8_t *dstY = (uint8_t *)dst;
  size_t dstYSize = dstStride * height;
  size_t dstUVStride = align(dstStride / 2, 16);
  size_t dstYSize = dstYStride * height;
  size_t dstUVSize = dstUVStride * height / 2;
  uint8_t *dstV = dstY + dstYSize;
  uint8_t *dstU = dstV + dstUVSize;
@@ -584,7 +583,7 @@ static void convertYUV420Planar16ToYUV420Planar(
    }

    srcY += srcYStride;
    dstY += dstStride;
    dstY += dstYStride;
  }

  for (size_t y = 0; y < (height + 1) / 2; ++y) {
@@ -683,6 +682,9 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
  size_t srcYStride = buffer->stride[0];
  size_t srcUStride = buffer->stride[1];
  size_t srcVStride = buffer->stride[2];
  C2PlanarLayout layout = wView.layout();
  size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
  size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;

  if (buffer->bitdepth == 10) {
    const uint16_t *srcY = (const uint16_t *)buffer->plane[0];
@@ -692,18 +694,19 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
    if (format == HAL_PIXEL_FORMAT_RGBA_1010102) {
      convertYUV420Planar16ToY410(
          (uint32_t *)dst, srcY, srcU, srcV, srcYStride / 2, srcUStride / 2,
          srcVStride / 2, align(mWidth, 16), mWidth, mHeight);
          srcVStride / 2, dstYStride / sizeof(uint32_t), mWidth, mHeight);
    } else {
      convertYUV420Planar16ToYUV420Planar(dst, srcY, srcU, srcV, srcYStride / 2,
                                          srcUStride / 2, srcVStride / 2,
                                          align(mWidth, 16), mWidth, mHeight);
                                          dstYStride, dstUVStride, mWidth, mHeight);
    }
  } else {
    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];
    copyOutputBufferToYV12Frame(dst, srcY, srcU, srcV, srcYStride, srcUStride,
                                srcVStride, mWidth, mHeight);
    copyOutputBufferToYuvPlanarFrame(dst, srcY, srcU, srcV, srcYStride, srcUStride,
                                     srcVStride, dstYStride, dstUVStride,
                                     mWidth, mHeight);
  }
  finishWork(buffer->user_private_data, work, std::move(block));
  block = nullptr;