1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16package ohos.hdi.codec.v3_0;
17
18import ohos.hdi.codec.v3_0.CodecTypes;
19
20/**
21 * @brief Enumerates the extended codec codingtyps.
22
23 * @since 4.1
24 * @version 2.0
25 */
26enum CodecVideoExType {
27    CODEC_VIDEO_CodingVP9  = 10, /** VP9 Index in Codec HDI */
28    CODEC_VIDEO_CodingHEVC = 11, /** HEVC Index in Codec HDI */
29};
30
31/**
32 * @brief Enumerates the extended HEVC profile.
33
34 * @since 4.1
35 * @version 2.0
36 */
37enum CodecHevcProfile {
38    CODEC_HEVC_PROFILE_INVALID = 0x0,
39    CODEC_HEVC_PROFILE_MAIN = 0x1,
40    CODEC_HEVC_PROFILE_MAIN10 = 0x2,
41    CODEC_HEVC_PROFILE_MAIN_STILL = 0x3,
42    // main_10 profile with HDR SEI support.
43    CODEC_HEVC_PROFILE_MAIN10_HDR10 = 0x1000,
44    CODEC_HEVC_PROFILE_MAIN10_HDR10_PLUS = 0x2000,
45    CODEC_HEVC_PROFILE_MAX = 0x7FFFFFFF
46};
47
48/**
49 * @brief Enumerates the extended HEVC level.
50
51 * @since 4.1
52 * @version 2.0
53 */
54enum CodecHevcLevel {
55    CODEC_HEVC_LEVEL_INVALID = 0x0,
56    CODEC_HEVC_MAIN_TIER_LEVEL1 = 0x1,
57    CODEC_HEVC_HIGH_TIER_LEVEL1 = 0x2,
58    CODEC_HEVC_MAIN_TIER_LEVEL2 = 0x4,
59    CODEC_HEVC_HIGH_TIER_LEVEL2 = 0x8,
60    CODEC_HEVC_MAIN_TIER_LEVEL21 = 0x10,
61    CODEC_HEVC_HIGH_TIER_LEVEL21 = 0x20,
62    CODEC_HEVC_MAIN_TIER_LEVEL3 = 0x40,
63    CODEC_HEVC_HIGH_TIER_LEVEL3 = 0x80,
64    CODEC_HEVC_MAIN_TIER_LEVEL31 = 0x100,
65    CODEC_HEVC_HIGH_TIER_LEVEL31 = 0x200,
66    CODEC_HEVC_MAIN_TIER_LEVEL4 = 0x400,
67    CODEC_HEVC_HIGH_TIER_LEVEL4 = 0x800,
68    CODEC_HEVC_MAIN_TIER_LEVEL41 = 0x1000,
69    CODEC_HEVC_HIGH_TIER_LEVEL41 = 0x2000,
70    CODEC_HEVC_MAIN_TIER_LEVEL5 = 0x4000,
71    CODEC_HEVC_HIGH_TIER_LEVEL5 = 0x8000,
72    CODEC_HEVC_MAIN_TIER_LEVEL51 = 0x10000,
73    CODEC_HEVC_HIGH_TIER_LEVEL51 = 0x20000,
74    CODEC_HEVC_MAIN_TIER_LEVEL52 = 0x40000,
75    CODEC_HEVC_HIGH_TIER_LEVEL52 = 0x80000,
76    CODEC_HEVC_MAIN_TIER_LEVEL6 = 0x100000,
77    CODEC_HEVC_HIGH_TIER_LEVEL6 = 0x200000,
78    CODEC_HEVC_MAIN_TIER_LEVEL61 = 0x400000,
79    CODEC_HEVC_HIGH_TIER_LEVEL61 = 0x800000,
80    CODEC_HEVC_MAIN_TIER_LEVEL62 = 0x1000000,
81    CODEC_HEVC_HIGH_TIER_LEVEL62 = 0x2000000,
82    CODEC_HEVC_HIGH_TIER_MAX = 0x7FFFFFFF
83};
84
85/**
86 * @brief Enumerates the buffer types.
87
88 * @since 4.1
89 * @version 2.0
90 */
91enum CodecBufferType {
92    /** Invalid buffer type. */
93    CODEC_BUFFER_TYPE_INVALID = 0,
94    /** Virtual address type. */
95    CODEC_BUFFER_TYPE_VIRTUAL_ADDR = 0x1,
96    /** Shared memory. */
97    CODEC_BUFFER_TYPE_AVSHARE_MEM_FD = 0x2,
98    /** Handle. */
99    CODEC_BUFFER_TYPE_HANDLE = 0x4,
100    /** Dynamic handle. */
101    CODEC_BUFFER_TYPE_DYNAMIC_HANDLE = 0x8,
102    /** DMA memory. */
103    CODEC_BUFFER_TYPE_DMA_MEM_FD = 0x10,
104};
105
106/**
107 * @brief Defines the <b>SupportBuffer</b>.
108
109 * @since 4.1
110 * @version 2.0
111 */
112struct SupportBufferType {
113    unsigned int  size;              /** Size of the structure */
114    union CodecVersionType  version; /** Component version */
115    unsigned int portIndex;          /** Port index */
116    unsigned int bufferTypes;        /** Supported buffer types */
117};
118
119/**
120 * @brief Define the <b>UseBuffer</b>.
121
122 * @since 4.1
123 * @version 2.0
124 */
125struct UseBufferType {
126    unsigned int size;              /** Size of the structure */
127    union CodecVersionType version; /** Component version */
128    unsigned int portIndex;         /** Port index */
129    unsigned int bufferType;        /** Buffer type */
130};
131
132/**
133 * @brief Defines the <b>BufferHandleUsage</b>.
134
135 * @since 4.1
136 * @version 2.0
137 */
138struct GetBufferHandleUsageParams {
139    unsigned int size;              /** Size of the structure */
140    union CodecVersionType version; /** Component version */
141    unsigned int portIndex;         /** Port index */
142    unsigned long usage;            /** Usage */
143};
144
145/**
146 * @brief Defines the <b>CodecVideoPortFormatParam</b>.
147
148 * @since 4.1
149 * @version 2.0
150 */
151struct CodecVideoPortFormatParam {
152    unsigned int size;                /** Size of the structure */
153    union CodecVersionType version;   /** Component version */
154    unsigned int portIndex;           /** Port index */
155    unsigned int codecColorIndex;     /** Color format index */
156    unsigned int codecColorFormat;    /** Color format defined in Display */
157    unsigned int codecCompressFormat; /** See  */
158    unsigned int framerate;           /** Q16 format */
159};
160
161/**
162 * @brief Defines the <b>ControlRateConstantQuality</b>.
163
164 * @since 4.1
165 * @version 2.0
166 */
167struct ControlRateConstantQuality {
168    unsigned int size;              /** Size of the structure */
169    union CodecVersionType version; /** Component version */
170    unsigned int portIndex;         /** Port index */
171    unsigned int qualityValue;      /** Control rate constant quality */
172};
173
174/**
175 * @brief Defines the <b>WorkingFrequencyParam</b>.
176
177 * @since 4.1
178 * @version 2.0
179 */
180struct WorkingFrequencyParam {
181    unsigned int size;              /** Size of the structure */
182    union CodecVersionType version; /** Component version */
183    unsigned int level;             /** Working frequency level */
184};
185
186/**
187 * @brief Defines the <b>WorkingFrequencyParam</b>.
188
189 * @since 4.1
190 * @version 2.0
191 */
192struct ProcessNameParam {
193    unsigned int size;              /** Size of the structure */
194    union CodecVersionType version; /** Component version */
195    String processName;             /** Process Name */
196};
197
198/**
199 * @brief Defines the <b>AudioL2HCParam</b>.
200
201 * @since 5.0
202 * @version 3.0
203 */
204struct AudioL2HCParam {
205    unsigned int size;              /** Size of the structure */
206    union CodecVersionType version; /** Component version */
207    unsigned int sampleRate;        /** Sample Rate */
208    unsigned int sampleFormat;      /** Sample Format */
209    unsigned int channels;          /** Channels */
210    unsigned int bitRate;           /** Bit Rate */
211    unsigned int reserved;          /** reserved word */
212};
213
214/**
215 * @brief Enumerates the extended codec indexes.
216
217 * @since 4.1
218 * @version 3.1
219 */
220enum CodecIndexExType {
221    /** Extended BufferType index, value = Codec_IndexExtBufferTypeStartUnused + 0x00a00000 */
222    Codec_IndexExtBufferTypeStartUnused = 0x6F000000 + 0x00a00000,
223    /** SupportBuffer */
224    Codec_IndexParamSupportBufferType,
225    /** UseBuffer */
226    Codec_IndexParamUseBufferType,
227    /** GetBufferHandleUsage */
228    Codec_IndexParamGetBufferHandleUsage,
229    /** CodecVideoPortFormatParam */
230    Codec_IndexCodecVideoPortFormat,
231    /** ControlRateConstantQuality */
232    Codec_IndexParamControlRateConstantQuality,
233    /** Codec_IndexParamVideoHevc */
234    Codec_IndexParamVideoHevc = 0x6F000000 + 0x00a00007,
235    /** range/primary/transfer/matrix */
236    Codec_IndexColorAspects,
237    /** WorkingFrequencyParam */
238    Codec_IndexParamWorkingFrequency,
239    /** ProcessNameParam */
240    Codec_IndexParamProcessName,
241    /** AudioL2HCParam */
242    Codec_IndexParamAudioL2HC,
243    /** OverlayBuffer */
244    Codec_IndexParamOverlayBuffer,
245};
246
247/**
248 * @brief Structure for controlling HEVC video encoding
249
250 * @since 4.1
251 * @version 2.0
252 */
253struct CodecVideoParamHevc {
254    unsigned int size;              /** Size of the structure */
255    union CodecVersionType version; /** Component version */
256    unsigned int portIndex;         /** Port index */
257    enum CodecHevcProfile profile;  /** Hevc profile. For details,  see {@link CodecHevcProfile}. */
258    enum CodecHevcLevel level;      /** Hevc level. For details,  see {@link CodecHevcLevel}. */
259    unsigned int keyFrameInterval;  /** Distance between consecutive I-frames (including one of the I frams).
260                                        0 means interval is unspecified and can be freely chosen by the codec.
261                                        1 means a stream of only I frams. other  means the real value. */
262};
263
264/**
265 * @brief Enumerates the range type of color aspect.
266
267 * @since 4.1
268 * @version 2.0
269 */
270enum RangeType {
271    RANGE_UNSPECIFIED,
272    RANGE_FULL,
273    RANGE_LIMITED,
274    RANGE_MAX = 0xff,
275};
276
277/**
278 * @brief Enumerates the primaries of color aspect.
279
280 * @since 4.1
281 * @version 2.0
282 */
283enum Primaries {
284    PRIMARIES_UNSPECIFIED,
285    PRIMARIES_BT709,       //Rec. ITU-R BT.709-6
286    PRIMARIES_BT470_6M,    //Rec. ITU-R BT.470-6 System M
287    PRIMARIES_BT601_625,   //Rec. ITU-R BT.601-7 625 or Rec. ITU-R BT.470-6 System B,G
288    PRIMARIES_BT601_525,   //Rec. ITU-R BT.601-7 525 or SMPTE ST 170 or SMPTE ST 240
289    PRIMARIES_GENERICFILM, //Generic Film
290    PRIMARIES_BT2020,      //Rec. ITU-R BT.2020-2 or Rec. ITU-R BT.2100-2
291    PRIMARIES_MAX = 0xff,
292};
293
294/**
295 * @brief Enumerates the Transfer of color aspect.
296
297 * @since 4.1
298 * @version 2.0
299 */
300enum Transfer {
301    TRANSFER_UNSPECIFIED,
302    TRANSFER_LINEAR,          //Linear transfer characteristics
303    TRANSFER_SRGB,            //IEC 61966-2-1 sRGB
304    TRANSFER_SMPTE170,        //SMPTE ST 170 or Rec. ITU-R BT.709-6 or BT.601-7 or BT.2020-2
305    TRANSFER_GAMMA22,         //Rec. ITU-R BT.470-6 System M
306    TRANSFER_GAMMA28,         //Rec. ITU-R BT.470-6 System B,G
307    TRANSFER_PQ,              //Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system
308    TRANSFER_HLG,             //Rec. ITU-R BT.2100-2 hybrid log gamma (HLG) system
309    TRANSFER_SMPTE240 = 0x40, //SMPTE ST 240
310    TRANSFER_XVYCC,           //IEC 61966-2-4
311    TRANSFER_BT1361,          //Rec. ITU-R BT.1361-0 extended colour gamut system
312    TRANSFER_ST428,           //SMPTE ST 428-1
313    TRANSFER_MAX = 0xff,
314};
315
316/**
317 * @brief Enumerates the MatrixCoeffs of color aspect.
318
319 * @since 4.1
320 * @version 2.0
321 */
322enum MatrixCoeffs {
323    MATRIX_UNSPECIFED,
324    MATRIX_BT709,          //Rec. ITU-R BT.709-6
325    MATRIX_FCC,            //United States Federal Communications Commission
326    MATRIX_BT601,          //Rec. ITU-R BT.601-7 or Rec. ITU-R BT.470-6 System B,G
327    MATRIX_SMPTE240,       //SMPTE ST 240
328    MATRIX_BT2020,         //Rec. ITU-R BT.2100-2 (non-constant luminance)
329    MATRIX_BT2020CONSTANT, //Rec. ITU-R BT.2100-2 (constant luminance)
330    MATRIX_MAX = 0xff,
331};
332
333/**
334 * @brief Structure for video color aspsect
335
336 * @since 4.1
337 * @version 2.0
338 */
339struct ColorAspects {
340    enum RangeType range;
341    enum Primaries primaries;
342    enum Transfer transfer;
343    enum MatrixCoeffs matrixCoeffs;
344};
345
346/**
347 * @brief Structure for controlling color space
348
349 * @since 4.1
350 * @version 2.0
351 */
352struct CodecVideoColorspace {
353    unsigned int size;                /** Size of the structure */
354    union CodecVersionType version;   /** Component version */
355    unsigned int portIndex;           /** Port index */
356    unsigned int requestingDataSpace;
357    unsigned int dataSpaceChanged;
358    unsigned int pixeFormat;
359    unsigned int dataSpace;
360    struct ColorAspects aspects;
361};
362
363/**
364 * @brief Structure for controlling overlay
365
366 * @since 5.0
367 * @version 1.0
368 */
369struct CodecParamOverlay {
370    unsigned int size;                /** Size of the structure */
371    union CodecVersionType version;   /** Component version */
372    boolean enable;                   /** enable overlay */
373    unsigned int dstX;                /** the overlay image will be put on dstX of input image */
374    unsigned int dstY;                /** the overlay image will be put on dstY of input image */
375    unsigned int dstW;                /** the overlay image will be scaled to dstW */
376    unsigned int dstH;                /** the overlay image will be scaled to dstH */
377};
378