• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <gtest/gtest.h>
18 #include <vector>
19 
20 #include "ultrahdr/gainmapmetadata.h"
21 
22 namespace ultrahdr {
23 
24 class GainMapMetadataTest : public testing::Test {
25  public:
26   GainMapMetadataTest();
27   ~GainMapMetadataTest();
28 
29  protected:
30   virtual void SetUp();
31   virtual void TearDown();
32 };
33 
GainMapMetadataTest()34 GainMapMetadataTest::GainMapMetadataTest() {}
35 
~GainMapMetadataTest()36 GainMapMetadataTest::~GainMapMetadataTest() {}
37 
SetUp()38 void GainMapMetadataTest::SetUp() {}
39 
TearDown()40 void GainMapMetadataTest::TearDown() {}
41 
42 const std::string kIso = "urn:iso:std:iso:ts:21496:-1";
43 
TEST_F(GainMapMetadataTest,encodeMetadataThenDecode)44 TEST_F(GainMapMetadataTest, encodeMetadataThenDecode) {
45   ultrahdr_metadata_struct expected;
46   expected.version = "1.0";
47   expected.maxContentBoost = 100.5f;
48   expected.minContentBoost = 1.5f;
49   expected.gamma = 1.0f;
50   expected.offsetSdr = 0.0f;
51   expected.offsetHdr = 0.0f;
52   expected.hdrCapacityMin = 1.0f;
53   expected.hdrCapacityMax = expected.maxContentBoost;
54 
55   gain_map_metadata metadata;
56   gain_map_metadata::gainmapMetadataFloatToFraction(&expected, &metadata);
57   //  metadata.dump();
58 
59   std::vector<uint8_t> data;
60   gain_map_metadata::encodeGainmapMetadata(&metadata, data);
61 
62   gain_map_metadata decodedMetadata;
63   gain_map_metadata::decodeGainmapMetadata(data, &decodedMetadata);
64 
65   ultrahdr_metadata_struct decodedUHdrMetadata;
66   gain_map_metadata::gainmapMetadataFractionToFloat(&decodedMetadata, &decodedUHdrMetadata);
67 
68   EXPECT_EQ(expected.maxContentBoost, decodedUHdrMetadata.maxContentBoost);
69   EXPECT_EQ(expected.minContentBoost, decodedUHdrMetadata.minContentBoost);
70   EXPECT_EQ(expected.gamma, decodedUHdrMetadata.gamma);
71   EXPECT_EQ(expected.offsetSdr, decodedUHdrMetadata.offsetSdr);
72   EXPECT_EQ(expected.offsetHdr, decodedUHdrMetadata.offsetHdr);
73   EXPECT_EQ(expected.hdrCapacityMin, decodedUHdrMetadata.hdrCapacityMin);
74   EXPECT_EQ(expected.hdrCapacityMax, decodedUHdrMetadata.hdrCapacityMax);
75 }
76 }  // namespace ultrahdr
77