Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2010 Samsung Electronics Co. LTD
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef _SSBSIP_MFC_API_H_
     18 #define _SSBSIP_MFC_API_H_
     19 
     20 /*--------------------------------------------------------------------------------*/
     21 /* Definition                                                                     */
     22 /*--------------------------------------------------------------------------------*/
     23 #define MAX_DECODER_INPUT_BUFFER_SIZE  (1024 * 3072)
     24 #define MAX_ENCODER_OUTPUT_BUFFER_SIZE (1024 * 3072)
     25 
     26 #define MMAP_BUFFER_SIZE_MMAP          (70*1024*1024)
     27 
     28 #define S5PC110_MFC_DEV_NAME           "/dev/s3c-mfc"
     29 
     30 /*--------------------------------------------------------------------------------*/
     31 /* Structure and Type                                                             */
     32 /*--------------------------------------------------------------------------------*/
     33 typedef enum {
     34     H264_DEC,
     35     VC1_DEC,     /* VC1 advaced Profile decoding  */
     36     MPEG4_DEC,
     37     XVID_DEC,
     38     MPEG1_DEC,
     39     MPEG2_DEC,
     40     H263_DEC,
     41     VC1RCV_DEC,  /* VC1 simple/main profile decoding  */
     42     FIMV1_DEC,
     43     FIMV2_DEC,
     44     FIMV3_DEC,
     45     FIMV4_DEC,
     46     H264_ENC,
     47     MPEG4_ENC,
     48     H263_ENC,
     49     UNKNOWN_TYPE
     50 } SSBSIP_MFC_CODEC_TYPE;
     51 
     52 typedef enum {
     53     DONT_CARE = 0,
     54     I_FRAME = 1,
     55     NOT_CODED = 2
     56 } SSBSIP_MFC_FORCE_SET_FRAME_TYPE;
     57 
     58 typedef enum {
     59     NV12_LINEAR = 0,
     60     NV12_TILE
     61 } SSBSIP_MFC_INSTRM_MODE_TYPE;
     62 
     63 typedef enum {
     64     NO_CACHE = 0,
     65     CACHE = 1
     66 } SSBIP_MFC_BUFFER_TYPE;
     67 
     68 typedef enum {
     69     MFC_DEC_SETCONF_POST_ENABLE = 1,
     70     MFC_DEC_SETCONF_EXTRA_BUFFER_NUM,
     71     MFC_DEC_SETCONF_DISPLAY_DELAY,
     72     MFC_DEC_SETCONF_IS_LAST_FRAME,
     73     MFC_DEC_SETCONF_SLICE_ENABLE,
     74     MFC_DEC_SETCONF_CRC_ENABLE,
     75     MFC_DEC_SETCONF_FIMV1_WIDTH_HEIGHT,
     76     MFC_DEC_SETCONF_FRAME_TAG,
     77     MFC_DEC_GETCONF_CRC_DATA,
     78     MFC_DEC_GETCONF_BUF_WIDTH_HEIGHT,
     79     MFC_DEC_GETCONF_CROP_INFO,
     80     MFC_DEC_GETCONF_FRAME_TAG
     81 } SSBSIP_MFC_DEC_CONF;
     82 
     83 typedef enum {
     84     MFC_ENC_SETCONF_FRAME_TYPE = 100,
     85     MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
     86     MFC_ENC_SETCONF_CHANGE_BIT_RATE,
     87     MFC_ENC_SETCONF_FRAME_TAG,
     88     MFC_ENC_SETCONF_ALLOW_FRAME_SKIP,
     89     MFC_ENC_GETCONF_FRAME_TAG
     90 } SSBSIP_MFC_ENC_CONF;
     91 
     92 typedef enum {
     93     MFC_GETOUTBUF_STATUS_NULL = 0,
     94     MFC_GETOUTBUF_DECODING_ONLY = 1,
     95     MFC_GETOUTBUF_DISPLAY_DECODING,
     96     MFC_GETOUTBUF_DISPLAY_ONLY,
     97     MFC_GETOUTBUF_DISPLAY_END
     98 } SSBSIP_MFC_DEC_OUTBUF_STATUS;
     99 
    100 typedef enum {
    101     MFC_FRAME_TYPE_NOT_CODED,
    102     MFC_FRAME_TYPE_I_FRAME,
    103     MFC_FRAME_TYPE_P_FRAME,
    104     MFC_FRAME_TYPE_B_FRAME,
    105     MFC_FRAME_TYPE_OTHERS
    106 } SSBSIP_MFC_FRAME_TYPE;
    107 
    108 typedef enum {
    109     MFC_RET_OK                      = 1,
    110     MFC_RET_FAIL                    = -1000,
    111     MFC_RET_OPEN_FAIL               = -1001,
    112     MFC_RET_CLOSE_FAIL              = -1002,
    113 
    114     MFC_RET_DEC_INIT_FAIL           = -2000,
    115     MFC_RET_DEC_EXE_TIME_OUT        = -2001,
    116     MFC_RET_DEC_EXE_ERR             = -2002,
    117     MFC_RET_DEC_GET_INBUF_FAIL      = -2003,
    118     MFC_RET_DEC_SET_INBUF_FAIL      = -2004,
    119     MFC_RET_DEC_GET_OUTBUF_FAIL     = -2005,
    120     MFC_RET_DEC_GET_CONF_FAIL       = -2006,
    121     MFC_RET_DEC_SET_CONF_FAIL       = -2007,
    122 
    123     MFC_RET_ENC_INIT_FAIL           = -3000,
    124     MFC_RET_ENC_EXE_TIME_OUT        = -3001,
    125     MFC_RET_ENC_EXE_ERR             = -3002,
    126     MFC_RET_ENC_GET_INBUF_FAIL      = -3003,
    127     MFC_RET_ENC_SET_INBUF_FAIL      = -3004,
    128     MFC_RET_ENC_GET_OUTBUF_FAIL     = -3005,
    129     MFC_RET_ENC_SET_OUTBUF_FAIL     = -3006,
    130     MFC_RET_ENC_GET_CONF_FAIL       = -3007,
    131     MFC_RET_ENC_SET_CONF_FAIL       = -3008,
    132 
    133     MFC_RET_INVALID_PARAM           = -4000
    134 } SSBSIP_MFC_ERROR_CODE;
    135 
    136 typedef struct {
    137     void *YPhyAddr;                     // [OUT] physical address of Y
    138     void *CPhyAddr;                     // [OUT] physical address of CbCr
    139     void *YVirAddr;                     // [OUT] virtual address of Y
    140     void *CVirAddr;                     // [OUT] virtual address of CbCr
    141 
    142     int img_width;                      // [OUT] width of real image
    143     int img_height;                     // [OUT] height of real image
    144     int buf_width;                      // [OUT] width aligned to 16
    145     int buf_height;                     // [OUT] height alighed to 16
    146 
    147     int timestamp_top;                  // [OUT] timestamp of top filed(This is used for interlaced stream)
    148     int timestamp_bottom;               // [OUT] timestamp of bottom filed(This is used for interlaced stream)
    149     int consumedByte;                   // [OUT] the number of byte consumed during decoding
    150     int res_change;                     // [OUT] whether resolution is changed or not. 0: not change, 1: increased, 2: decreased
    151     int crop_top_offset;                // [OUT] crop information, top_offset
    152     int crop_bottom_offset;             // [OUT] crop information, bottom_offset
    153     int crop_left_offset;               // [OUT] crop information, left_offset
    154     int crop_right_offset;              // [OUT] crop information, right_offset
    155 } SSBSIP_MFC_DEC_OUTPUT_INFO;
    156 
    157 typedef struct {
    158     void *YPhyAddr;                     // [IN/OUT] physical address of Y
    159     void *CPhyAddr;                     // [IN/OUT] physical address of CbCr
    160     void *YVirAddr;                     // [IN/OUT] virtual address of Y
    161     void *CVirAddr;                     // [IN/OUT] virtual address of CbCr
    162     int YSize;                          // [IN/OUT] input size of Y data
    163     int CSize;                          // [IN/OUT] input size of CbCr data
    164 } SSBSIP_MFC_ENC_INPUT_INFO;
    165 
    166 typedef struct {
    167     unsigned int dataSize;              // [OUT] encoded data size(without header)
    168     unsigned int headerSize;            // [OUT] encoded header size
    169     unsigned int frameType;             // [OUT] frame type of encoded stream
    170     void *StrmPhyAddr;                  // [OUT] physical address of Y
    171     void *StrmVirAddr;                  // [OUT] virtual address of Y
    172     void *encodedYPhyAddr;              // [OUT] physical address of Y which is flushed
    173     void *encodedCPhyAddr;              // [OUT] physical address of C which is flushed
    174 } SSBSIP_MFC_ENC_OUTPUT_INFO;
    175 
    176 typedef struct {
    177     // common parameters
    178     SSBSIP_MFC_CODEC_TYPE codecType;    // [IN] codec type
    179     int SourceWidth;                    // [IN] width of video to be encoded
    180     int SourceHeight;                   // [IN] height of video to be encoded
    181     int IDRPeriod;                      // [IN] GOP number(interval of I-frame)
    182     int SliceMode;                      // [IN] Multi slice mode
    183     int RandomIntraMBRefresh;           // [IN] cyclic intra refresh
    184     int EnableFRMRateControl;           // [IN] frame based rate control enable
    185     int Bitrate;                        // [IN] rate control parameter(bit rate)
    186     int FrameQp;                        // [IN] The quantization parameter of the frame
    187     int FrameQp_P;                      // [IN] The quantization parameter of the P frame
    188     int QSCodeMax;                      // [IN] Maximum Quantization value
    189     int QSCodeMin;                      // [IN] Minimum Quantization value
    190     int CBRPeriodRf;                    // [IN] Reaction coefficient parameter for rate control
    191     int PadControlOn;                   // [IN] Enable padding control
    192     int LumaPadVal;                     // [IN] Luma pel value used to fill padding area
    193     int CbPadVal;                       // [IN] CB pel value used to fill padding area
    194     int CrPadVal;                       // [IN] CR pel value used to fill padding area
    195     int FrameMap;                       // [IN] Encoding input mode(tile mode or linear mode)
    196 
    197     // H.264 specific parameters
    198     int ProfileIDC;                     // [IN] profile
    199     int LevelIDC;                       // [IN] level
    200     int FrameQp_B;                      // [IN] The quantization parameter of the B frame
    201     int FrameRate;                      // [IN] rate control parameter(frame rate)
    202     int SliceArgument;                  // [IN] MB number or byte number
    203     int NumberBFrames;                  // [IN] The number of consecutive B frame inserted
    204     int NumberReferenceFrames;          // [IN] The number of reference pictures used
    205     int NumberRefForPframes;            // [IN] The number of reference pictures used for encoding P pictures
    206     int LoopFilterDisable;              // [IN] disable the loop filter
    207     int LoopFilterAlphaC0Offset;        // [IN] Alpha & C0 offset for H.264 loop filter
    208     int LoopFilterBetaOffset;           // [IN] Beta offset for H.264 loop filter
    209     int SymbolMode;                     // [IN] The mode of entropy coding(CABAC, CAVLC)
    210     int PictureInterlace;               // [IN] Enables the interlace mode
    211     int Transform8x8Mode;               // [IN] Allow 8x8 transform(This is allowed only for high profile)
    212     int EnableMBRateControl;            // [IN] Enable macroblock-level rate control
    213     int DarkDisable;                    // [IN] Disable adaptive rate control on dark region
    214     int SmoothDisable;                  // [IN] Disable adaptive rate control on smooth region
    215     int StaticDisable;                  // [IN] Disable adaptive rate control on static region
    216     int ActivityDisable;                // [IN] Disable adaptive rate control on high activity region
    217 } SSBSIP_MFC_ENC_H264_PARAM;
    218 
    219 typedef struct {
    220     // common parameters
    221     SSBSIP_MFC_CODEC_TYPE codecType;    // [IN] codec type
    222     int SourceWidth;                    // [IN] width of video to be encoded
    223     int SourceHeight;                   // [IN] height of video to be encoded
    224     int IDRPeriod;                      // [IN] GOP number(interval of I-frame)
    225     int SliceMode;                      // [IN] Multi slice mode
    226     int RandomIntraMBRefresh;           // [IN] cyclic intra refresh
    227     int EnableFRMRateControl;           // [IN] frame based rate control enable
    228     int Bitrate;                        // [IN] rate control parameter(bit rate)
    229     int FrameQp;                        // [IN] The quantization parameter of the frame
    230     int FrameQp_P;                      // [IN] The quantization parameter of the P frame
    231     int QSCodeMax;                      // [IN] Maximum Quantization value
    232     int QSCodeMin;                      // [IN] Minimum Quantization value
    233     int CBRPeriodRf;                    // [IN] Reaction coefficient parameter for rate control
    234     int PadControlOn;                   // [IN] Enable padding control
    235     int LumaPadVal;                     // [IN] Luma pel value used to fill padding area
    236     int CbPadVal;                       // [IN] CB pel value used to fill padding area
    237     int CrPadVal;                       // [IN] CR pel value used to fill padding area
    238     int FrameMap;                       // [IN] Encoding input mode(tile mode or linear mode)
    239 
    240     // MPEG4 specific parameters
    241     int ProfileIDC;                     // [IN] profile
    242     int LevelIDC;                       // [IN] level
    243     int FrameQp_B;                      // [IN] The quantization parameter of the B frame
    244     int TimeIncreamentRes;              // [IN] frame rate
    245     int VopTimeIncreament;              // [IN] frame rate
    246     int SliceArgument;                  // [IN] MB number or byte number
    247     int NumberBFrames;                  // [IN] The number of consecutive B frame inserted
    248     int DisableQpelME;                  // [IN] disable quarter-pixel motion estimation
    249 } SSBSIP_MFC_ENC_MPEG4_PARAM;
    250 
    251 typedef struct {
    252     // common parameters
    253     SSBSIP_MFC_CODEC_TYPE codecType;    // [IN] codec type
    254     int SourceWidth;                    // [IN] width of video to be encoded
    255     int SourceHeight;                   // [IN] height of video to be encoded
    256     int IDRPeriod;                      // [IN] GOP number(interval of I-frame)
    257     int SliceMode;                      // [IN] Multi slice mode
    258     int RandomIntraMBRefresh;           // [IN] cyclic intra refresh
    259     int EnableFRMRateControl;           // [IN] frame based rate control enable
    260     int Bitrate;                        // [IN] rate control parameter(bit rate)
    261     int FrameQp;                        // [IN] The quantization parameter of the frame
    262     int FrameQp_P;                      // [IN] The quantization parameter of the P frame
    263     int QSCodeMax;                      // [IN] Maximum Quantization value
    264     int QSCodeMin;                      // [IN] Minimum Quantization value
    265     int CBRPeriodRf;                    // [IN] Reaction coefficient parameter for rate control
    266     int PadControlOn;                   // [IN] Enable padding control
    267     int LumaPadVal;                     // [IN] Luma pel value used to fill padding area
    268     int CbPadVal;                       // [IN] CB pel value used to fill padding area
    269     int CrPadVal;                       // [IN] CR pel value used to fill padding area
    270     int FrameMap;                       // [IN] Encoding input mode(tile mode or linear mode)
    271 
    272     // H.263 specific parameters
    273     int FrameRate;                      // [IN] rate control parameter(frame rate)
    274 } SSBSIP_MFC_ENC_H263_PARAM;
    275 
    276 typedef struct {
    277     int width;
    278     int height;
    279     int buf_width;
    280     int buf_height;
    281 } SSBSIP_MFC_IMG_RESOLUTION;
    282 
    283 typedef struct {
    284     int crop_top_offset;
    285     int crop_bottom_offset;
    286     int crop_left_offset;
    287     int crop_right_offset;
    288 } SSBSIP_MFC_CROP_INFORMATION;
    289 
    290 #ifdef __cplusplus
    291 extern "C" {
    292 #endif
    293 
    294 /*--------------------------------------------------------------------------------*/
    295 /* Decoding APIs                                                                  */
    296 /*--------------------------------------------------------------------------------*/
    297 void *SsbSipMfcDecOpen(void *value);
    298 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecInit(void *openHandle, SSBSIP_MFC_CODEC_TYPE codec_type, int Frameleng);
    299 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecExe(void *openHandle, int lengthBufFill);
    300 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecClose(void *openHandle);
    301 
    302 void *SsbSipMfcDecGetInBuf(void *openHandle, void **phyInBuf, int inputBufferSize);
    303 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetInBuf(void *openHandle, void *phyInBuf, void *virInBuf, int inputBufferSize);
    304 
    305 SSBSIP_MFC_DEC_OUTBUF_STATUS SsbSipMfcDecGetOutBuf(void *openHandle, SSBSIP_MFC_DEC_OUTPUT_INFO *output_info);
    306 
    307 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecSetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value);
    308 SSBSIP_MFC_ERROR_CODE SsbSipMfcDecGetConfig(void *openHandle, SSBSIP_MFC_DEC_CONF conf_type, void *value);
    309 
    310 /*--------------------------------------------------------------------------------*/
    311 /* Encoding APIs                                                                  */
    312 /*--------------------------------------------------------------------------------*/
    313 void *SsbSipMfcEncOpen(void *value);
    314 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncInit(void *openHandle, void *param);
    315 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncExe(void *openHandle);
    316 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncClose(void *openHandle);
    317 
    318 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetSize(void *openHandle, SSBSIP_MFC_CODEC_TYPE codecType, int nWidth, int nHeight);
    319 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info);
    320 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetInBuf(void *openHandle, SSBSIP_MFC_ENC_INPUT_INFO *input_info);
    321 
    322 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetOutBuf(void *openHandle, SSBSIP_MFC_ENC_OUTPUT_INFO *output_info);
    323 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetOutBuf (void *openHandle, void *phyOutbuf, void *virOutbuf, int outputBufferSize);
    324 
    325 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncSetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value);
    326 SSBSIP_MFC_ERROR_CODE SsbSipMfcEncGetConfig(void *openHandle, SSBSIP_MFC_ENC_CONF conf_type, void *value);
    327 
    328 #ifdef __cplusplus
    329 }
    330 #endif
    331 
    332 #endif /* _SSBSIP_MFC_API_H_ */
    333