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 Name         : ih264d.h                                             */
23 /*                                                                           */
24 /*  Description       : This file contains all the necessary structure and   */
25 /*                      enumeration definitions needed for the Application   */
26 /*                      Program Interface(API) of the Ittiam H264 ASP       */
27 /*                      Decoder on Cortex A8 - Neon platform                 */
28 /*                                                                           */
29 /*  List of Functions : ih264d_api_function                              */
30 /*                                                                           */
31 /*  Issues / Problems : None                                                 */
32 /*                                                                           */
33 /*  Revision History  :                                                      */
34 /*                                                                           */
35 /*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
36 /*         26 08 2010   100239(RCY)     Draft                                */
37 /*                                                                           */
38 /*****************************************************************************/
39 
40 #ifndef _IH264D_H_
41 #define _IH264D_H_
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #include "iv.h"
47 #include "ivd.h"
48 
49 
50 /*****************************************************************************/
51 /* Constant Macros                                                           */
52 /*****************************************************************************/
53 
54 /*****************************************************************************/
55 /* Function Macros                                                           */
56 /*****************************************************************************/
57 #define IS_IVD_CONCEALMENT_APPLIED(x)       (x & (1 << IVD_APPLIEDCONCEALMENT))
58 #define IS_IVD_INSUFFICIENTDATA_ERROR(x)    (x & (1 << IVD_INSUFFICIENTDATA))
59 #define IS_IVD_CORRUPTEDDATA_ERROR(x)       (x & (1 << IVD_CORRUPTEDDATA))
60 #define IS_IVD_CORRUPTEDHEADER_ERROR(x)     (x & (1 << IVD_CORRUPTEDHEADER))
61 #define IS_IVD_UNSUPPORTEDINPUT_ERROR(x)    (x & (1 << IVD_UNSUPPORTEDINPUT))
62 #define IS_IVD_UNSUPPORTEDPARAM_ERROR(x)    (x & (1 << IVD_UNSUPPORTEDPARAM))
63 #define IS_IVD_FATAL_ERROR(x)               (x & (1 << IVD_FATALERROR))
64 #define IS_IVD_INVALID_BITSTREAM_ERROR(x)   (x & (1 << IVD_INVALID_BITSTREAM))
65 #define IS_IVD_INCOMPLETE_BITSTREAM_ERROR(x) (x & (1 << IVD_INCOMPLETE_BITSTREAM))
66 
67 
68 /*****************************************************************************/
69 /* API Function Prototype                                                    */
70 /*****************************************************************************/
71 IV_API_CALL_STATUS_T ih264d_api_function(iv_obj_t *ps_handle, void *pv_api_ip,void *pv_api_op);
72 
73 /*****************************************************************************/
74 /* Enums                                                                     */
75 /*****************************************************************************/
76 /* Codec Error codes for H264 ASP Decoder                                   */
77 
78 typedef enum {
79 
80     IH264D_VID_HDR_DEC_NUM_FRM_BUF_NOT_SUFFICIENT   = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 1,
81     IH264D_UNSUPPORTED_LEVEL   = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 2,
82     IH264D_UNSUPPORTED_NUM_REF_FRAMES   = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 3
83 
84 }IH264D_ERROR_CODES_T;
85 
86 /*****************************************************************************/
87 /* Extended Structures                                                       */
88 /*****************************************************************************/
89 
90 /*****************************************************************************/
91 /*  Get Number of Memory Records                                             */
92 /*****************************************************************************/
93 
94 
95 typedef struct {
96     iv_num_mem_rec_ip_t                    s_ivd_num_mem_rec_ip_t;
97 }ih264d_num_mem_rec_ip_t;
98 
99 
100 typedef struct{
101     iv_num_mem_rec_op_t                    s_ivd_num_mem_rec_op_t;
102 }ih264d_num_mem_rec_op_t;
103 
104 
105 /*****************************************************************************/
106 /*  Fill Memory Records                                                      */
107 /*****************************************************************************/
108 
109 
110 typedef struct {
111     iv_fill_mem_rec_ip_t                    s_ivd_fill_mem_rec_ip_t;
112     WORD32                                  i4_level;
113     UWORD32                                 u4_num_reorder_frames;
114     UWORD32                                 u4_num_ref_frames;
115     UWORD32                                 u4_share_disp_buf;
116 
117     /* format in which codec has to give out frame data for display */
118     IV_COLOR_FORMAT_T                       e_output_format;
119 
120     /* Number of extra display buffers that will be allocated to handle display pipeline depth */
121     UWORD32                                 u4_num_extra_disp_buf;
122 
123 }ih264d_fill_mem_rec_ip_t;
124 
125 
126 typedef struct{
127     iv_fill_mem_rec_op_t                   s_ivd_fill_mem_rec_op_t;
128 
129 }ih264d_fill_mem_rec_op_t;
130 
131 /*****************************************************************************/
132 /*  Retrieve Memory Records                                                  */
133 /*****************************************************************************/
134 
135 
136 typedef struct {
137     iv_retrieve_mem_rec_ip_t               s_ivd_retrieve_mem_rec_ip_t;
138 }ih264d_retrieve_mem_rec_ip_t;
139 
140 
141 typedef struct{
142     iv_retrieve_mem_rec_op_t               s_ivd_retrieve_mem_rec_op_t;
143 }ih264d_retrieve_mem_rec_op_t;
144 
145 
146 /*****************************************************************************/
147 /*   Initialize decoder                                                      */
148 /*****************************************************************************/
149 
150 
151 typedef struct {
152     ivd_init_ip_t                           s_ivd_init_ip_t;
153     WORD32                                  i4_level;
154     UWORD32                                 u4_num_reorder_frames;
155     UWORD32                                 u4_num_ref_frames;
156     UWORD32                                 u4_share_disp_buf;
157     /* Number of extra display buffers that will be allocated to handle display pipeline depth */
158     UWORD32                                 u4_num_extra_disp_buf;
159 
160 }ih264d_init_ip_t;
161 
162 
163 typedef struct{
164     ivd_init_op_t                           s_ivd_init_op_t;
165 }ih264d_init_op_t;
166 
167 
168 /*****************************************************************************/
169 /*   Video Decode                                                            */
170 /*****************************************************************************/
171 
172 
173 typedef struct {
174     ivd_video_decode_ip_t                   s_ivd_video_decode_ip_t;
175 }ih264d_video_decode_ip_t;
176 
177 
178 typedef struct{
179     ivd_video_decode_op_t                   s_ivd_video_decode_op_t;
180 }ih264d_video_decode_op_t;
181 
182 
183 /*****************************************************************************/
184 /*   Get Display Frame                                                       */
185 /*****************************************************************************/
186 
187 
188 typedef struct
189 {
190     ivd_get_display_frame_ip_t              s_ivd_get_display_frame_ip_t;
191 }ih264d_get_display_frame_ip_t;
192 
193 
194 typedef struct
195 {
196     ivd_get_display_frame_op_t              s_ivd_get_display_frame_op_t;
197 }ih264d_get_display_frame_op_t;
198 
199 /*****************************************************************************/
200 /*   Set Display Frame                                                       */
201 /*****************************************************************************/
202 
203 
204 typedef struct
205 {
206     ivd_set_display_frame_ip_t              s_ivd_set_display_frame_ip_t;
207 }ih264d_set_display_frame_ip_t;
208 
209 
210 typedef struct
211 {
212     ivd_set_display_frame_op_t              s_ivd_set_display_frame_op_t;
213 }ih264d_set_display_frame_op_t;
214 
215 /*****************************************************************************/
216 /*   Release Display Buffers                                                 */
217 /*****************************************************************************/
218 
219 
220 typedef struct
221 {
222     ivd_rel_display_frame_ip_t                  s_ivd_rel_display_frame_ip_t;
223 }ih264d_rel_display_frame_ip_t;
224 
225 
226 typedef struct
227 {
228     ivd_rel_display_frame_op_t                  s_ivd_rel_display_frame_op_t;
229 }ih264d_rel_display_frame_op_t;
230 
231 
232 typedef enum {
233     /** Set number of cores/threads to be used */
234     IH264D_CMD_CTL_SET_NUM_CORES         = IVD_CMD_CTL_CODEC_SUBCMD_START,
235 
236     /** Set processor details */
237     IH264D_CMD_CTL_SET_PROCESSOR         = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x001,
238 
239     /** Get display buffer dimensions */
240     IH264D_CMD_CTL_GET_BUFFER_DIMENSIONS = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x100,
241 
242     /** Get VUI parameters */
243     IH264D_CMD_CTL_GET_VUI_PARAMS        = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x101,
244 
245     /** Enable/disable GPU, supported on select platforms */
246     IH264D_CMD_CTL_GPU_ENABLE_DISABLE    = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x200,
247 
248     /** Set degrade level */
249     IH264D_CMD_CTL_DEGRADE               = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x300
250 }IH264D_CMD_CTL_SUB_CMDS;
251 /*****************************************************************************/
252 /*   Video control  Flush                                                    */
253 /*****************************************************************************/
254 
255 
256 typedef struct{
257     ivd_ctl_flush_ip_t                      s_ivd_ctl_flush_ip_t;
258 }ih264d_ctl_flush_ip_t;
259 
260 
261 typedef struct{
262     ivd_ctl_flush_op_t                      s_ivd_ctl_flush_op_t;
263 }ih264d_ctl_flush_op_t;
264 
265 /*****************************************************************************/
266 /*   Video control reset                                                     */
267 /*****************************************************************************/
268 
269 
270 typedef struct{
271     ivd_ctl_reset_ip_t                      s_ivd_ctl_reset_ip_t;
272 }ih264d_ctl_reset_ip_t;
273 
274 
275 typedef struct{
276     ivd_ctl_reset_op_t                      s_ivd_ctl_reset_op_t;
277 }ih264d_ctl_reset_op_t;
278 
279 
280 /*****************************************************************************/
281 /*   Video control  Set Params                                               */
282 /*****************************************************************************/
283 
284 
285 typedef struct {
286     ivd_ctl_set_config_ip_t             s_ivd_ctl_set_config_ip_t;
287 }ih264d_ctl_set_config_ip_t;
288 
289 
290 typedef struct{
291     ivd_ctl_set_config_op_t             s_ivd_ctl_set_config_op_t;
292 }ih264d_ctl_set_config_op_t;
293 
294 /*****************************************************************************/
295 /*   Video control:Get Buf Info                                              */
296 /*****************************************************************************/
297 
298 
299 typedef struct{
300     ivd_ctl_getbufinfo_ip_t             s_ivd_ctl_getbufinfo_ip_t;
301 }ih264d_ctl_getbufinfo_ip_t;
302 
303 
304 
305 typedef struct{
306     ivd_ctl_getbufinfo_op_t             s_ivd_ctl_getbufinfo_op_t;
307 }ih264d_ctl_getbufinfo_op_t;
308 
309 
310 /*****************************************************************************/
311 /*   Video control:Getstatus Call                                            */
312 /*****************************************************************************/
313 
314 
315 typedef struct{
316     ivd_ctl_getstatus_ip_t                  s_ivd_ctl_getstatus_ip_t;
317 }ih264d_ctl_getstatus_ip_t;
318 
319 
320 
321 typedef struct{
322     ivd_ctl_getstatus_op_t                  s_ivd_ctl_getstatus_op_t;
323 }ih264d_ctl_getstatus_op_t;
324 
325 
326 /*****************************************************************************/
327 /*   Video control:Get Version Info                                          */
328 /*****************************************************************************/
329 
330 
331 typedef struct{
332     ivd_ctl_getversioninfo_ip_t         s_ivd_ctl_getversioninfo_ip_t;
333 }ih264d_ctl_getversioninfo_ip_t;
334 
335 
336 
337 typedef struct{
338     ivd_ctl_getversioninfo_op_t         s_ivd_ctl_getversioninfo_op_t;
339 }ih264d_ctl_getversioninfo_op_t;
340 
341 typedef struct{
342 
343     /**
344      * u4_size
345      */
346     UWORD32                                     u4_size;
347 
348     /**
349      * cmd
350      */
351     IVD_API_COMMAND_TYPE_T                      e_cmd;
352 
353     /**
354      * sub_cmd
355      */
356     IVD_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
357 
358     /**
359      * Pictures that are are degraded
360      * 0 : No degrade
361      * 1 : Only on non-reference frames
362      * 2 : Use interval specified by u4_nondegrade_interval
363      * 3 : All non-key frames
364      * 4 : All frames
365      */
366     WORD32                                     i4_degrade_pics;
367 
368     /**
369      * Interval for pictures which are completely decoded without any degradation
370      */
371     WORD32                                     i4_nondegrade_interval;
372 
373     /**
374      * bit position (lsb is zero): Type of degradation
375      * 1 : Disable deblocking
376      * 2 : Faster inter prediction filters
377      * 3 : Fastest inter prediction filters
378      */
379     WORD32                                     i4_degrade_type;
380 
381 }ih264d_ctl_degrade_ip_t;
382 
383 typedef struct
384 {
385     /**
386      * u4_size
387      */
388     UWORD32                                     u4_size;
389 
390     /**
391      * error_code
392      */
393     UWORD32                                     u4_error_code;
394 }ih264d_ctl_degrade_op_t;
395 
396 typedef struct{
397     UWORD32                                     u4_size;
398     IVD_API_COMMAND_TYPE_T                      e_cmd;
399     IVD_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
400     UWORD32                                     u4_disable_deblk_level;
401 }ih264d_ctl_disable_deblock_ip_t;
402 
403 typedef struct{
404     UWORD32                                     u4_size;
405     UWORD32                                     u4_error_code;
406 }ih264d_ctl_disable_deblock_op_t;
407 
408 
409 typedef struct{
410     UWORD32                                     u4_size;
411     IVD_API_COMMAND_TYPE_T                      e_cmd;
412     IVD_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
413     UWORD32                                     u4_num_cores;
414 }ih264d_ctl_set_num_cores_ip_t;
415 
416 typedef struct{
417     UWORD32                                     u4_size;
418     UWORD32                                     u4_error_code;
419 }ih264d_ctl_set_num_cores_op_t;
420 
421 typedef struct
422 {
423      /**
424       * i4_size
425       */
426     UWORD32                                     u4_size;
427     /**
428      * cmd
429      */
430     IVD_API_COMMAND_TYPE_T                      e_cmd;
431     /**
432      * sub cmd
433      */
434     IVD_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
435     /**
436      * Processor type
437      */
438     UWORD32                                     u4_arch;
439     /**
440      * SOC type
441      */
442     UWORD32                                     u4_soc;
443 
444     /**
445      * num_cores
446      */
447     UWORD32                                     u4_num_cores;
448 
449 }ih264d_ctl_set_processor_ip_t;
450 
451 typedef struct
452 {
453     /**
454      * i4_size
455      */
456     UWORD32                                     u4_size;
457     /**
458      * error_code
459      */
460     UWORD32                                     u4_error_code;
461 }ih264d_ctl_set_processor_op_t;
462 
463 typedef struct{
464     UWORD32                                     u4_size;
465     IVD_API_COMMAND_TYPE_T                      e_cmd;
466     IVD_CONTROL_API_COMMAND_TYPE_T              e_sub_cmd;
467 }ih264d_ctl_get_frame_dimensions_ip_t;
468 
469 
470 typedef struct{
471     UWORD32                                     u4_size;
472     UWORD32                                     u4_error_code;
473     UWORD32                                     u4_x_offset[3];
474     UWORD32                                     u4_y_offset[3];
475     UWORD32                                     u4_disp_wd[3];
476     UWORD32                                     u4_disp_ht[3];
477     UWORD32                                     u4_buffer_wd[3];
478     UWORD32                                     u4_buffer_ht[3];
479 }ih264d_ctl_get_frame_dimensions_op_t;
480 
481 #ifdef __cplusplus
482 } /* closing brace for extern "C" */
483 #endif
484 #endif /* _IH264D_H_ */
485