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

Commit e106cd87 authored by Jessie Hao's avatar Jessie Hao
Browse files

Change lock to lockYCbCr for to get the actual y,cb,cr.



Found when use google sw decoder,below CTS case will fail:
CtsMediaTestCases android.media.cts.DecodeAccuracyTest 8,12,24,28,40,44.
Checked the failed case,test video height is not 4 bytes align,
eg 426x182,854x362,1920x818.
Some platform GPU may need height 4 bytes align, so the dst_v,dst_u calculation
should consider height alignment.
Here change lock to lockYCbCr to get the actual y,cb,cr.

Change-Id: Ibbccbad3936ab36ee2c25773367b0fbb67d9226e
Signed-off-by: default avatarJessie Hao <juan.hao@nxp.com>
parent 4cebb2ca
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -266,10 +266,21 @@ std::list<FrameRenderTracker::Info> SoftwareRenderer::render(

    Rect bounds(mCropWidth, mCropHeight);

    void *dst;
    void *dst = NULL;
    struct android_ycbcr ycbcr;
    if ( !mConverter &&
         (mColorFormat == OMX_COLOR_FormatYUV420Planar ||
         mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar ||
         mColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar ||
         mColorFormat == OMX_COLOR_FormatYUV420Planar16)) {
        CHECK_EQ(0, mapper.lockYCbCr(buf->handle,
                GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_RARELY,
                bounds, &ycbcr));
    } else {
        CHECK_EQ(0, mapper.lock(buf->handle,
                GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_RARELY,
                bounds, &dst));
    }

    // TODO move the other conversions also into ColorConverter, and
    // fix cropping issues (when mCropLeft/Top != 0 or mWidth != mCropWidth)
@@ -291,12 +302,10 @@ std::list<FrameRenderTracker::Info> SoftwareRenderer::render(
        src_u +=(mCropLeft + mCropTop * mWidth / 2)/2;
        src_v +=(mCropLeft + mCropTop * mWidth / 2)/2;

        uint8_t *dst_y = (uint8_t *)dst;
        size_t dst_y_size = buf->stride * buf->height;
        uint8_t *dst_y = (uint8_t *)ycbcr.y;
        uint8_t *dst_v = (uint8_t *)ycbcr.cr;
        uint8_t *dst_u = (uint8_t *)ycbcr.cb;
        size_t dst_c_stride = ALIGN(buf->stride / 2, 16);
        size_t dst_c_size = dst_c_stride * buf->height / 2;
        uint8_t *dst_v = dst_y + dst_y_size;
        uint8_t *dst_u = dst_v + dst_c_size;

        dst_y += mCropTop * buf->stride + mCropLeft;
        dst_v += (mCropTop/2) * dst_c_stride + mCropLeft/2;
@@ -327,12 +336,10 @@ std::list<FrameRenderTracker::Info> SoftwareRenderer::render(
        src_u += (mCropLeft + mCropTop * mWidth / 2) / 2;
        src_v += (mCropLeft + mCropTop * mWidth / 2) / 2;

        uint8_t *dst_y = (uint8_t *)dst;
        size_t dst_y_size = buf->stride * buf->height;
        uint8_t *dst_y = (uint8_t *)ycbcr.y;
        uint8_t *dst_v = (uint8_t *)ycbcr.cr;
        uint8_t *dst_u = (uint8_t *)ycbcr.cb;
        size_t dst_c_stride = ALIGN(buf->stride / 2, 16);
        size_t dst_c_size = dst_c_stride * buf->height / 2;
        uint8_t *dst_v = dst_y + dst_y_size;
        uint8_t *dst_u = dst_v + dst_c_size;

        dst_y += mCropTop * buf->stride + mCropLeft;
        dst_v += (mCropTop / 2) * dst_c_stride + mCropLeft / 2;
@@ -367,13 +374,10 @@ std::list<FrameRenderTracker::Info> SoftwareRenderer::render(
        src_y += mCropLeft + mCropTop * mWidth;
        src_uv += (mCropLeft + mCropTop * mWidth) / 2;

        uint8_t *dst_y = (uint8_t *)dst;

        size_t dst_y_size = buf->stride * buf->height;
        uint8_t *dst_y = (uint8_t *)ycbcr.y;
        uint8_t *dst_v = (uint8_t *)ycbcr.cr;
        uint8_t *dst_u = (uint8_t *)ycbcr.cb;
        size_t dst_c_stride = ALIGN(buf->stride / 2, 16);
        size_t dst_c_size = dst_c_stride * buf->height / 2;
        uint8_t *dst_v = dst_y + dst_y_size;
        uint8_t *dst_u = dst_v + dst_c_size;

        dst_y += mCropTop * buf->stride + mCropLeft;
        dst_v += (mCropTop/2) * dst_c_stride + mCropLeft/2;