History

resolve conflict

volvet committed 12 years ago

Commit ec84f4b1 parent 3958118124 files · +15352 −15696Browse files

Showing the changes to codec/processing/src/common (16 of 124 files). Show all

Unified · Split

16 files
  1. codec/processing/src/common/WelsFrameWork.cpp +301 −0
  2. codec/processing/src/common/WelsFrameWork.h +130 −0
  3. codec/processing/src/common/WelsFrameWorkEx.cpp +96 −0
  4. codec/processing/src/common/WelsVP.aps +0 −0
  5. codec/processing/src/common/WelsVP.def +36 −0
  6. codec/processing/src/common/WelsVP.rc +115 −0
  7. codec/processing/src/common/cpu.cpp +196 −0
  8. codec/processing/src/common/cpu.h +102 −0
  9. codec/processing/src/common/memory.cpp +117 −0
  10. codec/processing/src/common/memory.h +110 −0
  11. codec/processing/src/common/resource.h +15 −0
  12. codec/processing/src/common/thread.cpp +93 −0
  13. codec/processing/src/common/thread.h +89 −0
  14. codec/processing/src/common/typedef.h +102 −0
  15. codec/processing/src/common/util.cpp +45 −0
  16. codec/processing/src/common/util.h +107 −0
codec/processing/src/common/WelsFrameWork.cpp+301−0
@@ -0,0 +1,301 @@
1/*!
2 * \copy
3 * Copyright (c) 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
33#include "WelsFrameWork.h"
34#include "cpu.h"
35#include "../denoise/denoise.h"
36#include "../downsample/downsample.h"
37#include "../scenechangedetection/SceneChangeDetection.h"
38#include "../vaacalc/vaacalculation.h"
39#include "../backgounddetection/BackgroundDetection.h"
40#include "../adaptivequantization/AdaptiveQuantization.h"
41#include "../complexityanalysis/ComplexityAnalysis.h"
42#include "../imagerotate/imagerotate.h"
43
44
45/* interface API implement */
46
47EResult WELSAPI CreateVpInterface (void** ppCtx, int iVersion) {
48 if (iVersion & 0x8000)
49 return nsWelsVP::CreateSpecificVpInterface ((IWelsVP**)ppCtx);
50 else if (iVersion & 0x7fff)
51 return nsWelsVP::CreateSpecificVpInterface ((IWelsVPc**)ppCtx);
52 else
53 return RET_INVALIDPARAM;
54}
55
56EResult WELSAPI DestroyVpInterface (void* pCtx, int iVersion) {
57 if (iVersion & 0x8000)
58 return nsWelsVP::DestroySpecificVpInterface ((IWelsVP*)pCtx);
59 else if (iVersion & 0x7fff)
60 return nsWelsVP::DestroySpecificVpInterface ((IWelsVPc*)pCtx);
61 else
62 return RET_INVALIDPARAM;
63}
64
65WELSVP_NAMESPACE_BEGIN
66
67///////////////////////////////////////////////////////////////////////
68
69EResult CreateSpecificVpInterface (IWelsVP** ppCtx) {
70 EResult eReturn = RET_FAILED;
71
72 CVpFrameWork* pFr = new CVpFrameWork (1, eReturn);
73 if (pFr) {
74 *ppCtx = (IWelsVP*)pFr;
75 eReturn = RET_SUCCESS;
76 }
77
78 return eReturn;
79}
80
81EResult DestroySpecificVpInterface (IWelsVP* pCtx) {
82 _SafeDelete (pCtx);
83
84 return RET_SUCCESS;
85}
86
87///////////////////////////////////////////////////////////////////////////////
88
89CVpFrameWork::CVpFrameWork (uint32_t uiThreadsNum, EResult& eReturn) {
90 int32_t iCoreNum = 1;
91#ifndef X86_ASM
92 uint32_t uiCPUFlag = 0;
93#else
94 uint32_t uiCPUFlag = WelsCPUFeatureDetect (&iCoreNum);
95#endif
96
97 for (int32_t i = 0; i < MAX_STRATEGY_NUM; i++) {
98 IStrategy* pStrategy = m_pStgChain[i];
99 pStrategy = CreateStrategy (WelsStaticCast (EMethods, i + 1), uiCPUFlag);
100 m_pStgChain[i] = pStrategy;
101 }
102
103 WelsMutexInit (&m_mutes);
104
105 eReturn = RET_SUCCESS;
106}
107
108CVpFrameWork::~CVpFrameWork() {
109 for (int32_t i = 0; i < MAX_STRATEGY_NUM; i++) {
110 if (m_pStgChain[i]) {
111 Uninit (m_pStgChain[i]->m_eMethod);
112 _SafeDelete (m_pStgChain[i]);
113 }
114 }
115
116 WelsMutexDestroy (&m_mutes);
117}
118
119EResult CVpFrameWork::Init (int32_t iType, void* pCfg) {
120 EResult eReturn = RET_SUCCESS;
121 int32_t iCurIdx = WelsStaticCast (int32_t, WelsVpGetValidMethod (iType)) - 1;
122
123 Uninit (iType);
124
125 WelsMutexLock (&m_mutes);
126
127 IStrategy* pStrategy = m_pStgChain[iCurIdx];
128 if (pStrategy)
129 eReturn = pStrategy->Init (0, pCfg);
130
131 WelsMutexUnlock (&m_mutes);
132
133 return eReturn;
134}
135
136EResult CVpFrameWork::Uninit (int32_t iType) {
137 EResult eReturn = RET_SUCCESS;
138 int32_t iCurIdx = WelsStaticCast (int32_t, WelsVpGetValidMethod (iType)) - 1;
139
140 WelsMutexLock (&m_mutes);
141
142 IStrategy* pStrategy = m_pStgChain[iCurIdx];
143 if (pStrategy)
144 eReturn = pStrategy->Uninit (0);
145
146 WelsMutexUnlock (&m_mutes);
147
148 return eReturn;
149}
150
151EResult CVpFrameWork::Flush (int32_t iType) {
152 EResult eReturn = RET_SUCCESS;
153
154 return eReturn;
155}
156
157EResult CVpFrameWork::Process (int32_t iType, SPixMap* pSrcPixMap, SPixMap* pDstPixMap) {
158 EResult eReturn = RET_NOTSUPPORTED;
159 EMethods eMethod = WelsVpGetValidMethod (iType);
160 int32_t iCurIdx = WelsStaticCast (int32_t, eMethod) - 1;
161 SPixMap sSrcPic;
162 SPixMap sDstPic;
163 memset (&sSrcPic, 0, sizeof (sSrcPic)); // confirmed_safe_unsafe_usage
164 memset (&sDstPic, 0, sizeof (sDstPic)); // confirmed_safe_unsafe_usage
165
166 if (pSrcPixMap) sSrcPic = *pSrcPixMap;
167 if (pDstPixMap) sDstPic = *pDstPixMap;
168 if (!CheckValid (eMethod, sSrcPic, sDstPic))
169 return RET_INVALIDPARAM;
170
171 WelsMutexLock (&m_mutes);
172
173 IStrategy* pStrategy = m_pStgChain[iCurIdx];
174 if (pStrategy)
175 eReturn = pStrategy->Process (0, &sSrcPic, &sDstPic);
176
177 WelsMutexUnlock (&m_mutes);
178
179 return eReturn;
180}
181
182EResult CVpFrameWork::Get (int32_t iType, void* pParam) {
183 EResult eReturn = RET_SUCCESS;
184 int32_t iCurIdx = WelsStaticCast (int32_t, WelsVpGetValidMethod (iType)) - 1;
185
186 if (!pParam)
187 return RET_INVALIDPARAM;
188
189 WelsMutexLock (&m_mutes);
190
191 IStrategy* pStrategy = m_pStgChain[iCurIdx];
192 if (pStrategy)
193 eReturn = pStrategy->Get (0, pParam);
194
195 WelsMutexUnlock (&m_mutes);
196
197 return eReturn;
198}
199
200EResult CVpFrameWork::Set (int32_t iType, void* pParam) {
201 EResult eReturn = RET_SUCCESS;
202 int32_t iCurIdx = WelsStaticCast (int32_t, WelsVpGetValidMethod (iType)) - 1;
203
204 if (!pParam)
205 return RET_INVALIDPARAM;
206
207 WelsMutexLock (&m_mutes);
208
209 IStrategy* pStrategy = m_pStgChain[iCurIdx];
210 if (pStrategy)
211 eReturn = pStrategy->Set (0, pParam);
212
213 WelsMutexUnlock (&m_mutes);
214
215 return eReturn;
216}
217
218EResult CVpFrameWork::SpecialFeature (int32_t iType, void* pIn, void* pOut) {
219 EResult eReturn = RET_SUCCESS;
220
221 return eReturn;
222}
223
224bool_t CVpFrameWork::CheckValid (EMethods eMethod, SPixMap& pSrcPixMap, SPixMap& pDstPixMap) {
225 bool_t eReturn = FALSE;
226
227 if (eMethod == METHOD_NULL)
228 goto exit;
229
230 if (eMethod != METHOD_COLORSPACE_CONVERT) {
231 if (pSrcPixMap.pPixel[0]) {
232 if (pSrcPixMap.eFormat != VIDEO_FORMAT_I420 && pSrcPixMap.eFormat != VIDEO_FORMAT_YV12)
233 goto exit;
234 }
235 if (pSrcPixMap.pPixel[0] && pDstPixMap.pPixel[0]) {
236 if (pDstPixMap.eFormat != pSrcPixMap.eFormat)
237 goto exit;
238 }
239 }
240
241 if (pSrcPixMap.pPixel[0]) {
242 if (pSrcPixMap.sRect.iRectWidth <= 0 || pSrcPixMap.sRect.iRectWidth > MAX_WIDTH || pSrcPixMap.sRect.iRectHeight <= 0
243 || pSrcPixMap.sRect.iRectHeight > MAX_HEIGHT)
244 goto exit;
245 if (pSrcPixMap.sRect.iRectTop >= pSrcPixMap.sRect.iRectHeight
246 || pSrcPixMap.sRect.iRectLeft >= pSrcPixMap.sRect.iRectWidth || pSrcPixMap.sRect.iRectWidth > pSrcPixMap.iStride[0])
247 goto exit;
248 }
249 if (pDstPixMap.pPixel[0]) {
250 if (pDstPixMap.sRect.iRectWidth <= 0 || pDstPixMap.sRect.iRectWidth > MAX_WIDTH || pDstPixMap.sRect.iRectHeight <= 0
251 || pDstPixMap.sRect.iRectHeight > MAX_HEIGHT)
252 goto exit;
253 if (pDstPixMap.sRect.iRectTop >= pDstPixMap.sRect.iRectHeight
254 || pDstPixMap.sRect.iRectLeft >= pDstPixMap.sRect.iRectWidth || pDstPixMap.sRect.iRectWidth > pDstPixMap.iStride[0])
255 goto exit;
256 }
257 eReturn = TRUE;
258
259exit:
260 return eReturn;
261}
262
263IStrategy* CVpFrameWork::CreateStrategy (EMethods m_eMethod, int32_t iCpuFlag) {
264 IStrategy* pStrategy = NULL;
265
266 switch (m_eMethod) {
267 case METHOD_COLORSPACE_CONVERT:
268 //not support yet
269 break;
270 case METHOD_DENOISE:
271 pStrategy = WelsDynamicCast (IStrategy*, new CDenoiser (iCpuFlag));
272 break;
273 case METHOD_SCENE_CHANGE_DETECTION:
274 pStrategy = WelsDynamicCast (IStrategy*, new CSceneChangeDetection (iCpuFlag));
275 break;
276 case METHOD_DOWNSAMPLE:
277 pStrategy = WelsDynamicCast (IStrategy*, new CDownsampling (iCpuFlag));
278 break;
279 case METHOD_VAA_STATISTICS:
280 pStrategy = WelsDynamicCast (IStrategy*, new CVAACalculation (iCpuFlag));
281 break;
282 case METHOD_BACKGROUND_DETECTION:
283 pStrategy = WelsDynamicCast (IStrategy*, new CBackgroundDetection (iCpuFlag));
284 break;
285 case METHOD_ADAPTIVE_QUANT:
286 pStrategy = WelsDynamicCast (IStrategy*, new CAdaptiveQuantization (iCpuFlag));
287 break;
288 case METHOD_COMPLEXITY_ANALYSIS:
289 pStrategy = WelsDynamicCast (IStrategy*, new CComplexityAnalysis (iCpuFlag));
290 break;
291 case METHOD_IMAGE_ROTATE:
292 pStrategy = WelsDynamicCast (IStrategy*, new CImageRotating (iCpuFlag));
293 break;
294 default:
295 break;
296 }
297
298 return pStrategy;
299}
300
301WELSVP_NAMESPACE_END
codec/processing/src/common/WelsFrameWork.h+130−0
@@ -0,0 +1,130 @@
1/*!
2 * \copy
3 * Copyright (c) 2011-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 * \file : WelsFrameWork.h
32 *
33 * \brief : framework of wels video processor class
34 *
35 * \date : 2011/01/04
36 *
37 * \description :
38 *
39 *************************************************************************************
40 */
41
42#ifndef WELSVP_WELSFRAMEWORK_H
43#define WELSVP_WELSFRAMEWORK_H
44
45#include "../../interface/IWelsVP.h"
46#include "util.h"
47#include "thread.h"
48
49WELSVP_NAMESPACE_BEGIN
50
51EResult CreateSpecificVpInterface (IWelsVP** ppCtx);
52EResult DestroySpecificVpInterface (IWelsVP* pCtx);
53
54EResult CreateSpecificVpInterface (IWelsVPc** ppCtx);
55EResult DestroySpecificVpInterface (IWelsVPc* pCtx);
56
57#define MAX_STRATEGY_NUM (METHOD_MASK - 1)
58
59class IStrategy : public IWelsVP {
60 public:
61 IStrategy() {
62 m_eMethod = METHOD_NULL;
63 m_eFormat = VIDEO_FORMAT_I420;
64 m_iIndex = 0;
65 m_bInit = FALSE;
66 };
67
68 virtual ~IStrategy() {}
69
70 public:
71 virtual EResult Init (int32_t iType, void* pCfg) {
72 return RET_SUCCESS;
73 }
74 virtual EResult Uninit (int32_t iType) {
75 return RET_SUCCESS;
76 }
77 virtual EResult Flush (int32_t iType) {
78 return RET_SUCCESS;
79 }
80 virtual EResult Get (int32_t iType, void* pParam) {
81 return RET_SUCCESS;
82 }
83 virtual EResult Set (int32_t iType, void* pParam) {
84 return RET_SUCCESS;
85 }
86 virtual EResult SpecialFeature (int32_t iType, void* pIn, void* pOut) {
87 return RET_SUCCESS;
88 }
89 virtual EResult Process (int32_t iType, SPixMap* pSrc, SPixMap* pDst) = 0;
90
91 public:
92 EMethods m_eMethod;
93 EVideoFormat m_eFormat;
94 int32_t m_iIndex;
95 bool_t m_bInit;
96};
97
98class CVpFrameWork : public IWelsVP {
99 public:
100 CVpFrameWork (uint32_t uiThreadsNum, EResult& ret);
101 ~CVpFrameWork();
102
103 public:
104 EResult Init (int32_t iType, void* pCfg);
105
106 EResult Uninit (int32_t iType);
107
108 EResult Flush (int32_t iType);
109
110 EResult Process (int32_t iType, SPixMap* pSrc, SPixMap* pDst);
111
112 EResult Get (int32_t iType, void* pParam);
113
114 EResult Set (int32_t iType, void* pParam);
115
116 EResult SpecialFeature (int32_t iType, void* pIn, void* pOut);
117
118 private:
119 bool_t CheckValid (EMethods eMethod, SPixMap& sSrc, SPixMap& sDst);
120 IStrategy* CreateStrategy (EMethods eMethod, int32_t iCpuFlag);
121
122 private:
123 IStrategy* m_pStgChain[MAX_STRATEGY_NUM];
124
125 WELS_MUTEX m_mutes;
126};
127
128WELSVP_NAMESPACE_END
129
130#endif
codec/processing/src/common/WelsFrameWorkEx.cpp+96−0
@@ -0,0 +1,96 @@
1/*!
2 * \copy
3 * Copyright (c) 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
33#include "WelsFrameWork.h"
34
35///////////////////////////////////////////////////////////////////////
36
37WELSVP_NAMESPACE_BEGIN
38
39EResult Init (void* pCtx, int32_t iType, void* pCfg) {
40 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Init (iType, pCfg) : RET_INVALIDPARAM;
41}
42EResult Uninit (void* pCtx, int32_t iType) {
43 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Uninit (iType) : RET_INVALIDPARAM;
44}
45EResult Flush (void* pCtx, int32_t iType) {
46 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Flush (iType) : RET_INVALIDPARAM;
47}
48EResult Process (void* pCtx, int32_t iType, SPixMap* pSrc, SPixMap* dst) {
49 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Process (iType, pSrc, dst) : RET_INVALIDPARAM;
50}
51EResult Get (void* pCtx, int32_t iType, void* pParam) {
52 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Get (iType, pParam) : RET_INVALIDPARAM;
53}
54EResult Set (void* pCtx, int32_t iType, void* pParam) {
55 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->Set (iType, pParam) : RET_INVALIDPARAM;
56}
57EResult SpecialFeature (void* pCtx, int32_t iType, void* pIn, void* pOut) {
58 return pCtx ? WelsStaticCast (IWelsVP*, pCtx)->SpecialFeature (iType, pIn, pOut) : RET_INVALIDPARAM;
59}
60
61///////////////////////////////////////////////////////////////////////////////
62
63EResult CreateSpecificVpInterface (IWelsVPc** pCtx) {
64 EResult ret = RET_FAILED;
65 IWelsVP* pWelsVP = NULL;
66
67 ret = CreateSpecificVpInterface (&pWelsVP);
68 if (ret == RET_SUCCESS) {
69 IWelsVPc* pVPc = new IWelsVPc;
70 if (pVPc) {
71 pVPc->Init = Init;
72 pVPc->Uninit = Uninit;
73 pVPc->Flush = Flush;
74 pVPc->Process = Process;
75 pVPc->Get = Get;
76 pVPc->Set = Set;
77 pVPc->SpecialFeature = SpecialFeature;
78 pVPc->pCtx = WelsStaticCast (void*, pWelsVP);
79 *pCtx = pVPc;
80 } else
81 ret = RET_OUTOFMEMORY;
82 }
83
84 return ret;
85}
86
87EResult DestroySpecificVpInterface (IWelsVPc* pCtx) {
88 if (pCtx) {
89 DestroySpecificVpInterface (WelsStaticCast (IWelsVP*, pCtx->pCtx));
90 _SafeDelete (pCtx);
91 }
92
93 return RET_SUCCESS;
94}
95
96WELSVP_NAMESPACE_END
codec/processing/src/common/WelsVP.aps+0−0

Binary file not shown.

codec/processing/src/common/WelsVP.def+36−0
@@ -0,0 +1,36 @@
1;*!
2;* \copy
3;* Copyright (c) 2011-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
33LIBRARY welsvp.dll
34EXPORTS
35 CreateVpInterface PRIVATE
36 DestroyVpInterface PRIVATE
codec/processing/src/common/WelsVP.rc+115−0
@@ -0,0 +1,115 @@
1// Microsoft Visual C++ generated resource script.
2//
3#include "resource.h"
4
5#define APSTUDIO_READONLY_SYMBOLS
6/////////////////////////////////////////////////////////////////////////////
7//
8// Generated from the TEXTINCLUDE 2 resource.
9//
10#include "windows.h"
11
12/////////////////////////////////////////////////////////////////////////////
13#undef APSTUDIO_READONLY_SYMBOLS
14
15/////////////////////////////////////////////////////////////////////////////
16// Chinese (P.R.C.) resources
17
18#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
19#ifdef _WIN32
20LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
21#pragma code_page(936)
22#endif //_WIN32
23
24#ifdef APSTUDIO_INVOKED
25/////////////////////////////////////////////////////////////////////////////
26//
27// TEXTINCLUDE
28//
29
301 TEXTINCLUDE
31BEGIN
32 "resource.h\0"
33END
34
352 TEXTINCLUDE
36BEGIN
37 "#include ""windows.h""\r\n"
38 "\0"
39END
40
413 TEXTINCLUDE
42BEGIN
43 "\r\n"
44 "\0"
45END
46
47#endif // APSTUDIO_INVOKED
48
49#endif // Chinese (P.R.C.) resources
50/////////////////////////////////////////////////////////////////////////////
51
52
53/////////////////////////////////////////////////////////////////////////////
54// English (U.S.) resources
55
56#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
57#ifdef _WIN32
58LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
59#pragma code_page(1252)
60#endif //_WIN32
61
62/////////////////////////////////////////////////////////////////////////////
63//
64// Version
65//
66
67VS_VERSION_INFO VERSIONINFO
68 FILEVERSION 0,0,0,0
69 PRODUCTVERSION 0,0,0,0
70 FILEFLAGSMASK 0x3fL
71#ifdef _DEBUG
72 FILEFLAGS 0x1L
73#else
74 FILEFLAGS 0x0L
75#endif
76 FILEOS 0x40004L
77 FILETYPE 0x2L
78 FILESUBTYPE 0x0L
79BEGIN
80 BLOCK "StringFileInfo"
81 BEGIN
82 BLOCK "040904b0"
83 BEGIN
84 VALUE "Comments", "Cisco OpenH264 video preprocessing"
85 VALUE "CompanyName", "Cisco Systems"
86 VALUE "FileDescription", "Cisco OpenH264 video preprocessing"
87 VALUE "FileVersion", "0, 0, 0, 0"
88 VALUE "InternalName", "welsvp.dll"
89 VALUE "LegalCopyright", "� 2011-2015 Cisco and/or its affiliates. All rights reserved."
90 VALUE "OriginalFilename", "welsvp.dll"
91 VALUE "ProductName", "Cisco OpenH264 video preprocessing"
92 VALUE "ProductVersion", "0, 0, 0, 0"
93 END
94 END
95 BLOCK "VarFileInfo"
96 BEGIN
97 VALUE "Translation", 0x409, 1200
98 END
99END
100
101#endif // English (U.S.) resources
102/////////////////////////////////////////////////////////////////////////////
103
104
105
106#ifndef APSTUDIO_INVOKED
107/////////////////////////////////////////////////////////////////////////////
108//
109// Generated from the TEXTINCLUDE 3 resource.
110//
111
112
113/////////////////////////////////////////////////////////////////////////////
114#endif // not APSTUDIO_INVOKED
115
codec/processing/src/common/cpu.cpp+196−0
@@ -0,0 +1,196 @@
1/*!
2 * \copy
3 * Copyright (c) 2009-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 * \file cpu.c
32 *
33 * \brief CPU compatibility detection
34 *
35 * \date 04/29/2009 Created
36 *
37 *************************************************************************************
38 */
39
40#include "util.h"
41#include "cpu.h"
42
43WELSVP_NAMESPACE_BEGIN
44
45#define CPU_Vender_AMD "AuthenticAMD"
46#define CPU_Vender_INTEL "GenuineIntel"
47#define CPU_Vender_CYRIX "CyrixInstead"
48
49
50#if defined(X86_ASM)
51
52uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors) {
53 uint32_t uiCPU = 0;
54 uint32_t uiFeatureA = 0, uiFeatureB = 0, uiFeatureC = 0, uiFeatureD = 0;
55 int32_t CacheLineSize = 0;
56 int8_t chVenderName[16] = { 0 };
57
58 if (!WelsCPUIdVerify()) {
59 /* cpuid is not supported in cpu */
60 return 0;
61 }
62
63 WelsCPUId (0, &uiFeatureA, (uint32_t*)&chVenderName[0], (uint32_t*)&chVenderName[8], (uint32_t*)&chVenderName[4]);
64 if (uiFeatureA == 0) {
65 /* maximum input value for basic cpuid information */
66 return 0;
67 }
68
69 WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
70 if ((uiFeatureD & 0x00800000) == 0) {
71 /* Basic MMX technology is not support in cpu, mean nothing for us so return here */
72 return 0;
73 }
74
75 uiCPU = WELS_CPU_MMX;
76 if (uiFeatureD & 0x02000000) {
77 /* SSE technology is identical to AMD MMX extensions */
78 uiCPU |= WELS_CPU_MMXEXT | WELS_CPU_SSE;
79 }
80 if (uiFeatureD & 0x04000000) {
81 /* SSE2 support here */
82 uiCPU |= WELS_CPU_SSE2;
83 }
84 if (uiFeatureD & 0x00000001) {
85 /* x87 FPU on-chip checking */
86 uiCPU |= WELS_CPU_FPU;
87 }
88 if (uiFeatureD & 0x00008000) {
89 /* CMOV instruction checking */
90 uiCPU |= WELS_CPU_CMOV;
91 }
92 if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
93 if (uiFeatureD & 0x10000000) {
94 /* Multi-Threading checking: contains of multiple logic processors */
95 uiCPU |= WELS_CPU_HTT;
96 }
97 }
98
99 if (uiFeatureC & 0x00000001) {
100 /* SSE3 support here */
101 uiCPU |= WELS_CPU_SSE3;
102 }
103 if (uiFeatureC & 0x00000200) {
104 /* SSSE3 support here */
105 uiCPU |= WELS_CPU_SSSE3;
106 }
107 if (uiFeatureC & 0x00080000) {
108 /* SSE4.1 support here, 45nm Penryn processor */
109 uiCPU |= WELS_CPU_SSE41;
110 }
111 if (uiFeatureC & 0x00100000) {
112 /* SSE4.2 support here, next generation Nehalem processor */
113 uiCPU |= WELS_CPU_SSE42;
114 }
115 if (WelsCPUSupportAVX (uiFeatureA, uiFeatureC)) { //
116 /* AVX supported */
117 uiCPU |= WELS_CPU_AVX;
118 }
119 if (WelsCPUSupportFMA (uiFeatureA, uiFeatureC)) { //
120 /* AVX FMA supported */
121 uiCPU |= WELS_CPU_FMA;
122 }
123 if (uiFeatureC & 0x02000000) {
124 /* AES checking */
125 uiCPU |= WELS_CPU_AES;
126 }
127 if (uiFeatureC & 0x00400000) {
128 /* MOVBE checking */
129 uiCPU |= WELS_CPU_MOVBE;
130 }
131
132 if (pNumberOfLogicProcessors != NULL) {
133 // HTT enabled on chip
134 *pNumberOfLogicProcessors = (uiFeatureB & 0x00ff0000) >> 16; // feature bits: 23-16 on returned EBX
135 }
136
137 WelsCPUId (0x80000000, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
138
139 if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_AMD))
140 && (uiFeatureA >= 0x80000001)) { // confirmed_safe_unsafe_usage
141 WelsCPUId (0x80000001, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
142 if (uiFeatureD & 0x00400000) {
143 uiCPU |= WELS_CPU_MMXEXT;
144 }
145 if (uiFeatureD & 0x80000000) {
146 uiCPU |= WELS_CPU_3DNOW;
147 }
148 }
149
150 if (!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL)) { // confirmed_safe_unsafe_usage
151 int32_t family, model;
152
153 WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
154 family = ((uiFeatureA >> 8) & 0xf) + ((uiFeatureA >> 20) & 0xff);
155 model = ((uiFeatureA >> 4) & 0xf) + ((uiFeatureA >> 12) & 0xf0);
156
157 if ((family == 6) && (model == 9 || model == 13 || model == 14)) {
158 uiCPU &= ~ (WELS_CPU_SSE2 | WELS_CPU_SSE3);
159 }
160 }
161
162 // get cache line size
163 if ((!strcmp ((const str_t*)chVenderName, CPU_Vender_INTEL))
164 || ! (strcmp ((const str_t*)chVenderName, CPU_Vender_CYRIX))) { // confirmed_safe_unsafe_usage
165 WelsCPUId (1, &uiFeatureA, &uiFeatureB, &uiFeatureC, &uiFeatureD);
166
167 CacheLineSize = (uiFeatureB & 0xff00) >>
168 5; // ((clflush_line_size >> 8) << 3), CLFLUSH_line_size * 8 = CacheLineSize_in_byte
169
170 if (CacheLineSize == 128) {
171 uiCPU |= WELS_CPU_CACHELINE_128;
172 } else if (CacheLineSize == 64) {
173 uiCPU |= WELS_CPU_CACHELINE_64;
174 } else if (CacheLineSize == 32) {
175 uiCPU |= WELS_CPU_CACHELINE_32;
176 } else if (CacheLineSize == 16) {
177 uiCPU |= WELS_CPU_CACHELINE_16;
178 }
179 }
180
181 return uiCPU;
182}
183
184
185void WelsCPURestore (const uint32_t kuiCPU) {
186 if (kuiCPU & (WELS_CPU_MMX | WELS_CPU_MMXEXT | WELS_CPU_3DNOW | WELS_CPU_3DNOWEXT)) {
187 WelsEmms();
188 }
189}
190
191#endif
192
193
194WELSVP_NAMESPACE_END
195
196
codec/processing/src/common/cpu.h+102−0
@@ -0,0 +1,102 @@
1/*!
2 * \copy
3 * Copyright (c) 2009-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 * \file cpu.h
32 *
33 * \brief CPU feature compatibility detection
34 *
35 * \date 04/29/2009 Created
36 *
37 *************************************************************************************
38 */
39
40#ifndef WELSVP_CPU_H
41#define WELSVP_CPU_H
42
43#include "typedef.h"
44
45WELSVP_NAMESPACE_BEGIN
46
47/*
48 * WELS CPU feature flags
49 */
50#define WELS_CPU_MMX 0x00000001 /* mmx */
51#define WELS_CPU_MMXEXT 0x00000002 /* mmx-ext*/
52#define WELS_CPU_SSE 0x00000004 /* sse */
53#define WELS_CPU_SSE2 0x00000008 /* sse 2 */
54#define WELS_CPU_SSE3 0x00000010 /* sse 3 */
55#define WELS_CPU_SSE41 0x00000020 /* sse 4.1 */
56#define WELS_CPU_3DNOW 0x00000040 /* 3dnow! */
57#define WELS_CPU_3DNOWEXT 0x00000080 /* 3dnow! ext */
58#define WELS_CPU_ALTIVEC 0x00000100 /* altivec */
59#define WELS_CPU_SSSE3 0x00000200 /* ssse3 */
60#define WELS_CPU_SSE42 0x00000400 /* sse 4.2 */
61
62/* CPU features application extensive */
63#define WELS_CPU_AVX 0x00000800 /* Advanced Vector eXtentions */
64#define WELS_CPU_FPU 0x00001000 /* x87-FPU on chip */
65#define WELS_CPU_HTT 0x00002000 /* Hyper-Threading Technology (HTT), Multi-threading enabled feature:
66 physical processor package is capable of supporting more than one logic processor
67 */
68#define WELS_CPU_CMOV 0x00004000 /* Conditional Move Instructions,
69 also if x87-FPU is present at indicated by the CPUID.FPU feature bit, then FCOMI and FCMOV are supported
70 */
71#define WELS_CPU_MOVBE 0x00008000 /* MOVBE instruction */
72#define WELS_CPU_AES 0x00010000 /* AES instruction extensions */
73#define WELS_CPU_FMA 0x00020000 /* AVX VEX FMA instruction sets */
74
75#define WELS_CPU_CACHELINE_16 0x10000000 /* CacheLine Size 16 */
76#define WELS_CPU_CACHELINE_32 0x20000000 /* CacheLine Size 32 */
77#define WELS_CPU_CACHELINE_64 0x40000000 /* CacheLine Size 64 */
78#define WELS_CPU_CACHELINE_128 0x80000000 /* CacheLine Size 128 */
79
80/*
81 * Interfaces for CPU core feature detection as below
82 */
83
84#ifdef X86_ASM
85WELSVP_EXTERN_C_BEGIN
86
87int32_t WelsCPUIdVerify();
88
89void WelsCPUId (uint32_t uiIndex, uint32_t* pFeatureA, uint32_t* pFeatureB, uint32_t* pFeatureC, uint32_t* pFeatureD);
90int32_t WelsCPUSupportAVX (uint32_t eax, uint32_t ecx);
91int32_t WelsCPUSupportFMA (uint32_t eax, uint32_t ecx);
92
93void WelsEmms();
94
95WELSVP_EXTERN_C_END
96#endif
97
98uint32_t WelsCPUFeatureDetect (int32_t* pNumberOfLogicProcessors);
99
100WELSVP_NAMESPACE_END
101
102#endif
codec/processing/src/common/memory.cpp+117−0
@@ -0,0 +1,117 @@
1/*!
2 * \copy
3 * Copyright (c) 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
33#include "memory.h"
34
35WELSVP_NAMESPACE_BEGIN
36/////////////////////////////////////////////////////////////////////////////////
37
38void* WelsMalloc (const uint32_t kuiSize, str_t* pTag) {
39 const int32_t kiSizeVoidPointer = sizeof (void**);
40 const int32_t kiSizeInt32 = sizeof (int32_t);
41 const int32_t kiAlignedBytes = ALIGNBYTES - 1;
42
43 uint8_t* pBuf = (uint8_t*) ::malloc (kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32);
44 uint8_t* pAlignedBuf = NULL;
45
46 if (NULL == pBuf)
47 return NULL;
48
49 // to fill zero values
50 WelsMemset (pBuf, 0, kuiSize + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32);
51
52 pAlignedBuf = pBuf + kiAlignedBytes + kiSizeVoidPointer + kiSizeInt32;
53 pAlignedBuf -= WelsCastFromPointer (pAlignedBuf) & kiAlignedBytes;
54 * ((void**) (pAlignedBuf - kiSizeVoidPointer)) = pBuf;
55 * ((int32_t*) (pAlignedBuf - (kiSizeVoidPointer + kiSizeInt32))) = kuiSize;
56
57 return (pAlignedBuf);
58}
59
60/////////////////////////////////////////////////////////////////////////////
61
62void WelsFree (void* pPointer, str_t* pTag) {
63 if (pPointer) {
64 ::free (* (((void**) pPointer) - 1));
65 }
66}
67
68/////////////////////////////////////////////////////////////////////////////
69
70void* InternalReallocate (void* pPointer, const uint32_t kuiSize, str_t* pTag) {
71 uint32_t iOldSize = 0;
72 uint8_t* pNew = NULL;
73 if (pPointer != NULL)
74 iOldSize = * ((int32_t*) ((uint8_t*) pPointer - sizeof (void**) - sizeof (int32_t)));
75 else
76 return WelsMalloc (kuiSize, pTag);
77
78 pNew = (uint8_t*)WelsMalloc (kuiSize, pTag);
79 if (0 == pNew) {
80 if (iOldSize > 0 && kuiSize > 0 && iOldSize >= kuiSize)
81 return (pPointer);
82 return 0;
83 } else if (iOldSize > 0 && kuiSize > 0)
84 memcpy (pNew, pPointer, (iOldSize < kuiSize) ? iOldSize : kuiSize);
85 else
86 return 0;
87
88 WelsFree (pPointer, pTag);
89 return (pNew);
90}
91
92/////////////////////////////////////////////////////////////////////////////
93
94void* WelsRealloc (void* pPointer, uint32_t* pRealSize, const uint32_t kuiSize, str_t* pTag) {
95 const uint32_t kuiOldSize = *pRealSize;
96 uint32_t kuiNewSize = 0;
97 void* pLocalPointer = NULL;
98 if (kuiOldSize >= kuiSize) // large enough of original block, so do nothing
99 return (pPointer);
100
101 // new request
102 kuiNewSize = kuiSize + 15;
103 kuiNewSize -= (kuiNewSize & 15);
104 kuiNewSize += 32;
105
106 pLocalPointer = InternalReallocate (pPointer, kuiNewSize, pTag);
107 if (NULL != pLocalPointer) {
108 *pRealSize = kuiNewSize;
109 return (pLocalPointer);
110 } else {
111 return NULL;
112 }
113
114 return NULL; // something wrong
115}
116
117WELSVP_NAMESPACE_END
codec/processing/src/common/memory.h+110−0
@@ -0,0 +1,110 @@
1/*!
2 * \copy
3 * Copyright (c) 2011-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 * \file : memory.h
32 *
33 * \brief : memory definition for wels video processor class
34 *
35 * \date : 2011/02/22
36 *
37 * \description :
38 *
39 *************************************************************************************
40 */
41
42#ifndef WELSVP_MEMORY_H
43#define WELSVP_MEMORY_H
44
45#include "util.h"
46#include "typedef.h"
47
48WELSVP_NAMESPACE_BEGIN
49
50inline_t void* WelsMemset (void* pPointer, int32_t iValue, uint32_t uiSize) {
51 return ::memset (pPointer, iValue, uiSize);
52}
53
54inline_t void* WelsMemcpy (void* pDst, const void* kpSrc, uint32_t uiSize) {
55 return ::memcpy (pDst, kpSrc, uiSize);
56}
57
58inline_t int32_t WelsMemcmp (const void* kpBuf1, const void* kpBuf2, uint32_t uiSize) {
59 return ::memcmp (kpBuf1, kpBuf2, uiSize);
60}
61
62/*!
63*************************************************************************************
64* \brief malloc with zero filled utilization in Wels
65*
66* \param i_size uiSize of memory block required
67*
68* \return allocated memory pointer exactly, failed in case of NULL return
69*
70* \note N/A
71*************************************************************************************
72*/
73void* WelsMalloc (const uint32_t kuiSize, str_t* pTag = NULL);
74
75/*!
76*************************************************************************************
77* \brief free utilization in Wels
78*
79* \param p data pointer to be free.
80* i.e, uint8_t *p = actual data to be free, argv = &p.
81*
82* \return NONE
83*
84* \note N/A
85*************************************************************************************
86*/
87void WelsFree (void* pPointer, str_t* pTag = NULL);
88
89/*!
90*************************************************************************************
91* \brief reallocation in Wels. Do nothing and continue using old block
92* in case the block is large enough currently
93*
94* \param p memory block required in old time
95* \param i_size new uiSize of memory block requested
96* \param sz_real pointer to the old uiSize of memory block
97*
98* \return reallocated memory pointer exactly, failed in case of NULL return
99*
100* \note N/A
101*************************************************************************************
102*/
103void* WelsRealloc (void* pPointer, uint32_t* pRealSize, const uint32_t kuiSize, str_t* pTag = NULL);
104
105//////////////////////////////////////////////////////////////////////////////////////
106WELSVP_NAMESPACE_END
107
108#endif
109
110
codec/processing/src/common/resource.h+15−0
@@ -0,0 +1,15 @@
1//{{NO_DEPENDENCIES}}
2// Microsoft Visual C++ generated include file.
3// Used by WelsVP.rc
4//
5
6// Next default values for new objects
7//
8#ifdef APSTUDIO_INVOKED
9#ifndef APSTUDIO_READONLY_SYMBOLS
10#define _APS_NEXT_RESOURCE_VALUE 101
11#define _APS_NEXT_COMMAND_VALUE 40001
12#define _APS_NEXT_CONTROL_VALUE 1000
13#define _APS_NEXT_SYMED_VALUE 101
14#endif
15#endif
codec/processing/src/common/thread.cpp+93−0
@@ -0,0 +1,93 @@
1/*!
2 * \copy
3 * Copyright (c) 2009-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 * \file thread.cpp
32 *
33 * \brief Interfaces introduced in thread programming
34 *
35 * \date 11/17/2009 Created
36 *
37 *************************************************************************************
38 */
39
40#include "thread.h"
41
42WELSVP_NAMESPACE_BEGIN
43
44#if defined(_WIN32)
45
46WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
47 InitializeCriticalSection (mutex);
48
49 return WELS_THREAD_ERROR_OK;
50}
51
52WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
53 EnterCriticalSection (mutex);
54
55 return WELS_THREAD_ERROR_OK;
56}
57
58WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
59 LeaveCriticalSection (mutex);
60
61 return WELS_THREAD_ERROR_OK;
62}
63
64WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
65 DeleteCriticalSection (mutex);
66
67 return WELS_THREAD_ERROR_OK;
68}
69
70#elif defined(__GNUC__)
71
72WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex) {
73 return pthread_mutex_init (mutex, NULL);
74}
75
76WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex) {
77 return pthread_mutex_lock (mutex);
78}
79
80WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex) {
81 return pthread_mutex_unlock (mutex);
82}
83
84WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex) {
85 return pthread_mutex_destroy (mutex);
86}
87
88#endif
89
90WELSVP_NAMESPACE_END
91
92
93
codec/processing/src/common/thread.h+89−0
@@ -0,0 +1,89 @@
1/*!
2 * \copy
3 * Copyright (c) 2009-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 * \file thread.h
32 *
33 * \brief Interfaces introduced in thread programming
34 *
35 * \date 11/17/2009 Created
36 *
37 *************************************************************************************
38 */
39
40#ifndef WELSVP_THREAD_H
41#define WELSVP_THREAD_H
42
43#include "typedef.h"
44
45#if defined(_WIN32)
46
47#include <windows.h>
48
49#elif defined(__GNUC__)
50
51#include <stdlib.h>
52#include <unistd.h>
53#include <pthread.h>
54#include <semaphore.h>
55#include <signal.h>
56#include <errno.h>
57
58#endif//WIN32
59
60WELSVP_NAMESPACE_BEGIN
61
62#if defined(_WIN32)
63
64typedef HANDLE WELS_THREAD_HANDLE;
65typedef CRITICAL_SECTION WELS_MUTEX;
66
67#elif defined(__GNUC__)
68
69typedef pthread_t WELS_THREAD_HANDLE;
70typedef pthread_mutex_t WELS_MUTEX;
71
72#endif
73
74typedef long_t WELS_THREAD_ERROR_CODE;
75
76#define WELS_THREAD_ERROR_OK 0
77#define WELS_THREAD_ERROR_GENERIAL ((unsigned long)(-1))
78#define WELS_THREAD_ERROR_WAIT_OBJECT_0 0
79#define WELS_THREAD_ERROR_WAIT_TIMEOUT ((unsigned long)0x00000102L)
80#define WELS_THREAD_ERROR_WAIT_FAILED WELS_THREAD_ERROR_GENERIAL
81
82WELS_THREAD_ERROR_CODE WelsMutexInit (WELS_MUTEX* mutex);
83WELS_THREAD_ERROR_CODE WelsMutexLock (WELS_MUTEX* mutex);
84WELS_THREAD_ERROR_CODE WelsMutexUnlock (WELS_MUTEX* mutex);
85WELS_THREAD_ERROR_CODE WelsMutexDestroy (WELS_MUTEX* mutex);
86
87WELSVP_NAMESPACE_END
88
89#endif
codec/processing/src/common/typedef.h+102−0
@@ -0,0 +1,102 @@
1/*!
2 * \copy
3 * Copyright (c) 2011-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 * \file : typedef.h
32 *
33 * \brief : basic type definition
34 *
35 * \date : 2011/01/04
36 *
37 * \description : 1. Define basic type with platform-independent;
38 * 2. Define specific namespace to avoid name pollution;
39 * 3. C++ ONLY;
40 *
41 *************************************************************************************
42 */
43
44#ifndef WELSVP_TYPEDEF_H
45#define WELSVP_TYPEDEF_H
46
47#define WELSVP_EXTERN_C_BEGIN extern "C" {
48#define WELSVP_EXTERN_C_END }
49
50#define WELSVP_NAMESPACE_BEGIN namespace nsWelsVP {
51#define WELSVP_NAMESPACE_END }
52
53WELSVP_NAMESPACE_BEGIN
54
55#if ( defined(_WIN32) || defined(_WIN32) ) && defined(_MSC_VER)
56
57typedef char int8_t ;
58typedef unsigned char uint8_t ;
59typedef short int16_t ;
60typedef unsigned short uint16_t ;
61typedef int int32_t ;
62typedef unsigned int uint32_t ;
63typedef __int64 int64_t ;
64typedef unsigned __int64 uint64_t ;
65#define inline_t _inline
66
67#else // GCC
68
69typedef signed char int8_t
70; // [comment]: some compilers may identify the type "char" as "unsigned char" as default, so declare it explicit
71typedef unsigned char uint8_t ;
72typedef signed short int16_t ;
73typedef unsigned short uint16_t ;
74typedef signed int int32_t ;
75typedef unsigned int uint32_t ;
76typedef long long int64_t ;
77typedef unsigned long long uint64_t ;
78#define inline_t inline
79
80#endif
81
82typedef char str_t ; // [comment]: specific use plain char only for character parameters
83typedef long long_t ;
84typedef int32_t bool_t ;
85
86#if defined(_WIN32) || defined(_MACH_PLATFORM) || defined(__GNUC__)
87typedef float float_t ;
88typedef double double_t ;
89#endif
90
91#ifndef NULL
92#define NULL 0
93#endif
94
95enum {
96 FALSE = 0,
97 TRUE = !FALSE
98};
99
100WELSVP_NAMESPACE_END
101
102#endif
codec/processing/src/common/util.cpp+45−0
@@ -0,0 +1,45 @@
1/*!
2 * \copy
3 * Copyright (c) 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
33#include "util.h"
34
35WELSVP_NAMESPACE_BEGIN
36/////////////////////////////////////////////////////////////////////////////////
37
38
39int32_t WelsStrCmp (const str_t* kpStr1, const str_t* kpStr2) {
40 return ::strcmp (kpStr1, kpStr2);
41}
42
43
44/////////////////////////////////////////////////////////////////////////////////
45WELSVP_NAMESPACE_END
codec/processing/src/common/util.h+107−0
@@ -0,0 +1,107 @@
1/*!
2 * \copy
3 * Copyright (c) 2011-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 * \file : util.h
32 *
33 * \brief : utils for wels video processor class
34 *
35 * \date : 2011/01/04
36 *
37 * \description :
38 *
39 *************************************************************************************
40 */
41
42#ifndef WELSVP_UTIL_H
43#define WELSVP_UTIL_H
44
45#include <stdio.h>
46#include <stdlib.h>
47#include <string.h>
48#include <stdarg.h>
49#include <assert.h>
50
51#include "typedef.h"
52#include "memory.h"
53#include "../../interface/IWelsVP.h"
54
55WELSVP_NAMESPACE_BEGIN
56
57#define MAX_WIDTH (4096)
58#define MAX_HEIGHT (2304)//MAX_FS_LEVEL51 (36864); MAX_FS_LEVEL51*256/4096 = 2304
59#define MB_WIDTH_LUMA (16)
60#define PESN (1e-6) // desired float precision
61
62#define MB_TYPE_INTRA4x4 0x00000001
63#define MB_TYPE_INTRA16x16 0x00000002
64#define MB_TYPE_INTRA_PCM 0x00000004
65#define MB_TYPE_INTRA (MB_TYPE_INTRA4x4 | MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
66#define IS_INTRA(type) ((type)&MB_TYPE_INTRA)
67
68#define WELS_MAX(x, y) ((x) > (y) ? (x) : (y))
69#define WELS_MIN(x, y) ((x) < (y) ? (x) : (y))
70#define WELS_SIGN(a) ((long_t)(a) >> 31)
71#define WELS_ABS(a) ((WELS_SIGN(a) ^ (long_t)(a)) - WELS_SIGN(a))
72#define WELS_CLAMP(x, minv, maxv) WELS_MIN(WELS_MAX(x, minv), maxv)
73
74#define ALIGNBYTES (16) /* Worst case is requiring alignment to an 16 byte boundary */
75#define WELS_ALIGN(iInput) ((iInput+(ALIGNMENT-1)) & ~(ALIGNMENT-1))
76#define WELS_ALIGN2(iInput) ((iInput+1) & ~1)
77#define WELS_ALIGN4(iInput) ((iInput+3) & ~3)
78#define WELS_ALIGN8(iInput) ((iInput+7) & ~7)
79
80#define WelsCastFromPointer(p) (reinterpret_cast<long_t>(p))
81#define WelsStaticCast(type, p) (static_cast<type>(p))
82#define WelsDynamicCast(type, p) (dynamic_cast<type>(p))
83
84#define GET_METHOD(x) ((x) & 0xff) // mask method as the lowest 8bits
85#define GET_SPECIAL(x) (((x) >> 8) & 0xff) // mask special flag as 8bits
86
87inline_t EMethods WelsVpGetValidMethod (int32_t a) {
88 int32_t iMethod = GET_METHOD (a);
89 return WelsStaticCast (EMethods, WELS_CLAMP (iMethod, METHOD_NULL + 1, METHOD_MASK - 1));
90}
91
92
93#define _SafeFree(p) if (p) { WelsFree(p); (p) = NULL; }
94#define _SafeDelete(p) if (p) { delete (p); (p) = NULL; }
95
96
97//////////////////////////////////////////////////////////////////////////////////////
98
99int32_t WelsStrCmp (const str_t* kpStr1, const str_t* kpStr2);
100
101
102//////////////////////////////////////////////////////////////////////////////////////
103WELSVP_NAMESPACE_END
104
105#endif
106
107

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t