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