History

Revert "Merge pull request #2217 from huili2/simply_dec_ctx"

This reverts commit 27172bafd7ff2cc80b08768a32a23470f3d6d3fd, reversing changes made to 24916a652ee5d3e36d931c222df20966f7c158fa.

Haibo Zhu committed 11 years ago

Commit 628befe1 parent 513a34011 files · +86 −133Browse 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+36−34
@@ -272,13 +272,14 @@ void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) { · 271 unmodified lines
272272 pPicBuf = NULL;
273273 *ppPicBuf = NULL;
274274 }
275−
276275 /*
277276 * fill data fields in default for decoder context
278277 */
279−void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
278+void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) {
280279 int32_t iCpuCores = 1;
280+ memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first
281281 pCtx->sLogCtx = *pLogCtx;
282+ pCtx->pMemAlign = pMa;
282283
283284 pCtx->pArgDec = NULL;
284285
@@ -441,20 +442,18 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 156 unmodified lines
441442 }
442443
443444 /*
444− * free memory dynamically allocated during decoder
445+ * free memory blocks in avc
445446 */
446−void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) {
447+void WelsFreeMem (PWelsDecoderContext pCtx) {
447448 int32_t iListIdx = 0;
448449 CMemoryAlign* pMa = pCtx->pMemAlign;
449450
450− //free dq layer memory
451− UninitialDqLayersContext (pCtx);
452−
453− //free FMO memory
451+ /* TODO: free memory blocks introduced in avc */
454452 ResetFmoList (pCtx);
455453
456− //free ref-pic list & picture memory
457454 WelsResetRefPic (pCtx);
455+
456+ // for sPicBuff
458457 for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
459458 PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx];
460459 if (NULL != pPicBuff && NULL != *pPicBuff) {
@@ -469,8 +468,6 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 8 unmodified lines
469468 pCtx->iLastImgHeightInPixel = 0;
470469 pCtx->bFreezeOutput = true;
471470 pCtx->bHaveGotMemory = false;
472−
473− //free CABAC memory
474471 pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
475472 }
476473
@@ -478,15 +475,19 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 1 unmodified line
478475 * \brief Open decoder
479476 */
480477 int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) {
481− int iRet = ERR_NONE;
482478 // function pointers
483− InitDecFuncs (pCtx, pCtx->uiCpuFlag);
479+ //initial MC function pointer--
480+ int iRet = ERR_NONE;
481+ InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag);
482+
483+ InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag);
484+ AssignFuncPointerForRec (pCtx);
484485
485486 // vlc tables
486487 InitVlcTable (&pCtx->sVlcTable);
487488
488− // static memory
489− iRet = WelsInitStaticMemory (pCtx);
489+ // startup memory
490+ iRet = WelsInitMemory (pCtx);
490491 if (ERR_NONE != iRet)
491492 return iRet;
492493
@@ -506,9 +507,11 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx) { · 13 unmodified lines
506507 * \brief Close decoder
507508 */
508509 void WelsCloseDecoder (PWelsDecoderContext pCtx) {
509− WelsFreeDynamicMemory (pCtx);
510+ WelsFreeMem (pCtx);
511+
512+ WelsFreeMemory (pCtx);
510513
511− WelsFreeStaticMemory (pCtx);
514+ UninitialDqLayersContext (pCtx);
512515
513516 #ifdef LONG_TERM_REF
514517 pCtx->bParamSetsLostFlag = false;
@@ -528,7 +531,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 13 unmodified lines
528531
529532 memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam));
530533 pCtx->eOutputColorFormat = pCtx->pParam->eOutputColorFormat;
531− if (!pCtx->pParam->bParseOnly) {
534+ if (!pCtx->bParseOnly) {
532535 int32_t iRet = DecoderSetCsp (pCtx, pCtx->pParam->eOutputColorFormat);
533536 if (iRet)
534537 return iRet;
@@ -543,7 +546,7 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 8 unmodified lines
543546 }
544547 pCtx->eErrorConMethod = pCtx->pParam->eEcActiveIdc;
545548
546− if (pCtx->pParam->bParseOnly) //parse only, disable EC method
549+ if (pCtx->bParseOnly) //parse only, disable EC method
547550 pCtx->eErrorConMethod = ERROR_CON_DISABLE;
548551 InitErrorCon (pCtx);
549552
@@ -571,11 +574,15 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 21 unmodified lines
571574 * \note N/A
572575 *************************************************************************************
573576 */
574−int32_t WelsInitDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
577+int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogContext* pLogCtx) {
575578 if (pCtx == NULL) {
576579 return ERR_INFO_INVALID_PTR;
577580 }
578581
582+ // default
583+ WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign);
584+
585+ pCtx->bParseOnly = bParseOnly;
579586 // open decoder
580587 return WelsOpenDecoder (pCtx);
581588 }
@@ -652,7 +659,7 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 70 unmodified lines
652659 pRawData->pCurPos = pRawData->pHead;
653660 }
654661
655− if (pCtx->pParam->bParseOnly) {
662+ if (pCtx->bParseOnly) {
656663 pSavedData = &pCtx->sSavedData;
657664 if ((kiBsLen + 4) > (pSavedData->pEnd - pSavedData->pCurPos)) {
658665 pSavedData->pCurPos = pSavedData->pHead;
@@ -857,15 +864,7 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 198 unmodified lines
857864 return iErr;
858865 }
859866
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) {
867+void AssignFuncPointerForRec (PWelsDecoderContext pCtx) {
869868 pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c;
870869 pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c;
871870 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c;
@@ -917,7 +916,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 45 unmodified lines
917916 pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
918917
919918 #if defined(HAVE_NEON)
920− if (uiCpuFlag & WELS_CPU_NEON) {
919+ if (pCtx->uiCpuFlag & WELS_CPU_NEON) {
921920 pCtx->pIdctResAddPredFunc = IdctResAddPred_neon;
922921
923922 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_neon;
@@ -942,7 +941,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 18 unmodified lines
942941 #endif//HAVE_NEON
943942
944943 #if defined(HAVE_NEON_AARCH64)
945− if (uiCpuFlag & WELS_CPU_NEON) {
944+ if (pCtx->uiCpuFlag & WELS_CPU_NEON) {
946945 pCtx->pIdctResAddPredFunc = IdctResAddPred_AArch64_neon;
947946
948947 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_AArch64_neon;
@@ -972,7 +971,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 23 unmodified lines
972971 #endif//HAVE_NEON_AARCH64
973972
974973 #if defined(X86_ASM)
975− if (uiCpuFlag & WELS_CPU_MMXEXT) {
974+ if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) {
976975 pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx;
977976
978977 ///////mmx code opt---
@@ -987,7 +986,7 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 8 unmodified lines
987986 pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsDecoderI4x4LumaPredDDL_mmx;
988987 pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsDecoderI4x4LumaPredVL_mmx;
989988 }
990− if (uiCpuFlag & WELS_CPU_SSE2) {
989+ if (pCtx->uiCpuFlag & WELS_CPU_SSE2) {
991990 /////////sse2 code opt---
992991 pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsDecoderI16x16LumaPredDc_sse2;
993992 pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsDecoderI16x16LumaPredPlane_sse2;
@@ -1001,6 +1000,9 @@ void InitPredFunc (PWelsDecoderContext pCtx, uint32_t uiCpuFlag) { · 7 unmodified lines
10011000 pCtx->pGetI4x4LumaPredFunc[I4_PRED_H] = WelsDecoderI4x4LumaPredH_sse2;
10021001 }
10031002 #endif
1003+ DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag);
1004+
1005+ WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag);
10041006 }
10051007
10061008 //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