History

use WelsUninitEncoderExt rather than FreeMemorySvc which correctly deals with release of vpp memory

sijchen committed 10 years ago

Commit 408b7ca1 parent 8b120601 file · +48 −47Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+48−47
@@ -2433,6 +2433,51 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 2432 unmodified lines
2433 return 0;2433 return 0;
2434}2434}
2435 2435
2436/*!
2437 * \brief uninitialize Wels encoder core library
2438 * \pParam pEncCtx sWelsEncCtx*
2439 * \return none
2440 */
2441void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
2442 if (NULL == ppCtx || NULL == *ppCtx)
2443 return;
2444
2445 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
2446 "WelsUninitEncoderExt(), pCtx= %p, iMultipleThreadIdc= %d.",
2447 (void*) (*ppCtx), (*ppCtx)->pSvcParam->iMultipleThreadIdc);
2448
2449#if defined(STAT_OUTPUT)
2450 StatOverallEncodingExt (*ppCtx);
2451#endif
2452
2453 if ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && (*ppCtx)->pSliceThreading != NULL) {
2454 const int32_t iThreadCount = (*ppCtx)->pSvcParam->iMultipleThreadIdc;
2455 int32_t iThreadIdx = 0;
2456
2457 while (iThreadIdx < iThreadCount) {
2458 int res = 0;
2459 if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
2460 WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
2461 WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
2462 res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
2463 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..",
2464 iThreadIdx,
2465 res);
2466 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
2467 }
2468 ++ iThreadIdx;
2469 }
2470 }
2471
2472 if ((*ppCtx)->pVpp) {
2473 (*ppCtx)->pVpp->FreeSpatialPictures (*ppCtx);
2474 delete (*ppCtx)->pVpp;
2475 (*ppCtx)->pVpp = NULL;
2476 }
2477 FreeMemorySvc (ppCtx);
2478 *ppCtx = NULL;
2479}
2480
2436/*!2481/*!
2437 * \brief initialize Wels avc encoder core library2482 * \brief initialize Wels avc encoder core library
2438 * \pParam ppCtx sWelsEncCtx**2483 * \pParam ppCtx sWelsEncCtx**
@@ -2502,7 +2547,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 63 unmodified lines
2502 iRet = RequestMemorySvc (&pCtx, pExistingParasetList);2547 iRet = RequestMemorySvc (&pCtx, pExistingParasetList);
2503 if (iRet != 0) {2548 if (iRet != 0) {
2504 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), RequestMemorySvc failed return %d.", iRet);2549 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), RequestMemorySvc failed return %d.", iRet);
2505 FreeMemorySvc (&pCtx);2550 WelsUninitEncoderExt (&pCtx);
2506 return iRet;2551 return iRet;
2507 }2552 }
2508 2553
@@ -2514,12 +2559,12 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 5 unmodified lines
2514 if (pCtx->pVpp == NULL) {2559 if (pCtx->pVpp == NULL) {
2515 iRet = 1;2560 iRet = 1;
2516 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pOut of memory in case new CWelsPreProcess().");2561 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pOut of memory in case new CWelsPreProcess().");
2517 FreeMemorySvc (&pCtx);2562 WelsUninitEncoderExt (&pCtx);
2518 return iRet;2563 return iRet;
2519 }2564 }
2520 if ((iRet = pCtx->pVpp->AllocSpatialPictures (pCtx, pCtx->pSvcParam)) != 0) {2565 if ((iRet = pCtx->pVpp->AllocSpatialPictures (pCtx, pCtx->pSvcParam)) != 0) {
2521 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pVPP alloc spatial pictures failed");2566 WelsLog (pLogCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pVPP alloc spatial pictures failed");
2522 FreeMemorySvc (&pCtx);2567 WelsUninitEncoderExt (&pCtx);
2523 return iRet;2568 return iRet;
2524 }2569 }
2525 2570
@@ -2618,50 +2663,6 @@ void StatOverallEncodingExt (sWelsEncCtx* pCtx) { · 92 unmodified lines
2618 }2663 }
2619}2664}
2620#endif2665#endif
2621/*!
2622 * \brief uninitialize Wels encoder core library
2623 * \pParam pEncCtx sWelsEncCtx*
2624 * \return none
2625 */
2626void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
2627 if (NULL == ppCtx || NULL == *ppCtx)
2628 return;
2629
2630 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO,
2631 "WelsUninitEncoderExt(), pCtx= %p, iMultipleThreadIdc= %d.",
2632 (void*) (*ppCtx), (*ppCtx)->pSvcParam->iMultipleThreadIdc);
2633
2634#if defined(STAT_OUTPUT)
2635 StatOverallEncodingExt (*ppCtx);
2636#endif
2637
2638 if ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && (*ppCtx)->pSliceThreading != NULL) {
2639 const int32_t iThreadCount = (*ppCtx)->pSvcParam->iMultipleThreadIdc;
2640 int32_t iThreadIdx = 0;
2641
2642 while (iThreadIdx < iThreadCount) {
2643 int res = 0;
2644 if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
2645 WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
2646 WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
2647 res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
2648 WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..",
2649 iThreadIdx,
2650 res);
2651 (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
2652 }
2653 ++ iThreadIdx;
2654 }
2655 }
2656
2657 if ((*ppCtx)->pVpp) {
2658 (*ppCtx)->pVpp->FreeSpatialPictures (*ppCtx);
2659 delete (*ppCtx)->pVpp;
2660 (*ppCtx)->pVpp = NULL;
2661 }
2662 FreeMemorySvc (ppCtx);
2663 *ppCtx = NULL;
2664}
2665 2666
2666/*!2667/*!
2667 * \brief get temporal level due to configuration and coding context2668 * \brief get temporal level due to configuration and coding context

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