• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 
16 /**
17  * @addtogroup Codec
18  * @{
19  *
20  * @brief Defines APIs related to the Codec module.
21  *
22  * The Codec module provides APIs for initializing the custom data and audio and video codecs,
23  * setting codec parameters, and controlling and transferring data.
24  *
25  * @since 3.1
26  */
27 
28 /**
29  * @file codec_common_type.h
30  *
31  * @brief Declares custom data types used in the Codec module APIs, including the codec types,
32  * audio and video parameters, and buffers.
33  *
34  * @since 3.1
35  */
36 
37 #ifndef CODEC_COMMON_TYPE_H
38 #define CODEC_COMMON_TYPE_H
39 
40 #include <stdint.h>
41 
42 #ifdef __cplusplus
43 #if __cplusplus
44 extern "C" {
45 #endif
46 #endif /* __cplusplus */
47 
48 /**
49  * @brief Enumerates the codec types.
50  */
51 typedef enum {
52     /** Video decoder */
53     VIDEO_DECODER,
54     /** Video encoder */
55     VIDEO_ENCODER,
56     /** Audio decoder */
57     AUDIO_DECODER,
58     /** Audio encoder */
59     AUDIO_ENCODER,
60     /** Invalid type */
61     INVALID_TYPE
62 } CodecType;
63 
64 /**
65  * @brief Enumerates the codec profiles.
66  */
67 typedef enum {
68     /** Invalid profile */
69     INVALID_PROFILE = 0,
70     /** AAC-Low Complex */
71     AAC_LC_PROFILE = 0x1000,
72     /** AAC-Main */
73     AAC_MAIN_PROFILE,
74     /** HEAAC, AAC+, or AACPlusV1 */
75     AAC_HE_V1_PROFILE,
76     /** AAC++ or AACPlusV2 */
77     AAC_HE_V2_PROFILE,
78     /** AAC-Low Delay */
79     AAC_LD_PROFILE,
80     /** AAC-Enhanced Low Delay */
81     AAC_ELD_PROFILE,
82     /** H.264 Baseline */
83     AVC_BASELINE_PROFILE = 0x2000,
84     /** H.264 Main */
85     AVC_MAIN_PROFILE,
86     /** H.264 High */
87     AVC_HIGH_PROFILE,
88     /** H.265 Main */
89     HEVC_MAIN_PROFILE = 0x3000,
90     /** H.265 Main 10 */
91     HEVC_MAIN_10_PROFILE,
92 } Profile;
93 
94 /**
95  * @brief Enumerates the audio sampling rates.
96  */
97 typedef enum {
98     /** 8 kHz */
99     AUD_SAMPLE_RATE_8000   = 8000,
100     /** 12 kHz */
101     AUD_SAMPLE_RATE_12000  = 12000,
102     /** 11.025 kHz */
103     AUD_SAMPLE_RATE_11025  = 11025,
104     /** 16 kHz */
105     AUD_SAMPLE_RATE_16000  = 16000,
106     /** 22.050 kHz */
107     AUD_SAMPLE_RATE_22050  = 22050,
108     /** 24 kHz */
109     AUD_SAMPLE_RATE_24000  = 24000,
110     /** 32 kHz */
111     AUD_SAMPLE_RATE_32000  = 32000,
112     /** 44.1 kHz */
113     AUD_SAMPLE_RATE_44100  = 44100,
114     /** 48 kHz */
115     AUD_SAMPLE_RATE_48000  = 48000,
116     /** 64 kHz */
117     AUD_SAMPLE_RATE_64000  = 64000,
118     /** 96 kHz */
119     AUD_SAMPLE_RATE_96000  = 96000,
120     /** Invalid sampling rate */
121     AUD_SAMPLE_RATE_INVALID,
122 } AudioSampleRate;
123 
124 /**
125 * @brief Defines the alignment.
126  */
127 typedef struct {
128     int32_t widthAlignment; /** Value to align with the width */
129     int32_t heightAlignment; /** Value to align with the height */
130 } Alignment;
131 
132 /**
133  * @brief Defines a rectangle.
134  */
135 typedef struct {
136     int32_t width;  /** Width of the rectangle */
137     int32_t height; /** Height of the rectangle */
138 } Rect;
139 
140 /**
141  * @brief Defines a value range.
142  */
143 typedef struct {
144     int32_t min; /** Minimum value */
145     int32_t max; /** Maximum value */
146 } RangeValue;
147 
148 /**
149  * @brief Enumerates the playback capabilities.
150  */
151 typedef enum {
152     /** Adaptive playback */
153     CODEC_CAP_ADAPTIVE_PLAYBACK = 0x1,
154     /** Secure playback */
155     CODEC_CAP_SECURE_PLAYBACK = 0x2,
156     /** Tunnel playback */
157     CODEC_CAP_TUNNEL_PLAYBACK = 0x4,
158     /** Multi-plane (video image plane and audio tunnel plane) playback */
159     CODEC_CAP_MULTI_PLANE = 0x10000,
160 } CodecCapsMask;
161 
162 /**
163  * @brief Enumerates the codec processing modes.
164  */
165 typedef enum {
166     /** Input buffer in sync mode */
167     PROCESS_BLOCKING_INPUT_BUFFER     = 0X1,
168     /** Output buffer in sync mode */
169     PROCESS_BLOCKING_OUTPUT_BUFFER    = 0X2,
170     /** Control flow in sync mode */
171     PROCESS_BLOCKING_CONTROL_FLOW     = 0X4,
172     /** Input buffer in async mode */
173     PROCESS_NONBLOCKING_INPUT_BUFFER  = 0X100,
174     /** Output buffer in async mode */
175     PROCESS_NONBLOCKING_OUTPUT_BUFFER = 0X200,
176     /** Control flow in async mode */
177     PROCESS_NONBLOCKING_CONTROL_FLOW  = 0X400,
178 } CodecProcessMode;
179 
180 /**
181  * @brief Enumerate the audio sampling formats.
182  *
183  * For the planar sampling format, the data of each channel is independently stored in data.
184  * For the packed sampling format, only the first data is used, and the data of each channel is interleaved.
185  */
186 typedef enum {
187     /** Unsigned 8 bits, packed */
188     AUDIO_SAMPLE_FMT_U8,
189     /** Signed 16 bits, packed */
190     AUDIO_SAMPLE_FMT_S16,
191     /** Signed 32 bits, packed */
192     AUDIO_SAMPLE_FMT_S32,
193     /** Float, packed */
194     AUDIO_SAMPLE_FMT_FLOAT,
195     /** Double, packed */
196     AUDIO_SAMPLE_FMT_DOUBLE,
197     /** Unsigned 8 bits, planar */
198     AUDIO_SAMPLE_FMT_U8P,
199     /** Signed 16 bits, planar */
200     AUDIO_SAMPLE_FMT_S16P,
201     /** Signed 32 bits, planar */
202     AUDIO_SAMPLE_FMT_S32P,
203     /** Float, planar */
204     AUDIO_SAMPLE_FMT_FLOATP,
205     /** Double, planar */
206     AUDIO_SAMPLE_FMT_DOUBLEP,
207     /** Invalid sampling format */
208     AUDIO_SAMPLE_FMT_INVALID,
209 } CodecAudioSampleFormat;
210 
211 #ifdef __cplusplus
212 #if __cplusplus
213 }
214 #endif
215 #endif /* __cplusplus */
216 
217 #endif /* CODEC_COMMON_TYPE_H */
218 /** @} */