xref: /aosp_15_r20/external/libavc/encoder/iv2.h (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 /**
21 *******************************************************************************
22 * @file
23 *  iv2.h
24 *
25 * @brief
26 *  This file contains all the necessary structure and enumeration definitions
27 *  needed for the Application Program Interface(API) of the Ittiam Video codecs.
28 *  This is version 2 of Ittiam Video API
29 *
30 * @author
31 *  ittiam
32 *
33 * @remarks
34 *  none
35 *
36 *******************************************************************************
37 */
38 
39 #ifndef _IV2_H_
40 #define _IV2_H_
41 
42 /*****************************************************************************/
43 /* Constant Macros                                                           */
44 /*****************************************************************************/
45 #define IV_MAX_RAW_COMPONENTS 4
46 
47 /*****************************************************************************/
48 /* Typedefs                                                                  */
49 /*****************************************************************************/
50 
51 /*****************************************************************************/
52 /* Enums                                                                     */
53 /*****************************************************************************/
54 
55 
56 /** Function status */
57 typedef enum{
58     IV_STATUS_NA                                = 0x7FFFFFFF,
59     IV_SUCCESS                                  = 0x0,
60     IV_FAIL                                     = 0x1,
61 }IV_STATUS_T;
62 
63 
64 /** Defines the types of memory */
65 typedef enum {
66     IV_NA_MEM_TYPE                              = 0x7FFFFFFF,
67     IV_EXTERNAL_CACHEABLE_PERSISTENT_MEM        = 0x0,
68     IV_EXTERNAL_CACHEABLE_SCRATCH_MEM           = 0x1,
69     IV_EXTERNAL_NONCACHEABLE_PERSISTENT_MEM     = 0x2,
70     IV_EXTERNAL_NONCACHEABLE_SCRATCH_MEM        = 0x3,
71     IV_INTERNAL_CACHEABLE_PERSISTENT_MEM        = 0x10,
72     IV_INTERNAL_CACHEABLE_SCRATCH_MEM           = 0x11,
73     IV_INTERNAL_NONCACHEABLE_PERSISTENT_MEM     = 0x12,
74     IV_INTERNAL_NONCACHEABLE_SCRATCH_MEM        = 0x13,
75 }IV_MEM_TYPE_T;
76 
77 /* The color formats used in video/image codecs */
78 typedef enum {
79     IV_CHROMA_NA                            = 0x7FFFFFFF,
80     IV_YUV_420P                             = 0x0,
81     IV_YUV_420SP_UV                         = 0x1,
82     IV_YUV_420SP_VU                         = 0x2,
83 
84     IV_YUV_422P                             = 0x10,
85     IV_YUV_422IBE                           = 0x11,
86     IV_YUV_422ILE                           = 0x12,
87 
88     IV_YUV_444P                             = 0x20,
89     IV_YUV_411P                             = 0x21,
90 
91     IV_GRAY                                 = 0x30,
92 
93     IV_RGB_565                              = 0x31,
94     IV_RGB_24                               = 0x32,
95     IV_RGBA_8888                            = 0x33
96 }IV_COLOR_FORMAT_T;
97 
98 /** Frame/Field coding types */
99 typedef enum {
100     IV_NA_FRAME                             = 0x7FFFFFFF,
101     IV_I_FRAME                              = 0x0,
102     IV_P_FRAME                              = 0x1,
103     IV_B_FRAME                              = 0x2,
104     IV_IDR_FRAME                            = 0x3,
105     IV_II_FRAME                             = 0x4,
106     IV_IP_FRAME                             = 0x5,
107     IV_IB_FRAME                             = 0x6,
108     IV_PI_FRAME                             = 0x7,
109     IV_PP_FRAME                             = 0x8,
110     IV_PB_FRAME                             = 0x9,
111     IV_BI_FRAME                             = 0xa,
112     IV_BP_FRAME                             = 0xb,
113     IV_BB_FRAME                             = 0xc,
114     IV_MBAFF_I_FRAME                        = 0xd,
115     IV_MBAFF_P_FRAME                        = 0xe,
116     IV_MBAFF_B_FRAME                        = 0xf,
117     IV_MBAFF_IDR_FRAME                      = 0x10,
118     IV_NOT_CODED_FRAME                      = 0x11,
119     IV_FRAMETYPE_DEFAULT                    = IV_I_FRAME
120 }IV_PICTURE_CODING_TYPE_T;
121 
122 /** Field type */
123 typedef enum {
124     IV_NA_FLD                               = 0x7FFFFFFF,
125     IV_TOP_FLD                              = 0x0,
126     IV_BOT_FLD                              = 0x1,
127     IV_FLD_TYPE_DEFAULT                     = IV_TOP_FLD
128 }IV_FLD_TYPE_T;
129 
130 /** Video content type progressive/interlaced etc */
131 typedef enum {
132     IV_CONTENTTYPE_NA                       = 0x7FFFFFFF,
133     IV_PROGRESSIVE                          = 0x0,
134     IV_INTERLACED                           = 0x1,
135     IV_PROGRESSIVE_FRAME                    = 0x2,
136     IV_INTERLACED_FRAME                     = 0x3,
137     IV_INTERLACED_TOPFIELD                  = 0x4,
138     IV_INTERLACED_BOTTOMFIELD               = 0x5,
139     IV_CONTENTTYPE_DEFAULT                  = IV_PROGRESSIVE,
140 }IV_CONTENT_TYPE_T;
141 
142 /** Profile */
143 typedef enum
144 {
145     IV_PROFILE_NA                           = 0x7FFFFFFF,
146     IV_PROFILE_BASE                         = 0x0,
147     IV_PROFILE_MAIN                         = 0x1,
148     IV_PROFILE_HIGH                         = 0x2,
149 
150 
151     IV_PROFILE_SIMPLE                       = 0x100,
152     IV_PROFILE_ADVSIMPLE                    = 0x101,
153     IV_PROFILE_DEFAULT                      = IV_PROFILE_BASE,
154 }IV_PROFILE_T;
155 
156 
157 /** Architecture Enumeration                               */
158 typedef enum
159 {
160     ARCH_NA                 =   0x7FFFFFFF,
161     ARCH_ARM_NONEON         =   0x0,
162     ARCH_ARM_A9Q,
163     ARCH_ARM_A9A,
164     ARCH_ARM_A9,
165     ARCH_ARM_A7,
166     ARCH_ARM_A5,
167     ARCH_ARM_A15,
168     ARCH_ARM_NEONINTR,
169     ARCH_X86_GENERIC,
170     ARCH_X86_SSSE3,
171     ARCH_X86_SSE42,
172     ARCH_ARM_A53,
173     ARCH_ARM_A57,
174     ARCH_ARM_V8_NEON
175 }IV_ARCH_T;
176 
177 /** SOC Enumeration                               */
178 typedef enum
179 {
180     SOC_NA                  = 0x7FFFFFFF,
181     SOC_GENERIC             = 0x0,
182     SOC_HISI_37X
183 }IV_SOC_T;
184 
185 
186 /** API command type */
187 typedef enum {
188     IV_CMD_NA                           = 0x7FFFFFFF,
189     IV_CMD_GET_NUM_MEM_REC              = 0x0,
190     IV_CMD_FILL_NUM_MEM_REC             = 0x1,
191     IV_CMD_RETRIEVE_MEMREC              = 0x2,
192     IV_CMD_INIT                         = 0x3,
193     /* Do not add anything after the following entry */
194     IV_CMD_EXTENSIONS                   = 0x100
195 }IV_API_COMMAND_TYPE_T;
196 
197 /*****************************************************************************/
198 /* Structure Definitions                                                     */
199 /*****************************************************************************/
200 
201 /** This structure defines the handle for the codec instance            */
202 
203 typedef struct{
204     /** size of the structure                                           */
205     UWORD32                                     u4_size;
206     /** Pointer to the API function pointer table of the codec          */
207     void                                        *pv_fxns;
208     /** Pointer to the handle of the codec                              */
209     void                                        *pv_codec_handle;
210 }iv_obj_t;
211 
212 /** This structure defines the memory record holder which will          *
213  * be used by the codec to communicate its memory requirements to the   *
214  * application through appropriate API functions                        */
215 
216 typedef struct {
217     /** size of the structure                                           */
218     UWORD32                                     u4_size;
219     /** Pointer to the memory allocated by the application              */
220     void                                        *pv_base;
221     /** u4_size of the memory to be allocated                           */
222     UWORD32                                     u4_mem_size;
223     /** Alignment of the memory pointer                                 */
224     UWORD32                                     u4_mem_alignment;
225     /** Type of the memory to be allocated                              */
226     IV_MEM_TYPE_T                               e_mem_type;
227 }iv_mem_rec_t;
228 
229 /** This structure defines attributes for the raw buffer                */
230 typedef struct {
231     /** size of the structure                                           */
232     UWORD32                                     u4_size;
233 
234     /** Color format                                                    */
235     IV_COLOR_FORMAT_T                           e_color_fmt;
236 
237     /** Pointer to each component                                       */
238     void                                        *apv_bufs[IV_MAX_RAW_COMPONENTS];
239 
240     /** Width of each component                                         */
241     UWORD32                                     au4_wd[IV_MAX_RAW_COMPONENTS];
242 
243     /** Height of each component                                        */
244     UWORD32                                     au4_ht[IV_MAX_RAW_COMPONENTS];
245 
246     /** Stride of each component                                        */
247     UWORD32                                     au4_strd[IV_MAX_RAW_COMPONENTS];
248 
249 }iv_raw_buf_t;
250 
251 /** This structure defines attributes for the bitstream buffer                */
252 typedef struct
253 {
254     /** size of the structure                                           */
255     UWORD32                                     u4_size;
256 
257     /** Pointer to buffer                                               */
258     void                                        *pv_buf;
259 
260     /** Number of valid bytes in the buffer                             */
261     UWORD32                                     u4_bytes;
262 
263     /** Allocated size of the buffer                                    */
264     UWORD32                                     u4_bufsize;
265 
266 }iv_bits_buf_t;
267 
268 /*****************************************************************************/
269 /*  Get Number of Memory Records                                             */
270 /*****************************************************************************/
271 
272 /** Input structure : Get number of memory records                     */
273 typedef struct {
274     /** size of the structure                                          */
275     UWORD32                                     u4_size;
276 
277     /** Command type                                                   */
278     IV_API_COMMAND_TYPE_T                       e_cmd;
279 }iv_num_mem_rec_ip_t;
280 
281 /** Output structure : Get number of memory records                    */
282 typedef struct{
283     /** size of the structure                                          */
284     UWORD32                                     u4_size;
285 
286     /** Return error code                                              */
287     UWORD32                                     u4_error_code;
288 
289     /** Number of memory records that will be used by the codec        */
290     UWORD32                                     u4_num_mem_rec;
291 }iv_num_mem_rec_op_t;
292 
293 
294 /*****************************************************************************/
295 /*  Fill Memory Records                                                      */
296 /*****************************************************************************/
297 
298 /** Input structure : Fill memory records                              */
299 
300 typedef struct {
301     /** size of the structure                                          */
302     UWORD32                                     u4_size;
303 
304     /** Command type                                                   */
305     IV_API_COMMAND_TYPE_T                       e_cmd;
306 
307     /** Number of memory records                                       */
308     UWORD32                                     u4_num_mem_rec;
309 
310     /** pointer to array of memrecords structures should be filled by codec
311     with details of memory resource requirements */
312     iv_mem_rec_t                                *ps_mem_rec;
313 
314     /** maximum width for which codec should request memory requirements */
315     UWORD32                                     u4_max_wd;
316 
317     /** maximum height for which codec should request memory requirements*/
318     UWORD32                                     u4_max_ht;
319 
320     /** Maximum number of reference frames                               */
321     UWORD32                                     u4_max_ref_cnt;
322 
323     /** Maximum number of reorder frames                                 */
324     UWORD32                                     u4_max_reorder_cnt;
325 
326     /** Maximum level supported                                          */
327     UWORD32                                     u4_max_level;
328 
329     /** Color format that codec supports for input/output                */
330     IV_COLOR_FORMAT_T                           e_color_format;
331 
332     /** Maximum search range to be used in X direction                      */
333     UWORD32                                     u4_max_srch_rng_x;
334 
335     /** Maximum search range to be used in Y direction                      */
336     UWORD32                                     u4_max_srch_rng_y;
337 
338 }iv_fill_mem_rec_ip_t;
339 
340 
341 /** Output structure : Fill memory records                               */
342 typedef struct{
343     /** size of the structure                                            */
344     UWORD32                                     u4_size;
345 
346     /** Return error code                                                */
347     UWORD32                                     u4_error_code;
348 
349     /** no of memory record structures which are filled by codec         */
350     UWORD32                                     u4_num_mem_rec;
351 }iv_fill_mem_rec_op_t;
352 
353 
354 /*****************************************************************************/
355 /*  Retrieve Memory Records                                                  */
356 /*****************************************************************************/
357 
358 /** Input structure : Retrieve memory records                                */
359 
360 typedef struct {
361     /** size of the structure                                          */
362     UWORD32                                     u4_size;
363 
364     /** Command type                                                   */
365     IV_API_COMMAND_TYPE_T                       e_cmd;
366 
367     /** array of structures where codec should fill with all memory  requested earlier */
368     iv_mem_rec_t                                *ps_mem_rec;
369 }iv_retrieve_mem_rec_ip_t;
370 
371 
372 typedef struct{
373     /** size of the structure                                            */
374     UWORD32                                     u4_size;
375 
376     /** Return error code                                                */
377     UWORD32                                     u4_error_code;
378 
379     /** no of memory record structures which are filled by codec         */
380     UWORD32                                     u4_num_mem_rec_filled;
381 }iv_retrieve_mem_rec_op_t;
382 
383 #endif /* _IV2_H_ */
384 
385