Merge "Add HDR metadata types to graphics/common"
This commit is contained in:
commit
fdbee4d3c4
6 changed files with 334 additions and 1 deletions
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Copyright (c) 2019, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.graphics.common;
|
||||
|
||||
/**
|
||||
* HDR static metadata extension as specified by CTA-861.3.
|
||||
*
|
||||
* This is an AIDL counterpart of the NDK struct `AHdrMetadata_cta861_3`.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Cta861_3 {
|
||||
/**
|
||||
* Maximum content light level.
|
||||
*/
|
||||
float maxContentLightLevel;
|
||||
/**
|
||||
* Maximum frame average light level.
|
||||
*/
|
||||
float maxFrameAverageLightLevel;
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/**
|
||||
* Copyright (c) 2019, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.graphics.common;
|
||||
import android.hardware.graphics.common.XyColor;
|
||||
|
||||
/**
|
||||
* Mastering display metadata as specified by SMPTE ST 2086.
|
||||
*
|
||||
* This is an AIDL counterpart of the NDK struct `AHdrMetadata_smpte2086`.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable Smpte2086 {
|
||||
/**
|
||||
* CIE XYZ chromaticity for red in the RGB primaries.
|
||||
*/
|
||||
XyColor primaryRed;
|
||||
/**
|
||||
* CIE XYZ chromaticity for green in the RGB primaries.
|
||||
*/
|
||||
XyColor primaryGreen;
|
||||
/**
|
||||
* CIE XYZ chromaticity for blue in the RGB primaries.
|
||||
*/
|
||||
XyColor primaryBlue;
|
||||
/**
|
||||
* CIE XYZ chromaticity for the white point.
|
||||
*/
|
||||
XyColor whitePoint;
|
||||
/**
|
||||
* Maximum luminance in candelas per square meter.
|
||||
*/
|
||||
float maxLuminance;
|
||||
/**
|
||||
* Minimum luminance in candelas per square meter.
|
||||
*/
|
||||
float minLuminance;
|
||||
}
|
|
@ -279,4 +279,43 @@ enum StandardMetadataType {
|
|||
* 4 bytes written in little endian.
|
||||
*/
|
||||
BLEND_MODE = 17,
|
||||
|
||||
/**
|
||||
* Can be used to get or set static HDR metadata specified by SMPTE ST 2086.
|
||||
*
|
||||
* This metadata is a stable aidl android.hardware.graphics.common.Smpte2086.
|
||||
*
|
||||
* This is not used in tone mapping until it has been set for the first time.
|
||||
*
|
||||
* When it is encoded into a byte stream, each float member is represented by 4 bytes written in
|
||||
* little endian. The ordering of float values follows the definition of Smpte2086 and XyColor.
|
||||
* If this is unset when encoded into a byte stream, the byte stream is empty.
|
||||
*/
|
||||
SMPTE2086 = 18,
|
||||
|
||||
/**
|
||||
* Can be used to get or set static HDR metadata specified by CTA 861.3.
|
||||
*
|
||||
* This metadata is a stable aidl android.hardware.graphics.common.Cta861_3.
|
||||
*
|
||||
* This is not used in tone mapping until it has been set for the first time.
|
||||
*
|
||||
* When it is encoded into a byte stream, each float member is represented by 4 bytes written in
|
||||
* little endian. The ordering of float values follows the definition of Cta861_3.
|
||||
* If this is unset when encoded into a byte stream, the byte stream is empty.
|
||||
*/
|
||||
CTA861_3 = 19,
|
||||
|
||||
/**
|
||||
* Can be used to get or set dynamic HDR metadata specified by SMPTE ST 2094-40:2016.
|
||||
*
|
||||
* This metadata is uint8_t byte array.
|
||||
*
|
||||
* This is not used in tone mapping until it has been set for the first time.
|
||||
*
|
||||
* When it is encoded into a byte stream, the length of the HDR metadata byte array is written
|
||||
* using 8 bytes in little endian. It is followed by the uint8_t byte array.
|
||||
* If this is unset when encoded into a byte stream, the byte stream is empty.
|
||||
*/
|
||||
SMPTE2094_40 = 20,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/**
|
||||
* Copyright (c) 2019, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.hardware.graphics.common;
|
||||
|
||||
/**
|
||||
* Chromaticity based on 2 parameters.
|
||||
*
|
||||
* This is an AIDL counterpart of the NDK struct `AColor_xy`.
|
||||
*
|
||||
* @note This can be used to represent any 2-dimensional chromaticity.
|
||||
*/
|
||||
@VintfStability
|
||||
parcelable XyColor {
|
||||
float x;
|
||||
float y;
|
||||
}
|
|
@ -478,7 +478,7 @@ interface IMapper {
|
|||
* particular Metadata field.
|
||||
*
|
||||
* The framework may attempt to set the following StandardMetadataType
|
||||
* values: DATASPACE, PER_FRAME_METADATA, PER_FRAME_METADATA_BLOB and BLEND_MODE.
|
||||
* values: DATASPACE, SMPTE2086, CTA861_3, SMPTE2094_40 and BLEND_MODE.
|
||||
* We strongly encourage everyone to support setting as many of those fields as
|
||||
* possible. If a device's Composer implementation supports a field, it should be
|
||||
* supported here. Over time these metadata fields will be moved out of
|
||||
|
|
|
@ -44,11 +44,13 @@ using android::hardware::graphics::common::V1_2::BufferUsage;
|
|||
using android::hardware::graphics::common::V1_2::PixelFormat;
|
||||
using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
|
||||
using aidl::android::hardware::graphics::common::BlendMode;
|
||||
using aidl::android::hardware::graphics::common::Cta861_3;
|
||||
using aidl::android::hardware::graphics::common::Dataspace;
|
||||
using aidl::android::hardware::graphics::common::ExtendableType;
|
||||
using aidl::android::hardware::graphics::common::PlaneLayout;
|
||||
using aidl::android::hardware::graphics::common::PlaneLayoutComponent;
|
||||
using aidl::android::hardware::graphics::common::PlaneLayoutComponentType;
|
||||
using aidl::android::hardware::graphics::common::Smpte2086;
|
||||
using aidl::android::hardware::graphics::common::StandardMetadataType;
|
||||
|
||||
using DecodeFunction = std::function<void(const IMapper::BufferDescriptorInfo& descriptorInfo,
|
||||
|
@ -1019,6 +1021,42 @@ TEST_P(GraphicsMapperHidlTest, GetBlendMode) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::get(Smpte2086)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetSmpte2086) {
|
||||
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Smpte2086,
|
||||
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<Smpte2086> smpte2086;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2086(vec, &smpte2086));
|
||||
EXPECT_FALSE(smpte2086.has_value());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::get(Cta861_3)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetCta861_3) {
|
||||
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Cta861_3,
|
||||
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<Cta861_3> cta861_3;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeCta861_3(vec, &cta861_3));
|
||||
EXPECT_FALSE(cta861_3.has_value());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::get(Smpte2094_40)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetSmpte2094_40) {
|
||||
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Smpte2094_40,
|
||||
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<std::vector<uint8_t>> smpte2094_40;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2094_40(vec, &smpte2094_40));
|
||||
EXPECT_FALSE(smpte2094_40.has_value());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::get(metadata) with a bad buffer
|
||||
*/
|
||||
|
@ -1072,6 +1110,15 @@ TEST_P(GraphicsMapperHidlTest, GetMetadataBadValue) {
|
|||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->get(bufferHandle, gralloc4::MetadataType_BlendMode, &vec));
|
||||
ASSERT_EQ(0, vec.size());
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->get(bufferHandle, gralloc4::MetadataType_Smpte2086, &vec));
|
||||
ASSERT_EQ(0, vec.size());
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->get(bufferHandle, gralloc4::MetadataType_Cta861_3, &vec));
|
||||
ASSERT_EQ(0, vec.size());
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->get(bufferHandle, gralloc4::MetadataType_Smpte2094_40, &vec));
|
||||
ASSERT_EQ(0, vec.size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1427,6 +1474,90 @@ TEST_P(GraphicsMapperHidlTest, SetBlendMode) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::set(Smpte2086)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, SetSmpte2086) {
|
||||
/**
|
||||
* DISPLAY_P3 is a color space that uses the DCI_P3 primaries,
|
||||
* the D65 white point and the SRGB transfer functions.
|
||||
* Rendering Intent: Colorimetric
|
||||
* Primaries:
|
||||
* x y
|
||||
* green 0.265 0.690
|
||||
* blue 0.150 0.060
|
||||
* red 0.680 0.320
|
||||
* white (D65) 0.3127 0.3290
|
||||
*/
|
||||
std::optional<Smpte2086> smpte2086;
|
||||
smpte2086->primaryRed.x = 0.680;
|
||||
smpte2086->primaryRed.y = 0.320;
|
||||
smpte2086->primaryGreen.x = 0.265;
|
||||
smpte2086->primaryGreen.y = 0.690;
|
||||
smpte2086->primaryBlue.x = 0.150;
|
||||
smpte2086->primaryBlue.y = 0.060;
|
||||
smpte2086->whitePoint.x = 0.3127;
|
||||
smpte2086->whitePoint.y = 0.3290;
|
||||
smpte2086->maxLuminance = 100.0;
|
||||
smpte2086->minLuminance = 0.1;
|
||||
|
||||
hidl_vec<uint8_t> vec;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::encodeSmpte2086(smpte2086, &vec));
|
||||
|
||||
testSet(mDummyDescriptorInfo, gralloc4::MetadataType_Smpte2086, vec,
|
||||
[&](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<Smpte2086> realSmpte2086;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2086(vec, &realSmpte2086));
|
||||
ASSERT_TRUE(realSmpte2086.has_value());
|
||||
EXPECT_EQ(smpte2086->primaryRed.x, realSmpte2086->primaryRed.x);
|
||||
EXPECT_EQ(smpte2086->primaryRed.y, realSmpte2086->primaryRed.y);
|
||||
EXPECT_EQ(smpte2086->primaryGreen.x, realSmpte2086->primaryGreen.x);
|
||||
EXPECT_EQ(smpte2086->primaryGreen.y, realSmpte2086->primaryGreen.y);
|
||||
EXPECT_EQ(smpte2086->primaryBlue.x, realSmpte2086->primaryBlue.x);
|
||||
EXPECT_EQ(smpte2086->primaryBlue.y, realSmpte2086->primaryBlue.y);
|
||||
EXPECT_EQ(smpte2086->whitePoint.x, realSmpte2086->whitePoint.x);
|
||||
EXPECT_EQ(smpte2086->whitePoint.y, realSmpte2086->whitePoint.y);
|
||||
EXPECT_EQ(smpte2086->maxLuminance, realSmpte2086->maxLuminance);
|
||||
EXPECT_EQ(smpte2086->minLuminance, realSmpte2086->minLuminance);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::set(Cta8613)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, SetCta861_3) {
|
||||
std::optional<Cta861_3> cta861_3;
|
||||
cta861_3->maxContentLightLevel = 78.0;
|
||||
cta861_3->maxFrameAverageLightLevel = 62.0;
|
||||
|
||||
hidl_vec<uint8_t> vec;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::encodeCta861_3(cta861_3, &vec));
|
||||
|
||||
testSet(mDummyDescriptorInfo, gralloc4::MetadataType_Cta861_3, vec,
|
||||
[&](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<Cta861_3> realCta861_3;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeCta861_3(vec, &realCta861_3));
|
||||
ASSERT_TRUE(realCta861_3.has_value());
|
||||
EXPECT_EQ(cta861_3->maxContentLightLevel, realCta861_3->maxContentLightLevel);
|
||||
EXPECT_EQ(cta861_3->maxFrameAverageLightLevel,
|
||||
realCta861_3->maxFrameAverageLightLevel);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::set(Smpte2094_40)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, SetSmpte2094_40) {
|
||||
hidl_vec<uint8_t> vec;
|
||||
|
||||
testSet(mDummyDescriptorInfo, gralloc4::MetadataType_Smpte2094_40, vec,
|
||||
[&](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
|
||||
std::optional<std::vector<uint8_t>> realSmpte2094_40;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2094_40(vec, &realSmpte2094_40));
|
||||
EXPECT_FALSE(realSmpte2094_40.has_value());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::set(metadata) with a bad buffer
|
||||
*/
|
||||
|
@ -1462,6 +1593,11 @@ TEST_P(GraphicsMapperHidlTest, SetMetadataNullBuffer) {
|
|||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Dataspace, vec));
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_BlendMode, vec));
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Smpte2086, vec));
|
||||
ASSERT_EQ(Error::BAD_BUFFER, mGralloc->set(bufferHandle, gralloc4::MetadataType_Cta861_3, vec));
|
||||
ASSERT_EQ(Error::BAD_BUFFER,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Smpte2094_40, vec));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1521,6 +1657,10 @@ TEST_P(GraphicsMapperHidlTest, SetBadMetadata) {
|
|||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Dataspace, vec));
|
||||
ASSERT_EQ(Error::UNSUPPORTED,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_BlendMode, vec));
|
||||
ASSERT_EQ(Error::UNSUPPORTED,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Smpte2086, vec));
|
||||
ASSERT_EQ(Error::UNSUPPORTED,
|
||||
mGralloc->set(bufferHandle, gralloc4::MetadataType_Cta861_3, vec));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1752,6 +1892,45 @@ TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoBlendMode) {
|
|||
EXPECT_EQ(BlendMode::INVALID, blendMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::getFromBufferDescriptorInfo(Smpte2086)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoSmpte2086) {
|
||||
hidl_vec<uint8_t> vec;
|
||||
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
|
||||
mDummyDescriptorInfo, gralloc4::MetadataType_Smpte2086, &vec));
|
||||
|
||||
std::optional<Smpte2086> smpte2086;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2086(vec, &smpte2086));
|
||||
EXPECT_FALSE(smpte2086.has_value());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::getFromBufferDescriptorInfo(Cta861_3)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoCta861_3) {
|
||||
hidl_vec<uint8_t> vec;
|
||||
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
|
||||
mDummyDescriptorInfo, gralloc4::MetadataType_Cta861_3, &vec));
|
||||
|
||||
std::optional<Cta861_3> cta861_3;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeCta861_3(vec, &cta861_3));
|
||||
EXPECT_FALSE(cta861_3.has_value());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::getFromBufferDescriptorInfo(Smpte2094_40)
|
||||
*/
|
||||
TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoSmpte2094_40) {
|
||||
hidl_vec<uint8_t> vec;
|
||||
ASSERT_EQ(Error::NONE,
|
||||
mGralloc->getFromBufferDescriptorInfo(mDummyDescriptorInfo,
|
||||
gralloc4::MetadataType_Smpte2094_40, &vec));
|
||||
std::optional<std::vector<uint8_t>> smpte2094_40;
|
||||
ASSERT_EQ(NO_ERROR, gralloc4::decodeSmpte2094_40(vec, &smpte2094_40));
|
||||
EXPECT_FALSE(smpte2094_40.has_value());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test IMapper::getFromBufferDescriptorInfo(metadata) for unsupported metadata
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue