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 #pragma once
18 #include "PlaneLayout.h"
19 
20 struct CbExternalMetadata {
21     static constexpr uint64_t kMagicValue = 0x247439A87E42E932LLU;
22 
23     struct Smpte2086 {
24         struct XyColor {
25             float x;
26             float y;
27         };
28 
29         XyColor primaryRed;
30         XyColor primaryGreen;
31         XyColor primaryBlue;
32         XyColor whitePoint;
33         float maxLuminance;
34         float minLuminance;
35     };
36 
37     struct Cta861_3 {
38         float maxContentLightLevel;
39         float maxFrameAverageLightLevel;
40     };
41 
42     uint64_t    magic;
43     uint64_t    bufferID;
44     PlaneLayout planeLayout[3];
45     PlaneLayoutComponent planeLayoutComponent[4];
46     Smpte2086   smpte2086;
47     Cta861_3    cta861_3;
48     uint32_t    width;              // buffer width
49     uint32_t    height;             // buffer height
50     int32_t     glFormat;           // OpenGL format enum used for host h/w color buffer
51     int32_t     glType;             // OpenGL type enum used when uploading to host
52     uint32_t    reservedRegionSize;
53     int32_t     dataspace;
54     int32_t     blendMode;
55 
56     uint8_t     planeLayoutSize;
57     uint8_t     nameSize;
58     bool        has_smpte2086;
59     bool        has_cta861_3;
60 
61     char        name[127];
62     char        unused[1];
63 };
64 
65 static_assert((sizeof(CbExternalMetadata) % 16) == 0);
66