Home | History | Annotate | Download | only in decoder
      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         : impeg2d.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 MPEG2 ASP       */
     27 /*                      Decoder on Cortex A8 - Neon platform                 */
     28 /*                                                                           */
     29 /*  List of Functions : impeg2d_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 __IMPEG2D_H__
     41 #define __IMPEG2D_H__
     42 
     43 #include "iv.h"
     44 #include "ivd.h"
     45 #ifdef __cplusplus
     46 extern "C"
     47 {
     48 #endif
     49 
     50 /*****************************************************************************/
     51 /* Constant Macros                                                           */
     52 /*****************************************************************************/
     53 #define EXPORT_MPEG2DEC_FULLCODEC_MEM_RECORDS   22
     54 
     55 /*****************************************************************************/
     56 /* Function Macros                                                           */
     57 /*****************************************************************************/
     58 #define IS_IVD_CONCEALMENT_APPLIED(x)           (x & (1 << IVD_APPLIEDCONCEALMENT))
     59 #define IS_IVD_INSUFFICIENTDATA_ERROR(x)        (x & (1 << IVD_INSUFFICIENTDATA))
     60 #define IS_IVD_CORRUPTEDDATA_ERROR(x)           (x & (1 << IVD_CORRUPTEDDATA))
     61 #define IS_IVD_CORRUPTEDHEADER_ERROR(x)         (x & (1 << IVD_CORRUPTEDHEADER))
     62 #define IS_IVD_UNSUPPORTEDINPUT_ERROR(x)        (x & (1 << IVD_UNSUPPORTEDINPUT))
     63 #define IS_IVD_UNSUPPORTEDPARAM_ERROR(x)        (x & (1 << IVD_UNSUPPORTEDPARAM))
     64 #define IS_IVD_FATAL_ERROR(x)                   (x & (1 << IVD_FATALERROR))
     65 #define IS_IVD_INVALID_BITSTREAM_ERROR(x)       (x & (1 << IVD_INVALID_BITSTREAM))
     66 #define IS_IVD_INCOMPLETE_BITSTREAM_ERROR(x)    (x & (1 << IVD_INCOMPLETE_BITSTREAM))
     67 
     68 #define SET_IVD_CONCEALMENT_APPLIED(x)          ((x) |= (x) | (1 << IVD_APPLIEDCONCEALMENT))
     69 #define SET_IVD_INSUFFICIENTDATA_ERROR(x)       ((x) |= (x) | (1 << IVD_INSUFFICIENTDATA))
     70 #define SET_IVD_CORRUPTEDDATA_ERROR(x)          ((x) |= (x) | (1 << IVD_CORRUPTEDDATA))
     71 #define SET_IVD_CORRUPTEDHEADER_ERROR(x)        ((x) |= (x) | (1 << IVD_CORRUPTEDHEADER))
     72 #define SET_IVD_UNSUPPORTEDINPUT_ERROR(x)       ((x) |= (x) | (1 << IVD_UNSUPPORTEDINPUT))
     73 #define SET_IVD_UNSUPPORTEDPARAM_ERROR(x)       ((x) |= (x) | (1 << IVD_UNSUPPORTEDPARAM))
     74 #define SET_IVD_FATAL_ERROR(x)                  ((x) |= (x) | (1 << IVD_FATALERROR))
     75 #define SET_IVD_INVALID_BITSTREAM_ERROR(x)      ((x) |= (x) | (1 << IVD_INVALID_BITSTREAM))
     76 #define SET_IVD_INCOMPLETE_BITSTREAM_ERROR(x)   ((x) |= (x) | (1 << IVD_INCOMPLETE_BITSTREAM))
     77 
     78 /*****************************************************************************/
     79 /* API Function Prototype                                                    */
     80 /*****************************************************************************/
     81 IV_API_CALL_STATUS_T impeg2d_api_function(iv_obj_t *ps_handle,
     82                                           void *pv_api_ip,
     83                                           void *pv_api_op);
     84 
     85 /*****************************************************************************/
     86 /* Enums                                                                     */
     87 /*****************************************************************************/
     88 /* Codec Error codes for MPEG2 ASP Decoder                                   */
     89 
     90 typedef enum
     91 {
     92 
     93     IMPEG2D_UNKNOWN_ERROR = IVD_DUMMY_ELEMENT_FOR_CODEC_EXTENSIONS + 1,
     94     /* API calls without init call */
     95     IMPEG2D_INIT_NOT_DONE,
     96     /* Query number of Memory Records API */
     97     IMPEG2D_QUERY_NUM_MEM_REC_FAIL,
     98 
     99     /* Fill Memory Records API */
    100     IMPEG2D_FILL_NUM_MEM_REC_NOT_SUFFICIENT,
    101 
    102     /* Initialize Decoder API */
    103     IMPEG2D_INIT_DEC_SCR_MEM_INSUFFICIENT,
    104     IMPEG2D_INIT_DEC_PER_MEM_INSUFFICIENT,
    105     IMPEG2D_INIT_NUM_MEM_REC_NOT_SUFFICIENT,
    106     IMPEG2D_INIT_CHROMA_FORMAT_HEIGHT_ERROR,
    107 
    108     /* Decode Sequence Header API */
    109     IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND,
    110     IMPEG2D_FRM_HDR_MARKER_BIT_NOT_FOUND,
    111     IMPEG2D_PROF_LEVEL_NOT_SUPPORTED,
    112     IMPEG2D_FMT_NOT_SUPPORTED,
    113     IMPEG2D_SCALABILITIY_NOT_SUPPORTED,
    114     IMPEG2D_PIC_SIZE_NOT_SUPPORTED,
    115 
    116     /* Search for start code API */
    117     //IMPEG2D_SEARCH_START_CODE_FAIL         ,
    118     /* Decode Video Frame API    */
    119     IMPEG2D_START_CODE_NOT_FOUND,
    120     IMPEG2D_MARKER_BIT_NOT_FOUND,
    121     IMPEG2D_INVALID_STUFFING,
    122     IMPEG2D_PROFILE_LEVEL_NOT_SUP,
    123     IMPEG2D_CHROMA_FMT_NOT_SUP,
    124     IMPEG2D_SCALABLITY_NOT_SUP,
    125     IMPEG2D_FRM_HDR_DECODE_ERR,
    126     IMPEG2D_MB_HDR_DECODE_ERR,
    127     IMPEG2D_MB_TEX_DECODE_ERR,
    128     IMPEG2D_INCORRECT_QUANT_MATRIX,
    129     IMPEG2D_INVALID_SKIP_MB,
    130     IMPEG2D_NOT_SUPPORTED_ERR,
    131     IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR,
    132     IMPEG2D_INVALID_PIC_TYPE,
    133     IMPEG2D_INVALID_HUFFMAN_CODE,
    134     IMPEG2D_NO_FREE_BUF_ERR,
    135 
    136     /* slice header errors */
    137     IMPEG2D_INVALID_VERT_SIZE,
    138     IMPEG2D_MB_DATA_DECODE_ERR,
    139 
    140     /* Get Display Frame API */
    141     IMPEG2D_GET_DISP_FRM_FAIL,
    142 
    143     /* Sample Version limitation */
    144     IMPEG2D_SAMPLE_VERSION_LIMIT_ERR,
    145     /**
    146      * Width/height greater than max width and max height
    147      */
    148     IMPEG2D_UNSUPPORTED_DIMENSIONS,
    149 
    150     /* Unknown API Command */
    151     IMPEG2D_UNKNOWN_API_COMMAND
    152 
    153 } IMPEG2D_ERROR_CODES_T;
    154 
    155 /*****************************************************************************/
    156 /* Extended Structures                                                       */
    157 /*****************************************************************************/
    158 typedef enum
    159 {
    160     /** Set number of cores/threads to be used */
    161     IMPEG2D_CMD_CTL_SET_NUM_CORES = IVD_CMD_CTL_CODEC_SUBCMD_START,
    162 
    163     /** Set processor details */
    164     IMPEG2D_CMD_CTL_SET_PROCESSOR = IVD_CMD_CTL_CODEC_SUBCMD_START + 0x001,
    165 
    166     /** Get display buffer dimensions */
    167     IMPEG2D_CMD_CTL_GET_BUFFER_DIMENSIONS = IVD_CMD_CTL_CODEC_SUBCMD_START
    168                     + 0x100,
    169 
    170 } IMPEG2D_CMD_CTL_SUB_CMDS;
    171 
    172 /*****************************************************************************/
    173 /*  Get Number of Memory Records                                             */
    174 /*****************************************************************************/
    175 
    176 typedef struct
    177 {
    178     iv_num_mem_rec_ip_t s_ivd_num_mem_rec_ip_t;
    179 } impeg2d_num_mem_rec_ip_t;
    180 
    181 typedef struct
    182 {
    183     iv_num_mem_rec_op_t s_ivd_num_mem_rec_op_t;
    184 } impeg2d_num_mem_rec_op_t;
    185 
    186 /*****************************************************************************/
    187 /*  Fill Memory Records                                                      */
    188 /*****************************************************************************/
    189 
    190 typedef struct
    191 {
    192     iv_fill_mem_rec_ip_t s_ivd_fill_mem_rec_ip_t;
    193     /* Flag to enable sharing of reference buffers between decoder
    194      and application */
    195 
    196     UWORD32 u4_share_disp_buf;
    197 
    198     /* format in which codec has to give out frame data for display */
    199     IV_COLOR_FORMAT_T e_output_format;
    200 
    201     /**
    202      * Flag to enable/disable deinterlacing
    203      */
    204     UWORD32 u4_deinterlace;
    205 
    206 } impeg2d_fill_mem_rec_ip_t;
    207 
    208 typedef struct
    209 {
    210     iv_fill_mem_rec_op_t s_ivd_fill_mem_rec_op_t;
    211 } impeg2d_fill_mem_rec_op_t;
    212 
    213 /*****************************************************************************/
    214 /*  Retrieve Memory Records                                                  */
    215 /*****************************************************************************/
    216 
    217 typedef struct
    218 {
    219     iv_retrieve_mem_rec_ip_t s_ivd_retrieve_mem_rec_ip_t;
    220 } impeg2d_retrieve_mem_rec_ip_t;
    221 
    222 typedef struct
    223 {
    224     iv_retrieve_mem_rec_op_t s_ivd_retrieve_mem_rec_op_t;
    225 } impeg2d_retrieve_mem_rec_op_t;
    226 
    227 /*****************************************************************************/
    228 /*   Initialize decoder                                                      */
    229 /*****************************************************************************/
    230 
    231 typedef struct
    232 {
    233     ivd_init_ip_t s_ivd_init_ip_t;
    234     /* Flag to enable sharing of reference buffers between decoder
    235      and application */
    236     UWORD32 u4_share_disp_buf;
    237 
    238     /**
    239      * Flag to enable/disable deinterlacing
    240      */
    241     UWORD32 u4_deinterlace;
    242 
    243 } impeg2d_init_ip_t;
    244 
    245 typedef struct
    246 {
    247     ivd_init_op_t s_ivd_init_op_t;
    248 } impeg2d_init_op_t;
    249 
    250 /*****************************************************************************/
    251 /*   Video Decode                                                            */
    252 /*****************************************************************************/
    253 
    254 typedef struct
    255 {
    256     ivd_video_decode_ip_t s_ivd_video_decode_ip_t;
    257 } impeg2d_video_decode_ip_t;
    258 
    259 typedef struct
    260 {
    261     ivd_video_decode_op_t s_ivd_video_decode_op_t;
    262 } impeg2d_video_decode_op_t;
    263 
    264 /*****************************************************************************/
    265 /*   Get Display Frame                                                       */
    266 /*****************************************************************************/
    267 
    268 typedef struct
    269 {
    270     ivd_get_display_frame_ip_t s_ivd_get_display_frame_ip_t;
    271 } impeg2d_get_display_frame_ip_t;
    272 
    273 typedef struct
    274 {
    275     ivd_get_display_frame_op_t s_ivd_get_display_frame_op_t;
    276 } impeg2d_get_display_frame_op_t;
    277 
    278 /*****************************************************************************/
    279 /*   Set Display Frame                                                       */
    280 /*****************************************************************************/
    281 typedef struct
    282 {
    283     ivd_set_display_frame_ip_t s_ivd_set_display_frame_ip_t;
    284 } impeg2d_set_display_frame_ip_t;
    285 
    286 typedef struct
    287 {
    288     ivd_set_display_frame_op_t s_ivd_set_display_frame_op_t;
    289 } impeg2d_set_display_frame_op_t;
    290 
    291 /*****************************************************************************/
    292 /*   Release Display Buffers                                                 */
    293 /*****************************************************************************/
    294 
    295 typedef struct
    296 {
    297     ivd_rel_display_frame_ip_t s_ivd_rel_display_frame_ip_t;
    298 } impeg2d_rel_display_frame_ip_t;
    299 
    300 typedef struct
    301 {
    302     ivd_rel_display_frame_op_t s_ivd_rel_display_frame_op_t;
    303 } impeg2d_rel_display_frame_op_t;
    304 
    305 /*****************************************************************************/
    306 /*   Video control  Flush                                                    */
    307 /*****************************************************************************/
    308 
    309 typedef struct
    310 {
    311     ivd_ctl_flush_ip_t s_ivd_ctl_flush_ip_t;
    312 } impeg2d_ctl_flush_ip_t;
    313 
    314 typedef struct
    315 {
    316     ivd_ctl_flush_op_t s_ivd_ctl_flush_op_t;
    317 } impeg2d_ctl_flush_op_t;
    318 
    319 /*****************************************************************************/
    320 /*   Video control reset                                                     */
    321 /*****************************************************************************/
    322 
    323 typedef struct
    324 {
    325     ivd_ctl_reset_ip_t s_ivd_ctl_reset_ip_t;
    326 } impeg2d_ctl_reset_ip_t;
    327 
    328 typedef struct
    329 {
    330     ivd_ctl_reset_op_t s_ivd_ctl_reset_op_t;
    331 } impeg2d_ctl_reset_op_t;
    332 
    333 /*****************************************************************************/
    334 /*   Video control  Set Params                                               */
    335 /*****************************************************************************/
    336 
    337 typedef struct
    338 {
    339     ivd_ctl_set_config_ip_t s_ivd_ctl_set_config_ip_t;
    340 } impeg2d_ctl_set_config_ip_t;
    341 
    342 typedef struct
    343 {
    344     ivd_ctl_set_config_op_t s_ivd_ctl_set_config_op_t;
    345 } impeg2d_ctl_set_config_op_t;
    346 
    347 /*****************************************************************************/
    348 /*   Video control:Get Buf Info                                              */
    349 /*****************************************************************************/
    350 
    351 typedef struct
    352 {
    353     ivd_ctl_getbufinfo_ip_t s_ivd_ctl_getbufinfo_ip_t;
    354 } impeg2d_ctl_getbufinfo_ip_t;
    355 
    356 typedef struct
    357 {
    358     ivd_ctl_getbufinfo_op_t s_ivd_ctl_getbufinfo_op_t;
    359 } impeg2d_ctl_getbufinfo_op_t;
    360 
    361 /*****************************************************************************/
    362 /*   Video control:Getstatus Call                                            */
    363 /*****************************************************************************/
    364 
    365 typedef struct
    366 {
    367     ivd_ctl_getstatus_ip_t s_ivd_ctl_getstatus_ip_t;
    368 } impeg2d_ctl_getstatus_ip_t;
    369 
    370 typedef struct
    371 {
    372     ivd_ctl_getstatus_op_t s_ivd_ctl_getstatus_op_t;
    373 } impeg2d_ctl_getstatus_op_t;
    374 
    375 /*****************************************************************************/
    376 /*   Video control:Get Version Info                                          */
    377 /*****************************************************************************/
    378 
    379 typedef struct
    380 {
    381     ivd_ctl_getversioninfo_ip_t s_ivd_ctl_getversioninfo_ip_t;
    382 } impeg2d_ctl_getversioninfo_ip_t;
    383 
    384 typedef struct
    385 {
    386     ivd_ctl_getversioninfo_op_t s_ivd_ctl_getversioninfo_op_t;
    387 } impeg2d_ctl_getversioninfo_op_t;
    388 
    389 /*****************************************************************************/
    390 /*   Video control:Disable Qpel                                              */
    391 /*****************************************************************************/
    392 
    393 typedef struct
    394 {
    395     UWORD32 u4_size;
    396     IVD_API_COMMAND_TYPE_T e_cmd;
    397     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    398     UWORD32 u4_num_cores;
    399 } impeg2d_ctl_set_num_cores_ip_t;
    400 
    401 typedef struct
    402 {
    403     UWORD32 u4_size;
    404     UWORD32 u4_error_code;
    405 } impeg2d_ctl_set_num_cores_op_t;
    406 
    407 typedef struct
    408 {
    409     /**
    410      * size
    411      */
    412     UWORD32 u4_size;
    413     /**
    414      * cmd
    415      */
    416     IVD_API_COMMAND_TYPE_T e_cmd;
    417     /**
    418      * sub cmd
    419      */
    420     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    421     /**
    422      * Processor type
    423      */
    424     UWORD32 u4_arch;
    425     /**
    426      * SOC type
    427      */
    428     UWORD32 u4_soc;
    429 
    430     /**
    431      * num_cores
    432      */
    433     UWORD32 u4_num_cores;
    434 
    435 } impeg2d_ctl_set_processor_ip_t;
    436 
    437 typedef struct
    438 {
    439     /**
    440      * size
    441      */
    442     UWORD32 u4_size;
    443     /**
    444      * error_code
    445      */
    446     UWORD32 u4_error_code;
    447 } impeg2d_ctl_set_processor_op_t;
    448 
    449 typedef struct
    450 {
    451 
    452     /**
    453      * size
    454      */
    455     UWORD32 u4_size;
    456 
    457     /**
    458      * cmd
    459      */
    460     IVD_API_COMMAND_TYPE_T e_cmd;
    461 
    462     /**
    463      * sub cmd
    464      */
    465     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    466 } impeg2d_ctl_get_frame_dimensions_ip_t;
    467 
    468 typedef struct
    469 {
    470 
    471     /**
    472      * size
    473      */
    474     UWORD32 u4_size;
    475 
    476     /**
    477      * error_code
    478      */
    479     UWORD32 u4_error_code;
    480 
    481     /**
    482      * x_offset[3]
    483      */
    484     UWORD32 u4_x_offset[3];
    485 
    486     /**
    487      * y_offset[3]
    488      */
    489     UWORD32 u4_y_offset[3];
    490 
    491     /**
    492      * disp_wd[3]
    493      */
    494     UWORD32 u4_disp_wd[3];
    495 
    496     /**
    497      * disp_ht[3]
    498      */
    499     UWORD32 u4_disp_ht[3];
    500 
    501     /**
    502      * buffer_wd[3]
    503      */
    504     UWORD32 u4_buffer_wd[3];
    505 
    506     /**
    507      * buffer_ht[3]
    508      */
    509     UWORD32 u4_buffer_ht[3];
    510 } impeg2d_ctl_get_frame_dimensions_op_t;
    511 
    512 #ifdef __cplusplus
    513 } /* closing brace for extern "C" */
    514 #endif
    515 
    516 #endif /* __IMPEG2D_H__ */
    517