Showing the changes to codec/processing/interface (1 of 124 files). Show all
Unified · Split
| @@ -0,0 +1,286 @@ | |||
| 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 | #ifdef _WIN32 | ||
| 51 | #define WELSAPI __stdcall | ||
| 52 | #else | ||
| 53 | #define WELSAPI | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #define WELSVP_MAJOR_VERSION 1 | ||
| 57 | #define WELSVP_MINOR_VERSION 1 | ||
| 58 | #define WELSVP_VERSION ((WELSVP_MAJOR_VERSION << 8) + WELSVP_MINOR_VERSION) | ||
| 59 | |||
| 60 | typedef enum { | ||
| 61 | RET_SUCCESS = 0, | ||
| 62 | RET_FAILED = -1, | ||
| 63 | RET_INVALIDPARAM = -2, | ||
| 64 | RET_OUTOFMEMORY = -3, | ||
| 65 | RET_NOTSUPPORTED = -4, | ||
| 66 | RET_UNEXPECTED = -5, | ||
| 67 | RET_NEEDREINIT = -6 | ||
| 68 | } EResult; | ||
| 69 | |||
| 70 | typedef enum { | ||
| 71 | VIDEO_FORMAT_NULL = 0, /* invalid format */ | ||
| 72 | /*rgb color formats*/ | ||
| 73 | VIDEO_FORMAT_RGB = 1, /* rgb 24bits */ | ||
| 74 | VIDEO_FORMAT_RGBA = 2, /* rgba */ | ||
| 75 | VIDEO_FORMAT_RGB555 = 3, /* rgb555 */ | ||
| 76 | VIDEO_FORMAT_RGB565 = 4, /* rgb565 */ | ||
| 77 | VIDEO_FORMAT_BGR = 5, /* bgr 24bits */ | ||
| 78 | VIDEO_FORMAT_BGRA = 6, /* bgr 32bits */ | ||
| 79 | VIDEO_FORMAT_ABGR = 7, /* abgr */ | ||
| 80 | VIDEO_FORMAT_ARGB = 8, /* argb */ | ||
| 81 | |||
| 82 | /*yuv color formats*/ | ||
| 83 | VIDEO_FORMAT_YUY2 = 20, /* yuy2 */ | ||
| 84 | VIDEO_FORMAT_YVYU = 21, /* yvyu */ | ||
| 85 | VIDEO_FORMAT_UYVY = 22, /* uyvy */ | ||
| 86 | VIDEO_FORMAT_I420 = 23, /* yuv 4:2:0 planar */ | ||
| 87 | VIDEO_FORMAT_YV12 = 24, /* yuv 4:2:0 planar */ | ||
| 88 | VIDEO_FORMAT_INTERNAL = 25, /* Only Used for SVC decoder testbed */ | ||
| 89 | VIDEO_FORMAT_NV12 = 26, /* y planar + uv packed */ | ||
| 90 | VIDEO_FORMAT_I422 = 27, /* yuv 4:2:2 planar */ | ||
| 91 | VIDEO_FORMAT_I444 = 28, /* yuv 4:4:4 planar */ | ||
| 92 | VIDEO_FORMAT_YUYV = 20, /* yuv 4:2:2 packed */ | ||
| 93 | |||
| 94 | VIDEO_FORMAT_RGB24 = 1, | ||
| 95 | VIDEO_FORMAT_RGB32 = 2, | ||
| 96 | VIDEO_FORMAT_RGB24_INV = 5, | ||
| 97 | VIDEO_FORMAT_RGB32_INV = 6, | ||
| 98 | VIDEO_FORMAT_RGB555_INV = 7, | ||
| 99 | VIDEO_FORMAT_RGB565_INV = 8, | ||
| 100 | VIDEO_FORMAT_YUV2 = 21, | ||
| 101 | VIDEO_FORMAT_420 = 23, | ||
| 102 | |||
| 103 | VIDEO_FORMAT_VFlip = 0x80000000 | ||
| 104 | } EVideoFormat; | ||
| 105 | |||
| 106 | typedef enum { | ||
| 107 | BUFFER_HOSTMEM = 0, | ||
| 108 | BUFFER_SURFACE | ||
| 109 | } EPixMapBufferProperty; | ||
| 110 | |||
| 111 | typedef struct { | ||
| 112 | int iRectTop; | ||
| 113 | int iRectLeft; | ||
| 114 | int iRectWidth; | ||
| 115 | int iRectHeight; | ||
| 116 | } SRect; | ||
| 117 | |||
| 118 | typedef struct { | ||
| 119 | void* pPixel[3]; | ||
| 120 | int iSizeInBits; | ||
| 121 | int iStride[3]; | ||
| 122 | SRect sRect; | ||
| 123 | EVideoFormat eFormat; | ||
| 124 | EPixMapBufferProperty eProperty;//not use? to remove? but how about the size of SPixMap? | ||
| 125 | } SPixMap; | ||
| 126 | |||
| 127 | typedef enum { | ||
| 128 | METHOD_NULL = 0, | ||
| 129 | METHOD_COLORSPACE_CONVERT ,//not support yet | ||
| 130 | METHOD_DENOISE , | ||
| 131 | METHOD_SCENE_CHANGE_DETECTION , | ||
| 132 | METHOD_DOWNSAMPLE , | ||
| 133 | METHOD_VAA_STATISTICS , | ||
| 134 | METHOD_BACKGROUND_DETECTION , | ||
| 135 | METHOD_ADAPTIVE_QUANT , | ||
| 136 | METHOD_COMPLEXITY_ANALYSIS , | ||
| 137 | METHOD_IMAGE_ROTATE , | ||
| 138 | METHOD_MASK | ||
| 139 | } EMethods; | ||
| 140 | |||
| 141 | //-----------------------------------------------------------------// | ||
| 142 | // Algorithm parameters define | ||
| 143 | //-----------------------------------------------------------------// | ||
| 144 | |||
| 145 | typedef struct { | ||
| 146 | int bSceneChangeFlag; // 0:false ; 1:true | ||
| 147 | } SSceneChangeResult; | ||
| 148 | |||
| 149 | typedef enum { | ||
| 150 | SIMILAR_SCENE, //similar scene | ||
| 151 | MEDIUM_CHANGED_SCENE, //medium changed scene | ||
| 152 | LARGE_CHANGED_SCENE, //large changed scene | ||
| 153 | } ESceneChangeIdc; | ||
| 154 | |||
| 155 | typedef struct { | ||
| 156 | unsigned char* pCurY; // Y data of current frame | ||
| 157 | unsigned char* pRefY; // Y data of pRef frame for diff calc | ||
| 158 | int (*pSad8x8)[4]; // sad of 8x8, every 4 in the same 16x16 get together | ||
| 159 | int* pSsd16x16; // sum of square difference of 16x16 | ||
| 160 | int* pSum16x16; // sum of 16x16 | ||
| 161 | int* pSumOfSquare16x16; // sum of square of 16x16 | ||
| 162 | int (*pSumOfDiff8x8)[4]; | ||
| 163 | unsigned char (*pMad8x8)[4]; | ||
| 164 | int iFrameSad; // sad of frame | ||
| 165 | } SVAACalcResult; | ||
| 166 | |||
| 167 | typedef struct { | ||
| 168 | int iCalcVar; | ||
| 169 | int iCalcBgd; | ||
| 170 | int iCalcSsd; | ||
| 171 | int iReserved; | ||
| 172 | SVAACalcResult* pCalcResult; | ||
| 173 | } SVAACalcParam; | ||
| 174 | |||
| 175 | typedef struct { | ||
| 176 | signed char* pBackgroundMbFlag; | ||
| 177 | SVAACalcResult* pCalcRes; | ||
| 178 | } SBGDInterface; | ||
| 179 | |||
| 180 | typedef enum { | ||
| 181 | AQ_QUALITY_MODE, //Quality mode | ||
| 182 | AQ_BITRATE_MODE, //Bitrate mode | ||
| 183 | } EAQModes; | ||
| 184 | |||
| 185 | typedef struct { | ||
| 186 | unsigned short uiMotionIndex; | ||
| 187 | unsigned short uiTextureIndex; | ||
| 188 | } SMotionTextureUnit; | ||
| 189 | |||
| 190 | typedef struct { | ||
| 191 | int iAdaptiveQuantMode; // 0:quality mode, 1:bitrates mode | ||
| 192 | SVAACalcResult* pCalcResult; | ||
| 193 | SMotionTextureUnit* pMotionTextureUnit; | ||
| 194 | |||
| 195 | signed char* pMotionTextureIndexToDeltaQp; | ||
| 196 | double dAverMotionTextureIndexToDeltaQp; | ||
| 197 | } SAdaptiveQuantizationParam; | ||
| 198 | |||
| 199 | typedef enum { | ||
| 200 | FRAME_SAD = 0, | ||
| 201 | GOM_SAD = -1, | ||
| 202 | GOM_VAR = -2 | ||
| 203 | } EComplexityAnalysisMode; | ||
| 204 | |||
| 205 | typedef struct { | ||
| 206 | int iComplexityAnalysisMode; | ||
| 207 | int iCalcBgd; | ||
| 208 | int iMbNumInGom; | ||
| 209 | int iFrameComplexity; | ||
| 210 | int* pGomComplexity; | ||
| 211 | int* pGomForegroundBlockNum; | ||
| 212 | signed char* pBackgroundMbFlag; | ||
| 213 | unsigned int* uiRefMbType; | ||
| 214 | SVAACalcResult* pCalcResult; | ||
| 215 | } SComplexityAnalysisParam; | ||
| 216 | |||
| 217 | ///////////////////////////////////////////////////////////////////////////////////////////// | ||
| 218 | |||
| 219 | typedef struct { | ||
| 220 | void* pCtx; | ||
| 221 | EResult (*Init) (void* pCtx, int iType, void* pCfg); | ||
| 222 | EResult (*Uninit) (void* pCtx, int iType); | ||
| 223 | EResult (*Flush) (void* pCtx, int iType); | ||
| 224 | EResult (*Process) (void* pCtx, int iType, SPixMap* pSrc, SPixMap* dst); | ||
| 225 | EResult (*Get) (void* pCtx, int iType, void* pParam); | ||
| 226 | EResult (*Set) (void* pCtx, int iType, void* pParam); | ||
| 227 | EResult (*SpecialFeature) (void* pCtx, int iType, void* pIn, void* pOut); | ||
| 228 | } IWelsVPc; | ||
| 229 | |||
| 230 | #if defined(__cplusplus) && !defined(CINTERFACE) /* C++ style interface */ | ||
| 231 | |||
| 232 | class IWelsVP { | ||
| 233 | public: | ||
| 234 | virtual ~IWelsVP() {} | ||
| 235 | |||
| 236 | public: | ||
| 237 | virtual EResult Init (int iType, void* pCfg) = 0; | ||
| 238 | virtual EResult Uninit (int iType) = 0; | ||
| 239 | virtual EResult Flush (int iType) = 0; | ||
| 240 | virtual EResult Process (int iType, SPixMap* pSrc, SPixMap* dst) = 0; | ||
| 241 | virtual EResult Get (int iType, void* pParam) = 0; | ||
| 242 | virtual EResult Set (int iType, void* pParam) = 0; | ||
| 243 | virtual EResult SpecialFeature (int iType, void* pIn, void* pOut) = 0; | ||
| 244 | }; | ||
| 245 | |||
| 246 | /* Recommend to invoke the interface via the micro for convenient */ | ||
| 247 | #define IWelsVPFunc_Init(p, a, b) (p)->Init(a, b) | ||
| 248 | #define IWelsVPFunc_Uninit(p, a) (p)->Uninit(a) | ||
| 249 | #define IWelsVPFunc_Flush(p, a) (p)->Flush(a) | ||
| 250 | #define IWelsVPFunc_Process(p, a, b, c) (p)->Process(a, b, c) | ||
| 251 | #define IWelsVPFunc_Get(p, a, b) (p)->Get(a, b) | ||
| 252 | #define IWelsVPFunc_Set(p, a, b) (p)->Set(a, b) | ||
| 253 | #define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(a, b, c) | ||
| 254 | |||
| 255 | /* C++ interface version */ | ||
| 256 | #define WELSVP_INTERFACE_VERION (0x8000 + (WELSVP_VERSION & 0x7fff)) | ||
| 257 | #define WELSVP_EXTERNC_BEGIN extern "C" { | ||
| 258 | #define WELSVP_EXTERNC_END } | ||
| 259 | |||
| 260 | #else /* C style interface */ | ||
| 261 | |||
| 262 | /* Recommend to invoke the interface via the micro for convenient */ | ||
| 263 | #define IWelsVPFunc_Init(p, a, b) (p)->Init(p->h, a, b) | ||
| 264 | #define IWelsVPFunc_Uninit(p, a) (p)->Uninit(p->h, a) | ||
| 265 | #define IWelsVPFunc_Flush(p, a) (p)->Flush(p->h, a) | ||
| 266 | #define IWelsVPFunc_Process(p, a, b, c) (p)->Process(p->h, a, b, c) | ||
| 267 | #define IWelsVPFunc_Get(p, a, b) (p)->Get(p->h, a, b) | ||
| 268 | #define IWelsVPFunc_Set(p, a, b) (p)->Set(p->h, a, b) | ||
| 269 | #define IWelsVPFunc_SpecialFeature(p, a, b, c) (p)->SpecialFeature(p->h, a, b, c) | ||
| 270 | |||
| 271 | /* C interface version */ | ||
| 272 | #define WELSVP_INTERFACE_VERION (0x0001 + (WELSVP_VERSION & 0x7fff)) | ||
| 273 | #define WELSVP_EXTERNC_BEGIN | ||
| 274 | #define WELSVP_EXTERNC_END | ||
| 275 | |||
| 276 | #endif | ||
| 277 | |||
| 278 | WELSVP_EXTERNC_BEGIN | ||
| 279 | EResult WELSAPI CreateVpInterface (void** ppCtx, int iVersion /*= WELSVP_INTERFACE_VERION*/); | ||
| 280 | EResult WELSAPI DestroyVpInterface (void* pCtx , int iVersion /*= WELSVP_INTERFACE_VERION*/); | ||
| 281 | WELSVP_EXTERNC_END | ||
| 282 | |||
| 283 | ////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 284 | #endif // IWELSVP_H_ | ||
| 285 | |||
| 286 | |||