xref: /rockchip-linux_mpp/inc/rk_hdr_meta_com.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  * Copyright 2022 Rockchip Electronics Co. LTD
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 #ifndef __RK_HDR_META_COM_H__
18 #define __RK_HDR_META_COM_H__
19 
20 #include "rk_type.h"
21 
22 typedef enum HdrCodecType_e {
23     HDR_CODEC_UNSPECIFIED = -1,
24     HDR_AVS2              = 0,
25     HDR_HEVC              = 1,
26     HDR_H264              = 2,
27     HDR_AV1               = 3,
28 } HdrCodecType;
29 
30 typedef enum HdrFormat_e {
31     HDR_NONE    = 0,
32     HDR10       = 1,
33     HLG         = 2,
34 //  RESERVED3 = 3, //reserved for more future static hdr format
35 //  RESERVED4 = 4, //reserved for more future static hdr format
36     HDRVIVID    = 5,
37 //  RESERVED6 = 6, //reserved for hdr vivid
38 //  RESERVED7 = 7, //reserved for hdr vivid
39     HDR10PLUS   = 8,
40 //  RESERVED9 = 9, //reserved for hdr10+
41 //  RESERVED10 = 10,//reserved for hdr10+
42     DLBY        = 11,
43 //  RESERVED12 = 12, //reserved for other dynamic hdr format
44 //  RESERVED13 = 13, //reserved for  other dynamic hdr format
45     HDR_FORMAT_MAX,
46 } HdrFormat;
47 
48 typedef enum HdrPayloadFormat_e {
49     STATIC = 0,
50     DYNAMIC = 1,
51     HDR_PAYLOAD_FORMAT_MAX,
52 } HdrPayloadFormat;
53 
54 typedef struct HdrStaticMeta_t {
55     RK_U32  color_space;
56     RK_U32  color_primaries;
57     RK_U32  color_trc;
58     RK_U32  red_x;
59     RK_U32  red_y;
60     RK_U32  green_x;
61     RK_U32  green_y;
62     RK_U32  blue_x;
63     RK_U32  blue_y;
64     RK_U32  white_point_x;
65     RK_U32  white_point_y;
66     RK_U32  min_luminance;
67     RK_U32  max_luminance;
68     RK_U32  max_cll;
69     RK_U32  max_fall;
70     RK_U32  reserved[4];
71 } HdrStaticMeta;
72 
73 /*
74  * HDR metadata format from codec
75  *
76  *  +----------+
77  *  |  header1 |
78  *  +----------+
79  *  |          |
80  *  |  payload |
81  *  |          |
82  *  +----------+
83  *  |  header2 |
84  *  +----------+
85  *  |          |
86  *  |  payload |
87  *  |          |
88  *  +----------+
89  *  |  header3 |
90  *  +----------+
91  *  |          |
92  *  |  payload |
93  *  |          |
94  *  +----------+
95  */
96 typedef struct RkMetaHdrHeader_t {
97     /* For transmission */
98     RK_U16  magic;              /* magic word for checking overwrite error      */
99     RK_U16  size;               /* total header+payload length including header */
100     RK_U16  message_total;      /* total message count in current transmission  */
101     RK_U16  message_index;      /* current message index in the transmission    */
102 
103     /* For payload identification */
104     RK_U16  version;            /* payload structure version                    */
105     RK_U16  hdr_format;         /* HDR protocol: HDR10, HLG, Dlby, HDRVivid ...    */
106     RK_U16  hdr_payload_type;   /* HDR data type: static data, dynamic data ... */
107     RK_U16  video_format;       /* video format: H.264, H.265, AVS2 ...         */
108 
109     /* For extenstion usage */
110     RK_U32  reserve[4];
111 
112     /* payload data aligned to 32bits */
113     RK_U32  payload[];
114 } RkMetaHdrHeader;
115 
116 #ifdef __cplusplus
117 extern "C" {
118 #endif /* __cplusplus */
119 
120 void fill_hdr_meta_to_frame(MppFrame frame, MppCodingType in_type);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif
127