History

remove bParseonly in ctx using that in param, and slightly modify the initialize process of decoder

huili2 committed 11 years ago

Commit 777dbc01 parent b700b6711 files · +133 −86Browse files

Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 11 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+34−36
@@ -272,14 +272,13 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 271 unmodified lines
272272 pPicBuf = NULL;
273273 *ppPicBuf = NULL;
274274 }
275+
275276 /*
276277 * fill data fields in default for decoder context
277278 */
278−void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) {
279+void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
279280 int32_t iCpuCores = 1;
280− memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first
281281 pCtx->sLogCtx = *pLogCtx;
282− pCtx->pMemAlign = pMa;
283282
284283 pCtx->pArgDec = NULL;
285284
@@ -442,18 +441,20 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 156 unmodified lines
442441 }
443442
444443 /*
445− * free memory blocks in avc
444+ * free memory dynamically allocated during decoder
446445 */
447−void WelsFreeMem (PWelsDecoderContext pCtx) {
446+void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) {
448447 int32_t iListIdx = 0;
449448 CMemoryAlign* pMa = pCtx->pMemAlign;
450449
451− /* TODO: free memory blocks introduced in avc */
450+ //free dq layer memory
451+ UninitialDqLayersContext (pCtx);
452+
453+ //free FMO memory
452454 ResetFmoList (pCtx);
453455
456+ //free ref-pic list & picture memory
454457 WelsResetRefPic (pCtx);
455−
456− // for sPicBuff
457458 for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
458459 PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx];
459460 if (NULL != pPicBuff && NULL != *pPicBuff) {
@@ -468,6 +469,8 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 8 unmodified lines
468469 pCtx->iLastImgHeightInPixel = 0;
469470 pCtx->bFreezeOutput = true;
470471 pCtx->bHaveGotMemory = false;
472+
473+ //free CABAC memory
471474 pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
472475 }
473476
@@ -475,19 +478,15 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 1 unmodified line
475478 * \brief Open decoder
476479 */
477480 int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
478− // function pointers
479− //initial MC function pointer--
480481 int iRet = ERR_NONE;
481− InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
482−
483− InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag);
484− AssignFuncPointerForRec (pCtx);
482+ // function pointers
483+ InitDecFuncs (pCtx, pCtx->uiCpuFlag);
485484
486485 // vlc tables
487486 InitVlcTable (&pCtx->sVlcTable);
488487
489− // startup memory
490− iRet = WelsInitMemory (pCtx);
488+ // static memory
489+ iRet = WelsInitStaticMemory (pCtx);
491490 if (ERR_NONE != iRet)
492491 return iRet;
493492
@@ -507,11 +506,9 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 13 unmodified lines
507506 * \brief Close decoder
508507 */
509508 void WelsCloseDecoder (PWelsDecoderContext pCtx) {
510− WelsFreeMem (pCtx);
511−
512− WelsFreeMemory (pCtx);
509+ WelsFreeDynamicMemory (pCtx);
513510
514− UninitialDqLayersContext (pCtx);
511+ WelsFreeStaticMemory (pCtx);
515512
516513 #ifdef LONG_TERM_REF
517514 pCtx->bParamSetsLostFlag = false;
@@ -531,7 +528,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 13 unmodified lines
531528
532529 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
533530 pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
534− if (!pCtx->bParseOnly) {
531+ if (!pCtx->pParam->bParseOnly) {
535532 int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
536533 if (iRet)
537534 return iRet;
@@ -546,7 +543,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 8 unmodified lines
546543 }
547544 pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
548545
549− if (pCtx->bParseOnly) //parse only, disable EC method
546+ if (pCtx->pParam->bParseOnly) //parse only, disable EC method
550547 pCtx->eErrorConMethod = ERROR_CON_DISABLE;
551548 InitErrorCon (pCtx);
552549
@@ -574,15 +571,11 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 21 unmodified lines
574571 * \note N/A
575572 *************************************************************************************
576573 */
577−int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx) {
574+int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
578575 if (pCtx == NULL) {
579576 return ERR_INFO_INVALID_PTR;
580577 }
581578
582− // default
583− WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign);
584−
585− pCtx->bParseOnly = bParseOnly;
586579 // open decoder
587580 return WelsOpenDecoder (pCtx);
588581 }
@@ -659,7 +652,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 70 unmodified lines
659652 pRawData->pCurPos = pRawData->pHead;
660653 }
661654
662− if (pCtx->bParseOnly) {
655+ if (pCtx->pParam->bParseOnly) {
663656 pSavedData = &pCtx->sSavedData;
664657 if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) {
665658 pSavedData->pCurPos = pSavedData->pHead;
@@ -864,7 +857,15 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 198 unmodified lines
864857 return iErr;
865858 }
866859
867−void AssignFuncPointerForRec (PWelsDecoderContext pCtx) {
860+void InitDecFuncs (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) {
861+ WelsBlockFuncInit (&pCtx->sBlockFunc, uiCpuFlag);
862+ InitPredFunc (pCtx, uiCpuFlag);
863+ InitMcFunc (& (pCtx->sMcFunc), uiCpuFlag);
864+ InitExpandPictureFunc (& (pCtx->sExpandPicFunc), uiCpuFlag);
865+ DeblockingInit (&pCtx->sDeblockingFunc, uiCpuFlag);
866+}
867+
868+void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) {
868869 pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
869870 pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
870871 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c;
@@ -916,7 +917,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 45 unmodified lines
916917 pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
917918
918919 #if defined(HAVE_NEON)
919− if (pCtx->uiCpuFlag & WELS_CPU_NEON) {
920+ if (uiCpuFlag & WELS_CPU_NEON) {
920921 pCtx->pIdctResAddPredFunc = IdctResAddPred_neon;
921922
922923 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon;
@@ -941,7 +942,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 18 unmodified lines
941942 #endif//HAVE_NEON
942943
943944 #if defined(HAVE_NEON_AARCH64)
944− if (pCtx->uiCpuFlag & WELS_CPU_NEON) {
945+ if (uiCpuFlag & WELS_CPU_NEON) {
945946 pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon;
946947
947948 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon;
@@ -971,7 +972,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 23 unmodified lines
971972 #endif//HAVE_NEON_AARCH64
972973
973974 #if defined(X86_ASM)
974− if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) {
975+ if (uiCpuFlag & WELS_CPU_MMXEXT) {
975976 pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx;
976977
977978 ///////mmx code opt---
@@ -986,7 +987,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 8 unmodified lines
986987 pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx;
987988 pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx;
988989 }
989− if (pCtx->uiCpuFlag & WELS_CPU_SSE2) {
990+ if (uiCpuFlag & WELS_CPU_SSE2) {
990991 /////////sse2 code opt---
991992 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2;
992993 pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2;
@@ -1000,9 +1001,6 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 7 unmodified lines
10001001 pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2;
10011002 }
10021003 #endif
1003− DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag);
1004−
1005− WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag);
10061004 }
10071005
10081006 //reset decoder number related statistics info

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