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