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

Commit db8556ba authored by hkuang's avatar hkuang Committed by Android (Google) Code Review
Browse files

Merge "Optimize the YUV buffer copy a little bit to skip unnecessary operation." into lmp-dev

parents 60a89850 58c4cf45
Loading
Loading
Loading
Loading
+15 −18
Original line number Diff line number Diff line
@@ -202,28 +202,25 @@ void SoftVideoDecoderOMXComponent::copyYV12FrameToOutputBuffer(
    size_t dstYStride = mIsAdaptive ? mAdaptiveMaxWidth : mWidth;
    size_t dstUVStride = dstYStride / 2;
    size_t dstHeight = mIsAdaptive ? mAdaptiveMaxHeight : mHeight;
    uint8_t *dstStart = dst;

    for (size_t i = 0; i < dstHeight; ++i) {
        if (i < mHeight) {
    for (size_t i = 0; i < mHeight; ++i) {
         memcpy(dst, srcY, mWidth);
         srcY += srcYStride;
        }
         dst += dstYStride;
    }

    for (size_t i = 0; i < dstHeight / 2; ++i) {
        if (i < mHeight / 2) {
    dst = dstStart + dstYStride * dstHeight;
    for (size_t i = 0; i < mHeight / 2; ++i) {
         memcpy(dst, srcU, mWidth / 2);
         srcU += srcUStride;
        }
         dst += dstUVStride;
    }

    for (size_t i = 0; i < dstHeight / 2; ++i) {
        if (i < mHeight / 2) {
    dst = dstStart + (5 * dstYStride * dstHeight) / 4;
    for (size_t i = 0; i < mHeight / 2; ++i) {
         memcpy(dst, srcV, mWidth / 2);
         srcV += srcVStride;
        }
         dst += dstUVStride;
    }
}