1 /*! 2 * \copy 3 * Copyright (c) 2004-2013, Cisco Systems 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 13 * * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * 32 * \file : IWelsVP.h 33 * 34 * \brief : Interface of wels video processor class 35 * 36 * \date : 2011/01/04 37 * 38 * \description : 1. should support both C/C++ style interface 39 * 2. should concern with the feature extension requirement 40 * 3. should care the usage of "char"==> 41 * 1) value char : signed char/unsigned char 42 * 2) string char : char 43 * 44 ************************************************************************************* 45 */ 46 47 #ifndef IWELSVP_H_ 48 #define IWELSVP_H_ 49 50 #define WELSVP_MAJOR_VERSION 1 51 #define WELSVP_MINOR_VERSION 1 52 #define WELSVP_VERSION ((WELSVP_MAJOR_VERSION << 8) + WELSVP_MINOR_VERSION) 53 54 typedef enum { 55 RET_SUCCESS = 0, 56 RET_FAILED = -1, 57 RET_INVALIDPARAM = -2, 58 RET_OUTOFMEMORY = -3, 59 RET_NOTSUPPORTED = -4, 60 RET_UNEXPECTED = -5, 61 RET_NEEDREINIT = -6 62 } EResult; 63 64 typedef enum { 65 VIDEO_FORMAT_NULL = 0, /* invalid format */ 66 /*rgb color formats*/ 67 VIDEO_FORMAT_RGB = 1, /* rgb 24bits */ 68 VIDEO_FORMAT_RGBA = 2, /* rgba */ 69 VIDEO_FORMAT_RGB555 = 3, /* rgb555 */ 70 VIDEO_FORMAT_RGB565 = 4, /* rgb565 */ 71 VIDEO_FORMAT_BGR = 5, /* bgr 24bits */ 72 VIDEO_FORMAT_BGRA = 6, /* bgr 32bits */ 73 VIDEO_FORMAT_ABGR = 7, /* abgr */ 74 VIDEO_FORMAT_ARGB = 8, /* argb */ 75 76 /*yuv color formats*/ 77 VIDEO_FORMAT_YUY2 = 20, /* yuy2 */ 78 VIDEO_FORMAT_YVYU = 21, /* yvyu */ 79 VIDEO_FORMAT_UYVY = 22, /* uyvy */ 80 VIDEO_FORMAT_I420 = 23, /* yuv 4:2:0 planar */ 81 VIDEO_FORMAT_YV12 = 24, /* yuv 4:2:0 planar */ 82 VIDEO_FORMAT_INTERNAL = 25, /* Only Used for SVC decoder testbed */ 83 VIDEO_FORMAT_NV12 = 26, /* y planar + uv packed */ 84 VIDEO_FORMAT_I422 = 27, /* yuv 4:2:2 planar */ 85 VIDEO_FORMAT_I444 = 28, /* yuv 4:4:4 planar */ 86 VIDEO_FORMAT_YUYV = 20, /* yuv 4:2:2 packed */ 87 88 VIDEO_FORMAT_RGB24 = 1, 89 VIDEO_FORMAT_RGB32 = 2, 90 VIDEO_FORMAT_RGB24_INV = 5, 91 VIDEO_FORMAT_RGB32_INV = 6, 92 VIDEO_FORMAT_RGB555_INV = 7, 93 VIDEO_FORMAT_RGB565_INV = 8, 94 VIDEO_FORMAT_YUV2 = 21, 95 VIDEO_FORMAT_420 = 23, 96 97 VIDEO_FORMAT_VFlip = 0x80000000 98 } EVideoFormat; 99 100 typedef enum { 101 BUFFER_HOSTMEM = 0, 102 BUFFER_SURFACE 103 } EPixMapBufferProperty; 104 105 typedef struct { 106 int iRectTop; 107 int iRectLeft; 108 int iRectWidth; 109 int iRectHeight; 110 } SRect; 111 112 typedef struct { 113 void* pPixel[3]; 114 int iSizeInBits; 115 int iStride[3]; 116 SRect sRect; 117 EVideoFormat eFormat; 118 EPixMapBufferProperty eProperty;//not use? to remove? but how about the size of SPixMap? 119 } SPixMap; 120 121 typedef enum { 122 METHOD_NULL = 0, 123 METHOD_COLORSPACE_CONVERT ,//not support yet 124 METHOD_DENOISE , 125 METHOD_SCENE_CHANGE_DETECTION_VIDEO , 126 METHOD_SCENE_CHANGE_DETECTION_SCREEN , 127 METHOD_DOWNSAMPLE , 128 METHOD_VAA_STATISTICS , 129 METHOD_BACKGROUND_DETECTION , 130 METHOD_ADAPTIVE_QUANT , 131 METHOD_COMPLEXITY_ANALYSIS , 132 METHOD_COMPLEXITY_ANALYSIS_SCREEN, 133 METHOD_IMAGE_ROTATE , 134 METHOD_SCROLL_DETECTION, 135 METHOD_MASK 136 } EMethods; 137 138 //-----------------------------------------------------------------// 139 // Algorithm parameters define 140 //-----------------------------------------------------------------// 141 142 typedef enum { 143 SIMILAR_SCENE, //similar scene 144 MEDIUM_CHANGED_SCENE, //medium changed scene 145 LARGE_CHANGED_SCENE //large changed scene 146 } ESceneChangeIdc; 147 148 typedef enum { 149 NO_STATIC, // motion block 150 COLLOCATED_STATIC, // collocated static block 151 SCROLLED_STATIC, // scrolled static block 152 BLOCK_STATIC_IDC_ALL 153 } EStaticBlockIdc; 154 155 typedef struct { 156 SRect sMaskRect; 157 bool bMaskInfoAvailable; 158 int iScrollMvX; 159 int iScrollMvY; 160 bool bScrollDetectFlag; // 0:false ; 1:ltr; 2: scene change 161 } SScrollDetectionParam; 162 163 typedef struct { 164 ESceneChangeIdc eSceneChangeIdc; // SIMILAR_SCENE, MEDIUM_CHANGED_SCENE, LARGE_CHANGED_SCENE 165 int iMotionBlockNum; // Number of motion blocks 166 long long iFrameComplexity; // frame complexity 167 unsigned char* pStaticBlockIdc; // static block idc 168 SScrollDetectionParam sScrollResult; //results from scroll detection 169 } SSceneChangeResult; 170 171 typedef struct { 172 unsigned char* pCurY; // Y data of current frame 173 unsigned char* pRefY; // Y data of pRef frame for diff calc 174 int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together 175 int* pSsd16x16; // sum of square difference of 16x16 176 int* pSum16x16; // sum of 16x16 177 int* pSumOfSquare16x16; // sum of square of 16x16 178 int (*pSumOfDiff8x8)[4]; 179 unsigned char (*pMad8x8)[4]; 180 int iFrameSad; // sad of frame 181 } SVAACalcResult; 182 183 typedef struct { 184 int iCalcVar; 185 int iCalcBgd; 186 int iCalcSsd; 187 int iReserved; 188 SVAACalcResult* pCalcResult; 189 } SVAACalcParam; 190 191 typedef struct { 192 signed char* pBackgroundMbFlag; 193 SVAACalcResult* pCalcRes; 194 } SBGDInterface; 195 196 typedef enum { 197 AQ_QUALITY_MODE, //Quality mode 198 AQ_BITRATE_MODE //Bitrate mode 199 } EAQModes; 200 201 typedef struct { 202 unsigned short uiMotionIndex; 203 unsigned short uiTextureIndex; 204 } SMotionTextureUnit; 205 206 typedef struct { 207 int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode 208 SVAACalcResult* pCalcResult; 209 SMotionTextureUnit* pMotionTextureUnit; 210 211 signed char* pMotionTextureIndexToDeltaQp; 212 int iAverMotionTextureIndexToDeltaQp; // *AQ_STEP_INT_MULTIPLY 213 } SAdaptiveQuantizationParam; 214 215 typedef enum { 216 FRAME_SAD = 0, 217 GOM_SAD = -1, 218 GOM_VAR = -2 219 } EComplexityAnalysisMode; 220 221 typedef struct { 222 int iComplexityAnalysisMode; 223 int iCalcBgd; 224 int iMbNumInGom; 225 long long iFrameComplexity; 226 int* pGomComplexity; 227 int* pGomForegroundBlockNum; 228 signed char* pBackgroundMbFlag; 229 unsigned int* uiRefMbType; 230 SVAACalcResult* pCalcResult; 231 } SComplexityAnalysisParam; 232 233 typedef struct { 234 int iMbRowInGom; 235 int* pGomComplexity; 236 int iGomNumInFrame; 237 long long iFrameComplexity; //255*255(MaxMbSAD)*36864(MaxFS) make the highest bit of 32-bit integer 1 238 int iIdrFlag; 239 SScrollDetectionParam sScrollResult; 240 } SComplexityAnalysisScreenParam; 241 ///////////////////////////////////////////////////////////////////////////////////////////// 242 243 typedef struct { 244 void* pCtx; 245 EResult (*Init) (void* pCtx, int iType, void* pCfg); 246 EResult (*Uninit) (void* pCtx, int iType); 247 EResult (*Flush) (void* pCtx, int iType); 248 EResult (*Process) (void* pCtx, int iType, SPixMap* pSrc, SPixMap* dst); 249 EResult (*Get) (void* pCtx, int iType, void* pParam); 250 EResult (*Set) (void* pCtx, int iType, void* pParam); 251 EResult (*SpecialFeature) (void* pCtx, int iType, void* pIn, void* pOut); 252 } IWelsVPc; 253 254 #if defined(__cplusplus) && !defined(CINTERFACE) /* C++ style interface */ 255 256 class IWelsVP { 257 public: ~IWelsVP()258 virtual ~IWelsVP() {} 259 260 public: 261 virtual EResult Init (int iType, void* pCfg) = 0; 262 virtual EResult Uninit (int iType) = 0; 263 virtual EResult Flush (int iType) = 0; 264 virtual EResult Process (int iType, SPixMap* pSrc, SPixMap* dst) = 0; 265 virtual EResult Get (int iType, void* pParam) = 0; 266 virtual EResult Set (int iType, void* pParam) = 0; 267 virtual EResult SpecialFeature (int iType, void* pIn, void* pOut) = 0; 268 }; 269 270 /* Recommend to invoke the interface via the micro for convenient */ 271 #define IWelsVPFunc_Init(p, a, b) (p)->Init(a, b) 272 #define IWelsVPFunc_Uninit(p, a) (p)->Uninit(a) 273 #define IWelsVPFunc_Flush(p, a) (p)->Flush(a) 274 #define IWelsVPFunc_Process(p, a, b, c) (p)->Process(a, b, c) 275 #define IWelsVPFunc_Get(p, a, b) (p)->Get(a, b) 276 #define IWelsVPFunc_Set(p, a, b) (p)->Set(a, b) 277 #define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(a, b, c) 278 279 /* C++ interface version */ 280 #define WELSVP_INTERFACE_VERION (0x8000 + (WELSVP_VERSION & 0x7fff)) 281 #define WELSVP_EXTERNC_BEGIN extern "C" { 282 #define WELSVP_EXTERNC_END } 283 284 #else /* C style interface */ 285 286 /* Recommend to invoke the interface via the micro for convenient */ 287 #define IWelsVPFunc_Init(p, a, b) (p)->Init(p->h, a, b) 288 #define IWelsVPFunc_Uninit(p, a) (p)->Uninit(p->h, a) 289 #define IWelsVPFunc_Flush(p, a) (p)->Flush(p->h, a) 290 #define IWelsVPFunc_Process(p, a, b, c) (p)->Process(p->h, a, b, c) 291 #define IWelsVPFunc_Get(p, a, b) (p)->Get(p->h, a, b) 292 #define IWelsVPFunc_Set(p, a, b) (p)->Set(p->h, a, b) 293 #define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(p->h, a, b, c) 294 295 /* C interface version */ 296 #define WELSVP_INTERFACE_VERION (0x0001 + (WELSVP_VERSION & 0x7fff)) 297 #define WELSVP_EXTERNC_BEGIN 298 #define WELSVP_EXTERNC_END 299 300 #endif 301 302 WELSVP_EXTERNC_BEGIN 303 EResult WelsCreateVpInterface (void** ppCtx, int iVersion /*= WELSVP_INTERFACE_VERION*/); 304 EResult WelsDestroyVpInterface (void* pCtx , int iVersion /*= WELSVP_INTERFACE_VERION*/); 305 WELSVP_EXTERNC_END 306 307 ////////////////////////////////////////////////////////////////////////////////////////////// 308 #endif // IWELSVP_H_ 309 310 311