diff options
author | 2021-10-06 16:38:12 -0700 | |
---|---|---|
committer | 2021-10-13 00:24:34 +0000 | |
commit | 332765e8e3b0abae5cfce298c68d3b1015e2b641 (patch) | |
tree | c4b6636c627615fef4edc54ba00773eb02c989e2 | |
parent | f76d573a9908d06131e3ff3ca8fcf397114fdd57 (diff) |
Update gralloc wrappers to support querying SMPTE 2094-10 metadata
Bug: 200309502
Test: builds
Test: GrallocTypes_test
Change-Id: Ia5b17d414d1ed83612e402e2615814f23d18830c
-rw-r--r-- | libs/gralloc/types/Gralloc4.cpp | 12 | ||||
-rw-r--r-- | libs/gralloc/types/include/gralloctypes/Gralloc4.h | 11 | ||||
-rw-r--r-- | libs/gralloc/types/tests/Gralloc4_test.cpp | 28 | ||||
-rw-r--r-- | libs/ui/Gralloc4.cpp | 6 | ||||
-rw-r--r-- | libs/ui/GraphicBufferMapper.cpp | 5 | ||||
-rw-r--r-- | libs/ui/include/ui/Gralloc.h | 5 | ||||
-rw-r--r-- | libs/ui/include/ui/Gralloc4.h | 2 | ||||
-rw-r--r-- | libs/ui/include/ui/GraphicBufferMapper.h | 2 |
8 files changed, 71 insertions, 0 deletions
diff --git a/libs/gralloc/types/Gralloc4.cpp b/libs/gralloc/types/Gralloc4.cpp index e2f072a7ab..61e6657621 100644 --- a/libs/gralloc/types/Gralloc4.cpp +++ b/libs/gralloc/types/Gralloc4.cpp @@ -1134,6 +1134,18 @@ status_t decodeSmpte2094_40(const hidl_vec<uint8_t>& smpte2094_40, decodeByteVector); } +status_t encodeSmpte2094_10(const std::optional<std::vector<uint8_t>>& smpte2094_10, + hidl_vec<uint8_t>* outSmpte2094_10) { + return encodeOptionalMetadata(MetadataType_Smpte2094_10, smpte2094_10, outSmpte2094_10, + encodeByteVector); +} + +status_t decodeSmpte2094_10(const hidl_vec<uint8_t>& smpte2094_10, + std::optional<std::vector<uint8_t>>* outSmpte2094_10) { + return decodeOptionalMetadata(MetadataType_Smpte2094_10, smpte2094_10, outSmpte2094_10, + decodeByteVector); +} + status_t encodeUint32(const MetadataType& metadataType, uint32_t input, hidl_vec<uint8_t>* output) { return encodeMetadata(metadataType, input, output, encodeInteger); diff --git a/libs/gralloc/types/include/gralloctypes/Gralloc4.h b/libs/gralloc/types/include/gralloctypes/Gralloc4.h index 2f418acca5..deaffade1b 100644 --- a/libs/gralloc/types/include/gralloctypes/Gralloc4.h +++ b/libs/gralloc/types/include/gralloctypes/Gralloc4.h @@ -134,6 +134,12 @@ static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType aidl::android::hardware::graphics::common:: StandardMetadataType::SMPTE2094_40)}; +static const android::hardware::graphics::mapper::V4_0::IMapper::MetadataType + MetadataType_Smpte2094_10 = {GRALLOC4_STANDARD_METADATA_TYPE, + static_cast<int64_t>( + aidl::android::hardware::graphics::common:: + StandardMetadataType::SMPTE2094_10)}; + /*---------------------------------------------------------------------------------------------*/ /** @@ -327,6 +333,11 @@ status_t encodeSmpte2094_40(const std::optional<std::vector<uint8_t>>& smpte2094 status_t decodeSmpte2094_40(const android::hardware::hidl_vec<uint8_t>& smpte2094_40, std::optional<std::vector<uint8_t>>* outSmpte2094_40); +status_t encodeSmpte2094_10(const std::optional<std::vector<uint8_t>>& smpte2094_10, + android::hardware::hidl_vec<uint8_t>* outSmpte2094_10); +status_t decodeSmpte2094_10(const android::hardware::hidl_vec<uint8_t>& smpte2094_10, + std::optional<std::vector<uint8_t>>* outSmpte2094_10); + /** * The functions below can be used to encode and decode vendor metadata types. */ diff --git a/libs/gralloc/types/tests/Gralloc4_test.cpp b/libs/gralloc/types/tests/Gralloc4_test.cpp index 89cbf4ac4a..94e344f584 100644 --- a/libs/gralloc/types/tests/Gralloc4_test.cpp +++ b/libs/gralloc/types/tests/Gralloc4_test.cpp @@ -455,6 +455,32 @@ TEST_P(Gralloc4TestSmpte2094_40, Smpte2094_40) { ASSERT_NO_FATAL_FAILURE(testHelperStableAidlTypeOptional(GetParam(), gralloc4::encodeSmpte2094_40, gralloc4::decodeSmpte2094_40)); } +class Gralloc4TestSmpte2094_10 + : public testing::TestWithParam<std::optional<std::vector<uint8_t>>> {}; + +INSTANTIATE_TEST_CASE_P( + Gralloc4TestSmpte2094_10Params, Gralloc4TestSmpte2094_10, + ::testing::Values( + std::optional<std::vector<uint8_t>>({}), + std::optional<std::vector<uint8_t>>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}), + std::optional<std::vector<uint8_t>>({std::numeric_limits<uint8_t>::min(), + std::numeric_limits<uint8_t>::min() + 1, + std::numeric_limits<uint8_t>::min() + 2, + std::numeric_limits<uint8_t>::min() + 3, + std::numeric_limits<uint8_t>::min() + 4}), + std::optional<std::vector<uint8_t>>({std::numeric_limits<uint8_t>::max(), + std::numeric_limits<uint8_t>::max() - 1, + std::numeric_limits<uint8_t>::max() - 2, + std::numeric_limits<uint8_t>::max() - 3, + std::numeric_limits<uint8_t>::max() - 4}), + std::nullopt)); + +TEST_P(Gralloc4TestSmpte2094_10, Smpte2094_10) { + ASSERT_NO_FATAL_FAILURE(testHelperStableAidlTypeOptional(GetParam(), + gralloc4::encodeSmpte2094_10, + gralloc4::decodeSmpte2094_10)); +} + class Gralloc4TestBufferDescriptorInfo : public testing::TestWithParam<BufferDescriptorInfo> { }; INSTANTIATE_TEST_CASE_P( @@ -491,6 +517,7 @@ TEST_F(Gralloc4TestErrors, Gralloc4TestEncodeNull) { ASSERT_NE(NO_ERROR, gralloc4::encodeSmpte2086({{}}, nullptr)); ASSERT_NE(NO_ERROR, gralloc4::encodeCta861_3({{}}, nullptr)); ASSERT_NE(NO_ERROR, gralloc4::encodeSmpte2094_40({{}}, nullptr)); + ASSERT_NE(NO_ERROR, gralloc4::encodeSmpte2094_10({{}}, nullptr)); } TEST_F(Gralloc4TestErrors, Gralloc4TestDecodeNull) { @@ -516,6 +543,7 @@ TEST_F(Gralloc4TestErrors, Gralloc4TestDecodeNull) { ASSERT_NE(NO_ERROR, gralloc4::decodeSmpte2086(vec, nullptr)); ASSERT_NE(NO_ERROR, gralloc4::decodeCta861_3(vec, nullptr)); ASSERT_NE(NO_ERROR, gralloc4::decodeSmpte2094_40(vec, nullptr)); + ASSERT_NE(NO_ERROR, gralloc4::decodeSmpte2094_10(vec, nullptr)); } TEST_F(Gralloc4TestErrors, Gralloc4TestDecodeBadVec) { diff --git a/libs/ui/Gralloc4.cpp b/libs/ui/Gralloc4.cpp index 80f6c82bb0..8ac08fb70d 100644 --- a/libs/ui/Gralloc4.cpp +++ b/libs/ui/Gralloc4.cpp @@ -634,6 +634,12 @@ status_t Gralloc4Mapper::getSmpte2094_40( outSmpte2094_40); } +status_t Gralloc4Mapper::getSmpte2094_10( + buffer_handle_t bufferHandle, std::optional<std::vector<uint8_t>>* outSmpte2094_10) const { + return get(bufferHandle, gralloc4::MetadataType_Smpte2094_10, gralloc4::decodeSmpte2094_10, + outSmpte2094_10); +} + template <class T> status_t Gralloc4Mapper::getDefault(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, diff --git a/libs/ui/GraphicBufferMapper.cpp b/libs/ui/GraphicBufferMapper.cpp index d20bd7a899..82d6cd5ba3 100644 --- a/libs/ui/GraphicBufferMapper.cpp +++ b/libs/ui/GraphicBufferMapper.cpp @@ -301,6 +301,11 @@ status_t GraphicBufferMapper::getSmpte2094_40( return mMapper->getSmpte2094_40(bufferHandle, outSmpte2094_40); } +status_t GraphicBufferMapper::getSmpte2094_10( + buffer_handle_t bufferHandle, std::optional<std::vector<uint8_t>>* outSmpte2094_10) { + return mMapper->getSmpte2094_10(bufferHandle, outSmpte2094_10); +} + status_t GraphicBufferMapper::getDefaultPixelFormatFourCC(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, diff --git a/libs/ui/include/ui/Gralloc.h b/libs/ui/include/ui/Gralloc.h index e199648a8b..753b0a6794 100644 --- a/libs/ui/include/ui/Gralloc.h +++ b/libs/ui/include/ui/Gralloc.h @@ -178,6 +178,11 @@ public: std::optional<std::vector<uint8_t>>* /*outSmpte2094_40*/) const { return INVALID_OPERATION; } + virtual status_t getSmpte2094_10( + buffer_handle_t /*bufferHandle*/, + std::optional<std::vector<uint8_t>>* /*outSmpte2094_10*/) const { + return INVALID_OPERATION; + } virtual status_t getDefaultPixelFormatFourCC(uint32_t /*width*/, uint32_t /*height*/, PixelFormat /*format*/, uint32_t /*layerCount*/, diff --git a/libs/ui/include/ui/Gralloc4.h b/libs/ui/include/ui/Gralloc4.h index 4729cbaf67..62f9e4a53f 100644 --- a/libs/ui/include/ui/Gralloc4.h +++ b/libs/ui/include/ui/Gralloc4.h @@ -108,6 +108,8 @@ public: std::optional<ui::Cta861_3>* outCta861_3) const override; status_t getSmpte2094_40(buffer_handle_t bufferHandle, std::optional<std::vector<uint8_t>>* outSmpte2094_40) const override; + status_t getSmpte2094_10(buffer_handle_t bufferHandle, + std::optional<std::vector<uint8_t>>* outSmpte2094_10) const override; status_t getDefaultPixelFormatFourCC(uint32_t width, uint32_t height, PixelFormat format, uint32_t layerCount, uint64_t usage, diff --git a/libs/ui/include/ui/GraphicBufferMapper.h b/libs/ui/include/ui/GraphicBufferMapper.h index 837e3d826b..257c155efd 100644 --- a/libs/ui/include/ui/GraphicBufferMapper.h +++ b/libs/ui/include/ui/GraphicBufferMapper.h @@ -126,6 +126,8 @@ public: status_t getCta861_3(buffer_handle_t bufferHandle, std::optional<ui::Cta861_3>* outCta861_3); status_t getSmpte2094_40(buffer_handle_t bufferHandle, std::optional<std::vector<uint8_t>>* outSmpte2094_40); + status_t getSmpte2094_10(buffer_handle_t bufferHandle, + std::optional<std::vector<uint8_t>>* outSmpte2094_10); /** * Gets the default metadata for a gralloc buffer allocated with the given parameters. |