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

Commit 5343bc86 authored by Chong Zhang's avatar Chong Zhang
Browse files

hdr: fix dataspace range

Only set range to rull range when converting to rgb.

bug: 64227585
Change-Id: I001fe4a56a0074251a25459d72dd7a69b16a5be3
parent bbcbbe4f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ bool ColorConverter::isValid() const {
                    || mDstFormat == OMX_COLOR_Format32bitBGRA8888;

        case OMX_COLOR_FormatYUV420Planar16:
            return mDstFormat == OMX_COLOR_Format32BitRGBA1010102;
            return mDstFormat == OMX_COLOR_FormatYUV444Y410;

        case OMX_COLOR_FormatCbYCrY:
        case OMX_QCOM_COLOR_FormatYVU420SemiPlanar:
@@ -77,6 +77,12 @@ bool ColorConverter::isValid() const {
    }
}

bool ColorConverter::isDstRGB() const {
    return mDstFormat == OMX_COLOR_Format16bitRGB565
            || mDstFormat == OMX_COLOR_Format32BitRGBA8888
            || mDstFormat == OMX_COLOR_Format32bitBGRA8888;
}

ColorConverter::BitmapParams::BitmapParams(
        void *bits,
        size_t width, size_t height,
@@ -99,7 +105,7 @@ ColorConverter::BitmapParams::BitmapParams(

    case OMX_COLOR_Format32bitBGRA8888:
    case OMX_COLOR_Format32BitRGBA8888:
    case OMX_COLOR_Format32BitRGBA1010102:
    case OMX_COLOR_FormatYUV444Y410:
        mBpp = 4;
        mStride = 4 * mWidth;
        break;
+6 −2
Original line number Diff line number Diff line
@@ -134,6 +134,10 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
            }
            case OMX_COLOR_FormatYUV420Planar16:
            {
                // Here we would convert OMX_COLOR_FormatYUV420Planar16 into
                // OMX_COLOR_FormatYUV444Y410, and put it inside a buffer with
                // format HAL_PIXEL_FORMAT_RGBA_1010102. Surfaceflinger will
                // use render engine to convert it to RGB if needed.
                halFormat = HAL_PIXEL_FORMAT_RGBA_1010102;
                bufWidth = (mCropWidth + 1) & ~1;
                bufHeight = (mCropHeight + 1) & ~1;
@@ -152,7 +156,7 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
        CHECK(mConverter->isValid());
    } else if (mColorFormat == OMX_COLOR_FormatYUV420Planar16) {
        mConverter = new ColorConverter(
                mColorFormat, OMX_COLOR_Format32BitRGBA1010102);
                mColorFormat, OMX_COLOR_FormatYUV444Y410);
        CHECK(mConverter->isValid());
    }

@@ -380,7 +384,7 @@ skip_copying:
    if (format->findInt32("android._dataspace", (int32_t *)&dataSpace) && dataSpace != mDataSpace) {
        mDataSpace = dataSpace;

        if (mConverter != NULL) {
        if (mConverter != NULL && mConverter->isDstRGB()) {
            // graphics only supports full range RGB. ColorConverter should have
            // converted any YUV to full range.
            dataSpace = (android_dataspace)
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ struct ColorConverter {

    bool isValid() const;

    bool isDstRGB() const;

    status_t convert(
            const void *srcBits,
            size_t srcWidth, size_t srcHeight,