hdr: fix dataspace range
Only set range to rull range when converting to rgb.
bug: 64227585
Change-Id: I001fe4a56a0074251a25459d72dd7a69b16a5be3
diff --git a/media/libstagefright/colorconversion/ColorConverter.cpp b/media/libstagefright/colorconversion/ColorConverter.cpp
index c7f9001..eae73fc 100644
--- a/media/libstagefright/colorconversion/ColorConverter.cpp
+++ b/media/libstagefright/colorconversion/ColorConverter.cpp
@@ -64,7 +64,7 @@
|| 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::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 @@
case OMX_COLOR_Format32bitBGRA8888:
case OMX_COLOR_Format32BitRGBA8888:
- case OMX_COLOR_Format32BitRGBA1010102:
+ case OMX_COLOR_FormatYUV444Y410:
mBpp = 4;
mStride = 4 * mWidth;
break;
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index fca9c09..c9ebbdc 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -134,6 +134,10 @@
}
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 @@
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 @@
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)
diff --git a/media/libstagefright/include/media/stagefright/ColorConverter.h b/media/libstagefright/include/media/stagefright/ColorConverter.h
index f6bd353..a6c8981 100644
--- a/media/libstagefright/include/media/stagefright/ColorConverter.h
+++ b/media/libstagefright/include/media/stagefright/ColorConverter.h
@@ -33,6 +33,8 @@
bool isValid() const;
+ bool isDstRGB() const;
+
status_t convert(
const void *srcBits,
size_t srcWidth, size_t srcHeight,