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

Commit 47b1d228 authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian
Browse files

Use separate stride for V plane in convertYUV420Planar8ToYV12

The code assumes that U and V planes in C2GraphicsBuffer will
always have the same stride (which may or may not be the case).

Pass in separate V stride and use that for populating the V plane.

Bug: 260137064
Test: atest CtsMediaCodecTestCases CtsMediaDecoderTestCases CtsMediaPlayerTestCases
Change-Id: I4ca67104e69e04aba92eb01d40b24d0af80609ab
parent e984374c
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -578,7 +578,8 @@ bool C2SoftAomDec::outputBuffer(
    size_t srcVStride = img->stride[AOM_PLANE_V];
    C2PlanarLayout layout = wView.layout();
    size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
    size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
    size_t dstUStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
    size_t dstVStride = layout.planes[C2PlanarLayout::PLANE_V].rowInc;

    if (img->fmt == AOM_IMG_FMT_I42016) {
        const uint16_t *srcY = (const uint16_t *)img->planes[AOM_PLANE_Y];
@@ -592,7 +593,7 @@ bool C2SoftAomDec::outputBuffer(
                    std::static_pointer_cast<const C2ColorAspectsStruct>(defaultColorAspects));
        } else {
            convertYUV420Planar16ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride / 2,
                                        srcUStride / 2, srcVStride / 2, dstYStride, dstUVStride,
                                        srcUStride / 2, srcVStride / 2, dstYStride, dstUStride,
                                        mWidth, mHeight);
        }
    } else {
@@ -600,7 +601,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];
        convertYUV420Planar8ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride,
                                   srcVStride, dstYStride, dstUVStride, mWidth, mHeight);
                                   srcVStride, dstYStride, dstUStride, dstVStride, mWidth, mHeight);
    }
    finishWork(*(int64_t*)img->user_priv, work, std::move(block));
    block = nullptr;
+6 −6
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ constexpr uint16_t kNeutralUVBitDepth10 = 512;
void convertYUV420Planar8ToYV12(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,
                                bool isMonochrome) {
                                size_t dstUStride, size_t dstVStride, uint32_t width,
                                uint32_t height, bool isMonochrome) {
    for (size_t i = 0; i < height; ++i) {
        memcpy(dstY, srcY, width);
        srcY += srcYStride;
@@ -51,8 +51,8 @@ void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, con
        for (size_t i = 0; i < (height + 1) / 2; ++i) {
            memset(dstV, kNeutralUVBitDepth8, (width + 1) / 2);
            memset(dstU, kNeutralUVBitDepth8, (width + 1) / 2);
            dstV += dstUVStride;
            dstU += dstUVStride;
            dstV += dstVStride;
            dstU += dstUStride;
        }
        return;
    }
@@ -60,13 +60,13 @@ void convertYUV420Planar8ToYV12(uint8_t *dstY, uint8_t *dstU, uint8_t *dstV, con
    for (size_t i = 0; i < (height + 1) / 2; ++i) {
        memcpy(dstV, srcV, (width + 1) / 2);
        srcV += srcVStride;
        dstV += dstUVStride;
        dstV += dstVStride;
    }

    for (size_t i = 0; i < (height + 1) / 2; ++i) {
        memcpy(dstU, srcU, (width + 1) / 2);
        srcU += srcUStride;
        dstU += dstUVStride;
        dstU += dstUStride;
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ namespace android {
void convertYUV420Planar8ToYV12(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,
                                bool isMonochrome = false);
                                size_t dstUStride, size_t dstVStride, uint32_t width,
                                uint32_t height, bool isMonochrome = false);

void convertYUV420Planar16ToY410OrRGBA1010102(
        uint32_t *dst, const uint16_t *srcY,
+6 −4
Original line number Diff line number Diff line
@@ -857,7 +857,8 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,

  C2PlanarLayout layout = wView.layout();
  size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
  size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
  size_t dstUStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
  size_t dstVStride = layout.planes[C2PlanarLayout::PLANE_V].rowInc;

  if (buffer->bitdepth == 10) {
    const uint16_t *srcY = (const uint16_t *)buffer->plane[0];
@@ -873,10 +874,10 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
    } else if (format == HAL_PIXEL_FORMAT_YCBCR_P010) {
        convertYUV420Planar16ToP010((uint16_t *)dstY, (uint16_t *)dstU, srcY, srcU, srcV,
                                    srcYStride / 2, srcUStride / 2, srcVStride / 2, dstYStride / 2,
                                    dstUVStride / 2, mWidth, mHeight, isMonochrome);
                                    dstUStride / 2, mWidth, mHeight, isMonochrome);
    } else {
        convertYUV420Planar16ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride / 2,
                                    srcUStride / 2, srcVStride / 2, dstYStride, dstUVStride, mWidth,
                                    srcUStride / 2, srcVStride / 2, dstYStride, dstUStride, mWidth,
                                    mHeight, isMonochrome);
    }
  } else {
@@ -884,7 +885,8 @@ bool C2SoftGav1Dec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
    const uint8_t *srcU = (const uint8_t *)buffer->plane[1];
    const uint8_t *srcV = (const uint8_t *)buffer->plane[2];
    convertYUV420Planar8ToYV12(dstY, dstU, dstV, srcY, srcU, srcV, srcYStride, srcUStride,
                               srcVStride, dstYStride, dstUVStride, mWidth, mHeight, isMonochrome);
                               srcVStride, dstYStride, dstUStride, dstVStride, mWidth, mHeight,
                               isMonochrome);
  }
  finishWork(buffer->user_private_data, work, std::move(block));
  block = nullptr;
+4 −3
Original line number Diff line number Diff line
@@ -603,7 +603,8 @@ void C2SoftMpeg4Dec::process(

        C2PlanarLayout layout = wView.layout();
        size_t dstYStride = layout.planes[C2PlanarLayout::PLANE_Y].rowInc;
        size_t dstUVStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
        size_t dstUStride = layout.planes[C2PlanarLayout::PLANE_U].rowInc;
        size_t dstVStride = layout.planes[C2PlanarLayout::PLANE_V].rowInc;
        size_t srcYStride = align(mWidth, 16);
        size_t srcUStride = srcYStride / 2;
        size_t srcVStride = srcYStride / 2;
@@ -613,8 +614,8 @@ void C2SoftMpeg4Dec::process(
        const uint8_t *srcV = (const uint8_t *)srcY + vStride * srcYStride * 5 / 4;

        convertYUV420Planar8ToYV12(outputBufferY, outputBufferU, outputBufferV, srcY, srcU, srcV,
                                   srcYStride, srcUStride, srcVStride, dstYStride, dstUVStride,
                                   mWidth, mHeight);
                                   srcYStride, srcUStride, srcVStride, dstYStride, dstUStride,
                                   dstVStride, mWidth, mHeight);

        inPos += inSize - (size_t)tmpInSize;
        finishWork(workIndex, work);
Loading