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

Commit 61a02211 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix software decoder display issue."

parents 05dd1900 ac19c3d2
Loading
Loading
Loading
Loading
+20 −23
Original line number Diff line number Diff line
@@ -504,30 +504,28 @@ void C2SoftAomDec::process(const std::unique_ptr<C2Work>& work,
}

static void copyOutputBufferToYuvPlanarFrame(
        uint8_t *dst, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,
        uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
        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) {
    uint8_t* dstStart = dst;

    for (size_t i = 0; i < height; ++i) {
        memcpy(dst, srcY, width);
        memcpy(dstY, srcY, width);
        srcY += srcYStride;
        dst += dstYStride;
        dstY += dstYStride;
    }

    dst = dstStart + dstYStride * height;
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, srcV, width / 2);
        memcpy(dstV, srcV, width / 2);
        srcV += srcVStride;
        dst += dstUVStride;
        dstV += dstUVStride;
    }

    dst = dstStart + (dstYStride * height) + (dstUVStride * height / 2);
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, srcU, width / 2);
        memcpy(dstU, srcU, width / 2);
        srcU += srcUStride;
        dst += dstUVStride;
        dstU += dstUVStride;
    }
}

@@ -594,16 +592,12 @@ static void convertYUV420Planar16ToY410(uint32_t *dst,
    return;
}

static void convertYUV420Planar16ToYUV420Planar(uint8_t *dst,
static void convertYUV420Planar16ToYUV420Planar(
        uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
        const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
        size_t srcYStride, size_t srcUStride, size_t srcVStride,
        size_t dstYStride, size_t dstUVStride, size_t width, size_t height) {

    uint8_t *dstY = (uint8_t *)dst;
    size_t dstYSize = dstYStride * height;
    size_t dstUVSize = dstUVStride * height / 2;
    uint8_t *dstV = dstY + dstYSize;
    uint8_t *dstU = dstV + dstUVSize;
        size_t dstYStride, size_t dstUVStride,
        size_t width, size_t height) {

    for (size_t y = 0; y < height; ++y) {
        for (size_t x = 0; x < width; ++x) {
@@ -694,7 +688,9 @@ bool C2SoftAomDec::outputBuffer(
          block->width(), block->height(), mWidth, mHeight,
          (int)*(int64_t*)img->user_priv);

    uint8_t* dst = const_cast<uint8_t*>(wView.data()[C2PlanarLayout::PLANE_Y]);
    uint8_t* dstY = const_cast<uint8_t*>(wView.data()[C2PlanarLayout::PLANE_Y]);
    uint8_t* dstU = const_cast<uint8_t*>(wView.data()[C2PlanarLayout::PLANE_U]);
    uint8_t* dstV = const_cast<uint8_t*>(wView.data()[C2PlanarLayout::PLANE_V]);
    size_t srcYStride = img->stride[AOM_PLANE_Y];
    size_t srcUStride = img->stride[AOM_PLANE_U];
    size_t srcVStride = img->stride[AOM_PLANE_V];
@@ -708,13 +704,14 @@ bool C2SoftAomDec::outputBuffer(
        const uint16_t *srcV = (const uint16_t *)img->planes[AOM_PLANE_V];

        if (format == HAL_PIXEL_FORMAT_RGBA_1010102) {
            convertYUV420Planar16ToY410((uint32_t *)dst, srcY, srcU, srcV, srcYStride / 2,
            convertYUV420Planar16ToY410((uint32_t *)dstY, srcY, srcU, srcV, srcYStride / 2,
                                    srcUStride / 2, srcVStride / 2,
                                    dstYStride / sizeof(uint32_t),
                                    mWidth, mHeight);
        } else {
            convertYUV420Planar16ToYUV420Planar(dst, srcY, srcU, srcV, srcYStride / 2,
                                    srcUStride / 2, srcVStride / 2,
            convertYUV420Planar16ToYUV420Planar(dstY, dstU, dstV,
                                    srcY, srcU, srcV,
                                    srcYStride / 2, srcUStride / 2, srcVStride / 2,
                                    dstYStride, dstUVStride,
                                    mWidth, mHeight);
        }
@@ -723,7 +720,7 @@ bool C2SoftAomDec::outputBuffer(
        const uint8_t *srcU = (const uint8_t *)img->planes[AOM_PLANE_U];
        const uint8_t *srcV = (const uint8_t *)img->planes[AOM_PLANE_V];
        copyOutputBufferToYuvPlanarFrame(
                dst, srcY, srcU, srcV,
                dstY, dstU, dstV, srcY, srcU, srcV,
                srcYStride, srcUStride, srcVStride,
                dstYStride, dstUVStride,
                mWidth, mHeight);
+34 −32
Original line number Diff line number Diff line
@@ -470,33 +470,28 @@ void C2SoftGav1Dec::process(const std::unique_ptr<C2Work> &work,
  }
}

static void copyOutputBufferToYV12Frame(uint8_t *dst, const uint8_t *srcY,
                                        const uint8_t *srcU,
                                        const uint8_t *srcV, size_t srcYStride,
                                        size_t srcUStride, size_t srcVStride,
static void copyOutputBufferToYV12Frame(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
                                        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) {
    memcpy(dst, srcY, width);
    memcpy(dstY, srcY, width);
    srcY += srcYStride;
    dst += dstYStride;
    dstY += dstYStride;
  }

  dst = dstStart + dstYStride * height;
  for (size_t i = 0; i < height / 2; ++i) {
    memcpy(dst, srcV, width / 2);
    memcpy(dstV, srcV, width / 2);
    srcV += srcVStride;
    dst += dstUVStride;
    dstV += dstUVStride;
  }

  dst = dstStart + (dstYStride * height) + (dstUVStride * height / 2);
  for (size_t i = 0; i < height / 2; ++i) {
    memcpy(dst, srcU, width / 2);
    memcpy(dstU, srcU, width / 2);
    srcU += srcUStride;
    dst += dstUVStride;
    dstU += dstUVStride;
  }
}

@@ -568,15 +563,11 @@ 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) {
  uint8_t *dstY = (uint8_t *)dst;
  size_t dstYSize = dstStride * height;
  size_t dstUVStride = align(dstStride / 2, 16);
  size_t dstUVSize = dstUVStride * height / 2;
  uint8_t *dstV = dstY + dstYSize;
  uint8_t *dstU = dstV + dstUVSize;
    uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
    const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
    size_t srcYStride, size_t srcUStride, size_t srcVStride,
    size_t dstYStride, size_t dstUVStride,
    size_t width, size_t height) {

  for (size_t y = 0; y < height; ++y) {
    for (size_t x = 0; x < width; ++x) {
@@ -584,7 +575,7 @@ static void convertYUV420Planar16ToYUV420Planar(
    }

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

  for (size_t y = 0; y < (height + 1) / 2; ++y) {
@@ -679,11 +670,17 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
  ALOGV("provided (%dx%d) required (%dx%d), out frameindex %d", block->width(),
        block->height(), mWidth, mHeight, (int)buffer->user_private_data);

  uint8_t *dst = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]);
  uint8_t *dstY = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]);
  uint8_t *dstU = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_U]);
  uint8_t *dstV = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_V]);
  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];
    const uint16_t *srcU = (const uint16_t *)buffer->plane[1];
@@ -691,19 +688,24 @@ 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,
          (uint32_t *)dstY, srcY, srcU, srcV, srcYStride / 2, srcUStride / 2,
          srcVStride / 2, align(mWidth, 16), mWidth, mHeight);
    } else {
      convertYUV420Planar16ToYUV420Planar(dst, srcY, srcU, srcV, srcYStride / 2,
                                          srcUStride / 2, srcVStride / 2,
                                          align(mWidth, 16), mWidth, mHeight);
      convertYUV420Planar16ToYUV420Planar(dstY, dstU, dstV,
                                          srcY, srcU, srcV,
                                          srcYStride / 2, srcUStride / 2, srcVStride / 2,
                                          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);
    copyOutputBufferToYV12Frame(dstY, dstU, dstV,
                                srcY, srcU, srcV,
                                srcYStride, srcUStride, srcVStride,
                                dstYStride, dstUVStride,
                                mWidth, mHeight);
  }
  finishWork(buffer->user_private_data, work, std::move(block));
  block = nullptr;
+14 −11
Original line number Diff line number Diff line
@@ -467,34 +467,34 @@ bool C2SoftMpeg4Dec::handleResChange(const std::unique_ptr<C2Work> &work) {
/* TODO: can remove temporary copy after library supports writing to display
 * buffer Y, U and V plane pointers using stride info. */
static void copyOutputBufferToYuvPlanarFrame(
        uint8_t *dst, uint8_t *src,
        uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, uint8_t *src,
        size_t dstYStride, size_t dstUVStride,
        size_t srcYStride, uint32_t width,
        uint32_t height) {
    size_t srcUVStride = srcYStride / 2;
    uint8_t *srcStart = src;
    uint8_t *dstStart = dst;

    size_t vStride = align(height, 16);
    for (size_t i = 0; i < height; ++i) {
         memcpy(dst, src, width);
         memcpy(dstY, src, width);
         src += srcYStride;
         dst += dstYStride;
         dstY += dstYStride;
    }

    /* U buffer */
    src = srcStart + vStride * srcYStride;
    dst = dstStart + (dstYStride * height) + (dstUVStride * height / 2);
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, src, width / 2);
         memcpy(dstU, src, width / 2);
         src += srcUVStride;
         dst += dstUVStride;
         dstU += dstUVStride;
    }

    /* V buffer */
    src = srcStart + vStride * srcYStride * 5 / 4;
    dst = dstStart + (dstYStride * height);
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, src, width / 2);
         memcpy(dstV, src, width / 2);
         src += srcUVStride;
         dst += dstUVStride;
         dstV += dstUVStride;
    }
}

@@ -675,11 +675,14 @@ void C2SoftMpeg4Dec::process(
        }

        uint8_t *outputBufferY = wView.data()[C2PlanarLayout::PLANE_Y];
        uint8_t *outputBufferU = wView.data()[C2PlanarLayout::PLANE_U];
        uint8_t *outputBufferV = wView.data()[C2PlanarLayout::PLANE_V];

        C2PlanarLayout layout = wView.layout();
        size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
        size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
        (void)copyOutputBufferToYuvPlanarFrame(
                outputBufferY,
                outputBufferY, outputBufferU, outputBufferV,
                mOutputBuffer[mNumSamplesOutput & 1],
                dstYStride, dstUVStride,
                align(mWidth, 16), mWidth, mHeight);
+26 −25
Original line number Diff line number Diff line
@@ -630,31 +630,30 @@ void C2SoftVpxDec::process(
}

static void copyOutputBufferToYuvPlanarFrame(
        uint8_t *dst, const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,
        uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
        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) {
    uint8_t *dstStart = dst;

    for (size_t i = 0; i < height; ++i) {
         memcpy(dst, srcY, width);
         memcpy(dstY, srcY, width);
         srcY += srcYStride;
         dst += dstYStride;
         dstY += dstYStride;
    }

    dst = dstStart + dstYStride * height;
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, srcV, width / 2);
         memcpy(dstV, srcV, width / 2);
         srcV += srcVStride;
         dst += dstUVStride;
         dstV += dstUVStride;
    }

    dst = dstStart + (dstYStride * height) + (dstUVStride * height / 2);
    for (size_t i = 0; i < height / 2; ++i) {
         memcpy(dst, srcU, width / 2);
         memcpy(dstU, srcU, width / 2);
         srcU += srcUStride;
         dst += dstUVStride;
         dstU += dstUVStride;
    }

}

static void convertYUV420Planar16ToY410(uint32_t *dst,
@@ -720,16 +719,12 @@ static void convertYUV420Planar16ToY410(uint32_t *dst,
    return;
}

static void convertYUV420Planar16ToYUV420Planar(uint8_t *dst,
static void convertYUV420Planar16ToYUV420Planar(
        uint8_t *dstY, uint8_t *dstU, uint8_t *dstV,
        const uint16_t *srcY, const uint16_t *srcU, const uint16_t *srcV,
        size_t srcYStride, size_t srcUStride, size_t srcVStride,
        size_t dstYStride, size_t dstUVStride, size_t width, size_t height) {

    uint8_t *dstY = (uint8_t *)dst;
    size_t dstYSize = dstYStride * height;
    size_t dstUVSize = dstUVStride * height / 2;
    uint8_t *dstV = dstY + dstYSize;
    uint8_t *dstU = dstV + dstUVSize;
        size_t dstYStride, size_t dstUVStride,
        size_t width, size_t height) {

    for (size_t y = 0; y < height; ++y) {
        for (size_t x = 0; x < width; ++x) {
@@ -822,7 +817,10 @@ status_t C2SoftVpxDec::outputBuffer(
           block->width(), block->height(), mWidth, mHeight,
           ((c2_cntr64_t *)img->user_priv)->peekll());

    uint8_t *dst = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]);
    uint8_t *dstY = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]);
    uint8_t *dstU = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_U]);
    uint8_t *dstV = const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_V]);

    size_t srcYStride = img->stride[VPX_PLANE_Y];
    size_t srcUStride = img->stride[VPX_PLANE_U];
    size_t srcVStride = img->stride[VPX_PLANE_V];
@@ -841,18 +839,18 @@ status_t C2SoftVpxDec::outputBuffer(
            constexpr size_t kHeight = 64;
            for (; i < mHeight; i += kHeight) {
                queue->entries.push_back(
                        [dst, srcY, srcU, srcV,
                        [dstY, srcY, srcU, srcV,
                         srcYStride, srcUStride, srcVStride, dstYStride,
                         width = mWidth, height = std::min(mHeight - i, kHeight)] {
                            convertYUV420Planar16ToY410(
                                    (uint32_t *)dst, srcY, srcU, srcV, srcYStride / 2,
                                    (uint32_t *)dstY, srcY, srcU, srcV, srcYStride / 2,
                                    srcUStride / 2, srcVStride / 2, dstYStride / sizeof(uint32_t),
                                    width, height);
                        });
                srcY += srcYStride / 2 * kHeight;
                srcU += srcUStride / 2 * (kHeight / 2);
                srcV += srcVStride / 2 * (kHeight / 2);
                dst += dstYStride * kHeight;
                dstY += dstYStride * kHeight;
            }
            CHECK_EQ(0u, queue->numPending);
            queue->numPending = queue->entries.size();
@@ -861,8 +859,9 @@ status_t C2SoftVpxDec::outputBuffer(
                queue.waitForCondition(queue->cond);
            }
        } else {
            convertYUV420Planar16ToYUV420Planar(dst, srcY, srcU, srcV, srcYStride / 2,
                                                srcUStride / 2, srcVStride / 2,
            convertYUV420Planar16ToYUV420Planar(dstY, dstU, dstV,
                                                srcY, srcU, srcV,
                                                srcYStride / 2, srcUStride / 2, srcVStride / 2,
                                                dstYStride, dstUVStride,
                                                mWidth, mHeight);
        }
@@ -870,8 +869,10 @@ status_t C2SoftVpxDec::outputBuffer(
        const uint8_t *srcY = (const uint8_t *)img->planes[VPX_PLANE_Y];
        const uint8_t *srcU = (const uint8_t *)img->planes[VPX_PLANE_U];
        const uint8_t *srcV = (const uint8_t *)img->planes[VPX_PLANE_V];

        copyOutputBufferToYuvPlanarFrame(
                dst, srcY, srcU, srcV,
                dstY, dstU, dstV,
                srcY, srcU, srcV,
                srcYStride, srcUStride, srcVStride,
                dstYStride, dstUVStride,
                mWidth, mHeight);