• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 //#define LOG_NDEBUG 0
18 #define LOG_TAG "ColorUtils"
19 
20 #include <inttypes.h>
21 #include <arpa/inet.h>
22 #include <media/stagefright/foundation/ColorUtils.h>
23 
24 namespace android {
25 
26 // shortcut names for brevity in the following tables
27 typedef ColorAspects CA;
28 typedef ColorUtils CU;
29 
30 #define HI_UINT16(a) (((a) >> 8) & 0xFF)
31 #define LO_UINT16(a) ((a) & 0xFF)
32 
33 //
34 // static
fillHdrStaticInfoBuffer(const HDRStaticInfo & info,uint8_t * data)35 void ColorUtils::fillHdrStaticInfoBuffer( const HDRStaticInfo &info, uint8_t *data) {
36     // Static_Metadata_Descriptor_ID
37     data[0] = info.mID;
38 
39     // display primary 0
40     data[1] = LO_UINT16(info.sType1.mR.x);
41     data[2] = HI_UINT16(info.sType1.mR.x);
42     data[3] = LO_UINT16(info.sType1.mR.y);
43     data[4] = HI_UINT16(info.sType1.mR.y);
44 
45     // display primary 1
46     data[5] = LO_UINT16(info.sType1.mG.x);
47     data[6] = HI_UINT16(info.sType1.mG.x);
48     data[7] = LO_UINT16(info.sType1.mG.y);
49     data[8] = HI_UINT16(info.sType1.mG.y);
50 
51     // display primary 2
52     data[9] = LO_UINT16(info.sType1.mB.x);
53     data[10] = HI_UINT16(info.sType1.mB.x);
54     data[11] = LO_UINT16(info.sType1.mB.y);
55     data[12] = HI_UINT16(info.sType1.mB.y);
56 
57     // white point
58     data[13] = LO_UINT16(info.sType1.mW.x);
59     data[14] = HI_UINT16(info.sType1.mW.x);
60     data[15] = LO_UINT16(info.sType1.mW.y);
61     data[16] = HI_UINT16(info.sType1.mW.y);
62 
63     // MaxDisplayLuminance
64     data[17] = LO_UINT16(info.sType1.mMaxDisplayLuminance);
65     data[18] = HI_UINT16(info.sType1.mMaxDisplayLuminance);
66 
67     // MinDisplayLuminance
68     data[19] = LO_UINT16(info.sType1.mMinDisplayLuminance);
69     data[20] = HI_UINT16(info.sType1.mMinDisplayLuminance);
70 
71     // MaxContentLightLevel
72     data[21] = LO_UINT16(info.sType1.mMaxContentLightLevel);
73     data[22] = HI_UINT16(info.sType1.mMaxContentLightLevel);
74 
75     // MaxFrameAverageLightLevel
76     data[23] = LO_UINT16(info.sType1.mMaxFrameAverageLightLevel);
77     data[24] = HI_UINT16(info.sType1.mMaxFrameAverageLightLevel);
78 }
79 
80 
81 }  // namespace android
82 
83