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 } impeg2d_fill_mem_rec_ip_t;
    202 
    203 typedef struct
    204 {
    205     iv_fill_mem_rec_op_t s_ivd_fill_mem_rec_op_t;
    206 } impeg2d_fill_mem_rec_op_t;
    207 
    208 /*****************************************************************************/
    209 /*  Retrieve Memory Records                                                  */
    210 /*****************************************************************************/
    211 
    212 typedef struct
    213 {
    214     iv_retrieve_mem_rec_ip_t s_ivd_retrieve_mem_rec_ip_t;
    215 } impeg2d_retrieve_mem_rec_ip_t;
    216 
    217 typedef struct
    218 {
    219     iv_retrieve_mem_rec_op_t s_ivd_retrieve_mem_rec_op_t;
    220 } impeg2d_retrieve_mem_rec_op_t;
    221 
    222 /*****************************************************************************/
    223 /*   Initialize decoder                                                      */
    224 /*****************************************************************************/
    225 
    226 typedef struct
    227 {
    228     ivd_init_ip_t s_ivd_init_ip_t;
    229     /* Flag to enable sharing of reference buffers between decoder
    230      and application */
    231     UWORD32 u4_share_disp_buf;
    232 
    233 } impeg2d_init_ip_t;
    234 
    235 typedef struct
    236 {
    237     ivd_init_op_t s_ivd_init_op_t;
    238 } impeg2d_init_op_t;
    239 
    240 /*****************************************************************************/
    241 /*   Video Decode                                                            */
    242 /*****************************************************************************/
    243 
    244 typedef struct
    245 {
    246     ivd_video_decode_ip_t s_ivd_video_decode_ip_t;
    247 } impeg2d_video_decode_ip_t;
    248 
    249 typedef struct
    250 {
    251     ivd_video_decode_op_t s_ivd_video_decode_op_t;
    252 } impeg2d_video_decode_op_t;
    253 
    254 /*****************************************************************************/
    255 /*   Get Display Frame                                                       */
    256 /*****************************************************************************/
    257 
    258 typedef struct
    259 {
    260     ivd_get_display_frame_ip_t s_ivd_get_display_frame_ip_t;
    261 } impeg2d_get_display_frame_ip_t;
    262 
    263 typedef struct
    264 {
    265     ivd_get_display_frame_op_t s_ivd_get_display_frame_op_t;
    266 } impeg2d_get_display_frame_op_t;
    267 
    268 /*****************************************************************************/
    269 /*   Set Display Frame                                                       */
    270 /*****************************************************************************/
    271 typedef struct
    272 {
    273     ivd_set_display_frame_ip_t s_ivd_set_display_frame_ip_t;
    274 } impeg2d_set_display_frame_ip_t;
    275 
    276 typedef struct
    277 {
    278     ivd_set_display_frame_op_t s_ivd_set_display_frame_op_t;
    279 } impeg2d_set_display_frame_op_t;
    280 
    281 /*****************************************************************************/
    282 /*   Release Display Buffers                                                 */
    283 /*****************************************************************************/
    284 
    285 typedef struct
    286 {
    287     ivd_rel_display_frame_ip_t s_ivd_rel_display_frame_ip_t;
    288 } impeg2d_rel_display_frame_ip_t;
    289 
    290 typedef struct
    291 {
    292     ivd_rel_display_frame_op_t s_ivd_rel_display_frame_op_t;
    293 } impeg2d_rel_display_frame_op_t;
    294 
    295 /*****************************************************************************/
    296 /*   Video control  Flush                                                    */
    297 /*****************************************************************************/
    298 
    299 typedef struct
    300 {
    301     ivd_ctl_flush_ip_t s_ivd_ctl_flush_ip_t;
    302 } impeg2d_ctl_flush_ip_t;
    303 
    304 typedef struct
    305 {
    306     ivd_ctl_flush_op_t s_ivd_ctl_flush_op_t;
    307 } impeg2d_ctl_flush_op_t;
    308 
    309 /*****************************************************************************/
    310 /*   Video control reset                                                     */
    311 /*****************************************************************************/
    312 
    313 typedef struct
    314 {
    315     ivd_ctl_reset_ip_t s_ivd_ctl_reset_ip_t;
    316 } impeg2d_ctl_reset_ip_t;
    317 
    318 typedef struct
    319 {
    320     ivd_ctl_reset_op_t s_ivd_ctl_reset_op_t;
    321 } impeg2d_ctl_reset_op_t;
    322 
    323 /*****************************************************************************/
    324 /*   Video control  Set Params                                               */
    325 /*****************************************************************************/
    326 
    327 typedef struct
    328 {
    329     ivd_ctl_set_config_ip_t s_ivd_ctl_set_config_ip_t;
    330 } impeg2d_ctl_set_config_ip_t;
    331 
    332 typedef struct
    333 {
    334     ivd_ctl_set_config_op_t s_ivd_ctl_set_config_op_t;
    335 } impeg2d_ctl_set_config_op_t;
    336 
    337 /*****************************************************************************/
    338 /*   Video control:Get Buf Info                                              */
    339 /*****************************************************************************/
    340 
    341 typedef struct
    342 {
    343     ivd_ctl_getbufinfo_ip_t s_ivd_ctl_getbufinfo_ip_t;
    344 } impeg2d_ctl_getbufinfo_ip_t;
    345 
    346 typedef struct
    347 {
    348     ivd_ctl_getbufinfo_op_t s_ivd_ctl_getbufinfo_op_t;
    349 } impeg2d_ctl_getbufinfo_op_t;
    350 
    351 /*****************************************************************************/
    352 /*   Video control:Getstatus Call                                            */
    353 /*****************************************************************************/
    354 
    355 typedef struct
    356 {
    357     ivd_ctl_getstatus_ip_t s_ivd_ctl_getstatus_ip_t;
    358 } impeg2d_ctl_getstatus_ip_t;
    359 
    360 typedef struct
    361 {
    362     ivd_ctl_getstatus_op_t s_ivd_ctl_getstatus_op_t;
    363 } impeg2d_ctl_getstatus_op_t;
    364 
    365 /*****************************************************************************/
    366 /*   Video control:Get Version Info                                          */
    367 /*****************************************************************************/
    368 
    369 typedef struct
    370 {
    371     ivd_ctl_getversioninfo_ip_t s_ivd_ctl_getversioninfo_ip_t;
    372 } impeg2d_ctl_getversioninfo_ip_t;
    373 
    374 typedef struct
    375 {
    376     ivd_ctl_getversioninfo_op_t s_ivd_ctl_getversioninfo_op_t;
    377 } impeg2d_ctl_getversioninfo_op_t;
    378 
    379 /*****************************************************************************/
    380 /*   Video control:Disable Qpel                                              */
    381 /*****************************************************************************/
    382 
    383 typedef struct
    384 {
    385     UWORD32 u4_size;
    386     IVD_API_COMMAND_TYPE_T e_cmd;
    387     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    388     UWORD32 u4_num_cores;
    389 } impeg2d_ctl_set_num_cores_ip_t;
    390 
    391 typedef struct
    392 {
    393     UWORD32 u4_size;
    394     UWORD32 u4_error_code;
    395 } impeg2d_ctl_set_num_cores_op_t;
    396 
    397 typedef struct
    398 {
    399     /**
    400      * size
    401      */
    402     UWORD32 u4_size;
    403     /**
    404      * cmd
    405      */
    406     IVD_API_COMMAND_TYPE_T e_cmd;
    407     /**
    408      * sub cmd
    409      */
    410     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    411     /**
    412      * Processor type
    413      */
    414     UWORD32 u4_arch;
    415     /**
    416      * SOC type
    417      */
    418     UWORD32 u4_soc;
    419 
    420     /**
    421      * num_cores
    422      */
    423     UWORD32 u4_num_cores;
    424 
    425 } impeg2d_ctl_set_processor_ip_t;
    426 
    427 typedef struct
    428 {
    429     /**
    430      * size
    431      */
    432     UWORD32 u4_size;
    433     /**
    434      * error_code
    435      */
    436     UWORD32 u4_error_code;
    437 } impeg2d_ctl_set_processor_op_t;
    438 
    439 typedef struct
    440 {
    441 
    442     /**
    443      * size
    444      */
    445     UWORD32 u4_size;
    446 
    447     /**
    448      * cmd
    449      */
    450     IVD_API_COMMAND_TYPE_T e_cmd;
    451 
    452     /**
    453      * sub cmd
    454      */
    455     IVD_CONTROL_API_COMMAND_TYPE_T e_sub_cmd;
    456 } impeg2d_ctl_get_frame_dimensions_ip_t;
    457 
    458 typedef struct
    459 {
    460 
    461     /**
    462      * size
    463      */
    464     UWORD32 u4_size;
    465 
    466     /**
    467      * error_code
    468      */
    469     UWORD32 u4_error_code;
    470 
    471     /**
    472      * x_offset[3]
    473      */
    474     UWORD32 u4_x_offset[3];
    475 
    476     /**
    477      * y_offset[3]
    478      */
    479     UWORD32 u4_y_offset[3];
    480 
    481     /**
    482      * disp_wd[3]
    483      */
    484     UWORD32 u4_disp_wd[3];
    485 
    486     /**
    487      * disp_ht[3]
    488      */
    489     UWORD32 u4_disp_ht[3];
    490 
    491     /**
    492      * buffer_wd[3]
    493      */
    494     UWORD32 u4_buffer_wd[3];
    495 
    496     /**
    497      * buffer_ht[3]
    498      */
    499     UWORD32 u4_buffer_ht[3];
    500 } impeg2d_ctl_get_frame_dimensions_op_t;
    501 
    502 #ifdef __cplusplus
    503 } /* closing brace for extern "C" */
    504 #endif
    505 
    506 #endif /* __IMPEG2D_H__ */
    507