! * \brief initialize Wels avc encoder core library * \pParam ppCtx sWelsEncCtx** * \pParam pParam SWelsSvcCodingParam* * \return successful - 0; otherwise none 0 for failed */
| 2281 | * \return successful - 0; otherwise none 0 for failed |
| 2282 | */ |
| 2283 | int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingParam, SLogContext* pLogCtx, |
| 2284 | SExistingParasetList* pExistingParasetList) { |
| 2285 | sWelsEncCtx* pCtx = NULL; |
| 2286 | int32_t iRet = 0; |
| 2287 | int16_t iSliceNum = 1; // number of slices used |
| 2288 | int32_t iCacheLineSize = 16; // on chip cache line size in byte |
| 2289 | uint32_t uiCpuFeatureFlags = 0; |
| 2290 | if (NULL == ppCtx || NULL == pCodingParam) { |
| 2291 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), NULL == ppCtx(0x%p) or NULL == pCodingParam(0x%p).", |
| 2292 | (void*)ppCtx, (void*)pCodingParam); |
| 2293 | return 1; |
| 2294 | } |
| 2295 | |
| 2296 | iRet = ParamValidationExt (pLogCtx, pCodingParam); |
| 2297 | if (iRet != 0) { |
| 2298 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.", iRet); |
| 2299 | return iRet; |
| 2300 | } |
| 2301 | iRet = pCodingParam->DetermineTemporalSettings(); |
| 2302 | if (iRet != ENC_RETURN_SUCCESS) { |
| 2303 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 2304 | "WelsInitEncoderExt(), DetermineTemporalSettings failed return %d (check in/out frame rate and temporal layer setting! -- in/out = 2^x, x <= temppral_layer_num)", |
| 2305 | iRet); |
| 2306 | return iRet; |
| 2307 | } |
| 2308 | iRet = GetMultipleThreadIdc (pLogCtx, pCodingParam, iSliceNum, iCacheLineSize, uiCpuFeatureFlags); |
| 2309 | if (iRet != 0) { |
| 2310 | WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), GetMultipleThreadIdc failed return %d.", iRet); |
| 2311 | return iRet; |
| 2312 | } |
| 2313 | |
| 2314 | |
| 2315 | *ppCtx = NULL; |
| 2316 | |
| 2317 | pCtx = static_cast<sWelsEncCtx*> (malloc (sizeof (sWelsEncCtx))); |
| 2318 | |
| 2319 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)) |
| 2320 | memset (pCtx, 0, sizeof (sWelsEncCtx)); |
| 2321 | |
| 2322 | pCtx->sLogCtx = *pLogCtx; |
| 2323 | |
| 2324 | pCtx->pMemAlign = new CMemoryAlign (iCacheLineSize); |
| 2325 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pCtx->pMemAlign), WelsUninitEncoderExt (&pCtx)) |
| 2326 | |
| 2327 | iRet = AllocCodingParam (&pCtx->pSvcParam, pCtx->pMemAlign); |
| 2328 | if (iRet != 0) { |
| 2329 | WelsUninitEncoderExt (&pCtx); |
| 2330 | return iRet; |
| 2331 | } |
| 2332 | memcpy ((void*) pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage |
| 2333 | |
| 2334 | pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList"); |
| 2335 | if (NULL == pCtx->pFuncList) { |
| 2336 | WelsUninitEncoderExt (&pCtx); |
| 2337 | return 1; |
| 2338 | } |
| 2339 | InitFunctionPointers (pCtx, pCtx->pSvcParam, uiCpuFeatureFlags); |
| 2340 |
no test coverage detected