Showing the changes to codec/decoder/core/src/pic_queue.cpp (1 of 225 files). Show all
Unified · Split
| @@ -48,13 +48,13 @@ · 47 unmodified lines | ||
| 48 | 48 | |
| 49 | 49 | namespace WelsDec { |
| 50 | 50 | |
| 51 | −void_t FreePicture( PPicture pPic ); | |
| 51 | +void_t FreePicture (PPicture pPic); | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | ///////////////////////////////////Recycled queue management for pictures/////////////////////////////////// |
| 55 | 55 | /* ______________________________________ |
| 56 | 56 | -->| P0 | P1 | P2 | P3 | P4 | .. | Pn-1 |--> |
| 57 | − -------------------------------------- | |
| 57 | + -------------------------------------- | |
| 58 | 58 | * |
| 59 | 59 | * How does it work? |
| 60 | 60 | * node <- next; ++ next; |
| @@ -63,104 +63,94 @@ void_t FreePicture( PPicture pPic ); · 2 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | −PPicture AllocPicture( PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight ) | |
| 67 | −{ | |
| 68 | − PPicture pPic = NULL; | |
| 69 | − int32_t iPicWidth = 0; | |
| 70 | − int32_t iPicHeight= 0; | |
| 71 | − | |
| 72 | − int32_t iPicChromaWidth = 0; | |
| 73 | − int32_t iPicChromaHeight = 0; | |
| 74 | − int32_t iLumaSize = 0; | |
| 75 | − int32_t iChromaSize = 0; | |
| 76 | − | |
| 77 | − pPic = (PPicture) WelsMalloc( sizeof(SPicture), "PPicture" ); | |
| 78 | − WELS_VERIFY_RETURN_IF( NULL, NULL == pPic ); | |
| 79 | − | |
| 80 | − memset(pPic, 0, sizeof(SPicture) ); | |
| 81 | − | |
| 82 | − iPicWidth = WELS_ALIGN(kiPicWidth + (PADDING_LENGTH<<1), PICTURE_RESOLUTION_ALIGNMENT); | |
| 83 | − iPicHeight = WELS_ALIGN(kiPicHeight + (PADDING_LENGTH<<1), PICTURE_RESOLUTION_ALIGNMENT); | |
| 84 | − iPicChromaWidth = iPicWidth >> 1; | |
| 85 | − iPicChromaHeight = iPicHeight >> 1; | |
| 86 | − | |
| 87 | − iLumaSize = iPicWidth * iPicHeight; | |
| 88 | − iChromaSize = iPicChromaWidth * iPicChromaHeight; | |
| 89 | − if(pCtx->iDecoderMode == SW_MODE) | |
| 90 | − { | |
| 91 | − pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc( iLumaSize /* luma */ | |
| 92 | − + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]" ) ); | |
| 93 | − | |
| 94 | − WELS_VERIFY_RETURN_PROC_IF( NULL, NULL == pPic->pBuffer[0], FreePicture(pPic) ); | |
| 95 | − pPic->iLinesize[0] = iPicWidth; | |
| 96 | − pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; | |
| 97 | − pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize; | |
| 98 | − pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize; | |
| 99 | − pPic->pData[0] = pPic->pBuffer[0] + (1+pPic->iLinesize[0]) * PADDING_LENGTH; | |
| 100 | − pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/( ((1+pPic->iLinesize[1]) * PADDING_LENGTH) >> 1 ); | |
| 101 | − pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/( ((1+pPic->iLinesize[2]) * PADDING_LENGTH) >> 1 ); | |
| 102 | − } | |
| 103 | − | |
| 104 | − | |
| 105 | − | |
| 106 | − pPic->iPlanes = 3; // yv12 in default | |
| 107 | − pPic->iWidthInPixel = kiPicWidth; | |
| 108 | − pPic->iHeightInPixel= kiPicHeight; | |
| 109 | − pPic->iFrameNum = -1; | |
| 110 | − pPic->bAvailableFlag= true; | |
| 111 | − | |
| 112 | − return pPic; | |
| 66 | +PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight) { | |
| 67 | + PPicture pPic = NULL; | |
| 68 | + int32_t iPicWidth = 0; | |
| 69 | + int32_t iPicHeight = 0; | |
| 70 | + | |
| 71 | + int32_t iPicChromaWidth = 0; | |
| 72 | + int32_t iPicChromaHeight = 0; | |
| 73 | + int32_t iLumaSize = 0; | |
| 74 | + int32_t iChromaSize = 0; | |
| 75 | + | |
| 76 | + pPic = (PPicture) WelsMalloc (sizeof (SPicture), "PPicture"); | |
| 77 | + WELS_VERIFY_RETURN_IF (NULL, NULL == pPic); | |
| 78 | + | |
| 79 | + memset (pPic, 0, sizeof (SPicture)); | |
| 80 | + | |
| 81 | + iPicWidth = WELS_ALIGN (kiPicWidth + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); | |
| 82 | + iPicHeight = WELS_ALIGN (kiPicHeight + (PADDING_LENGTH << 1), PICTURE_RESOLUTION_ALIGNMENT); | |
| 83 | + iPicChromaWidth = iPicWidth >> 1; | |
| 84 | + iPicChromaHeight = iPicHeight >> 1; | |
| 85 | + | |
| 86 | + iLumaSize = iPicWidth * iPicHeight; | |
| 87 | + iChromaSize = iPicChromaWidth * iPicChromaHeight; | |
| 88 | + if (pCtx->iDecoderMode == SW_MODE) { | |
| 89 | + pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMalloc (iLumaSize /* luma */ | |
| 90 | + + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]")); | |
| 91 | + | |
| 92 | + WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic)); | |
| 93 | + pPic->iLinesize[0] = iPicWidth; | |
| 94 | + pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth; | |
| 95 | + pPic->pBuffer[1] = pPic->pBuffer[0] + iLumaSize; | |
| 96 | + pPic->pBuffer[2] = pPic->pBuffer[1] + iChromaSize; | |
| 97 | + pPic->pData[0] = pPic->pBuffer[0] + (1 + pPic->iLinesize[0]) * PADDING_LENGTH; | |
| 98 | + pPic->pData[1] = pPic->pBuffer[1] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[1]) * PADDING_LENGTH) >> 1); | |
| 99 | + pPic->pData[2] = pPic->pBuffer[2] + /*WELS_ALIGN*/ (((1 + pPic->iLinesize[2]) * PADDING_LENGTH) >> 1); | |
| 100 | + } | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + pPic->iPlanes = 3; // yv12 in default | |
| 105 | + pPic->iWidthInPixel = kiPicWidth; | |
| 106 | + pPic->iHeightInPixel = kiPicHeight; | |
| 107 | + pPic->iFrameNum = -1; | |
| 108 | + pPic->bAvailableFlag = true; | |
| 109 | + | |
| 110 | + return pPic; | |
| 113 | 111 | } |
| 114 | 112 | |
| 115 | −void_t FreePicture( PPicture pPic ) | |
| 116 | −{ | |
| 117 | − if ( NULL != pPic ) | |
| 118 | − { | |
| 113 | +void_t FreePicture (PPicture pPic) { | |
| 114 | + if (NULL != pPic) { | |
| 119 | 115 | |
| 120 | − if ( pPic->pBuffer[0] ) | |
| 121 | − { | |
| 122 | − WelsFree( pPic->pBuffer[0], "pPic->pBuffer[0]" ); | |
| 123 | − } | |
| 116 | + if (pPic->pBuffer[0]) { | |
| 117 | + WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]"); | |
| 118 | + } | |
| 124 | 119 | |
| 125 | − WelsFree( pPic, "pPic" ); | |
| 120 | + WelsFree (pPic, "pPic"); | |
| 126 | 121 | |
| 127 | − pPic = NULL; | |
| 128 | − } | |
| 122 | + pPic = NULL; | |
| 123 | + } | |
| 129 | 124 | } |
| 130 | −PPicture PrefetchPic( PPicBuff pPicBuf ) | |
| 131 | −{ | |
| 132 | − int32_t iPicIdx = 0; | |
| 133 | − PPicture pPic = NULL; | |
| 134 | − | |
| 135 | − if (pPicBuf->iCapacity == 0) | |
| 136 | − { | |
| 137 | − return NULL; | |
| 138 | − } | |
| 139 | − | |
| 140 | − for ( iPicIdx = pPicBuf->iCurrentIdx+1; iPicIdx<pPicBuf->iCapacity ;++iPicIdx) | |
| 141 | − { | |
| 142 | − if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) | |
| 143 | − { | |
| 144 | − pPic = pPicBuf->ppPic[iPicIdx]; | |
| 145 | − break; | |
| 146 | − } | |
| 147 | − } | |
| 148 | − if (pPic !=NULL) | |
| 149 | − { | |
| 150 | − pPicBuf->iCurrentIdx = iPicIdx; | |
| 151 | − return pPic; | |
| 152 | − } | |
| 153 | − for ( iPicIdx = 0 ; iPicIdx<pPicBuf->iCurrentIdx ;++iPicIdx) | |
| 154 | − { | |
| 155 | − if (pPicBuf->ppPic[iPicIdx] !=NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) | |
| 156 | − { | |
| 157 | − pPic = pPicBuf->ppPic[iPicIdx]; | |
| 158 | − break; | |
| 159 | − } | |
| 160 | − } | |
| 161 | − | |
| 162 | − pPicBuf->iCurrentIdx = iPicIdx; | |
| 163 | − return pPic; | |
| 125 | +PPicture PrefetchPic (PPicBuff pPicBuf) { | |
| 126 | + int32_t iPicIdx = 0; | |
| 127 | + PPicture pPic = NULL; | |
| 128 | + | |
| 129 | + if (pPicBuf->iCapacity == 0) { | |
| 130 | + return NULL; | |
| 131 | + } | |
| 132 | + | |
| 133 | + for (iPicIdx = pPicBuf->iCurrentIdx + 1; iPicIdx < pPicBuf->iCapacity ; ++iPicIdx) { | |
| 134 | + if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag | |
| 135 | + && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) { | |
| 136 | + pPic = pPicBuf->ppPic[iPicIdx]; | |
| 137 | + break; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + if (pPic != NULL) { | |
| 141 | + pPicBuf->iCurrentIdx = iPicIdx; | |
| 142 | + return pPic; | |
| 143 | + } | |
| 144 | + for (iPicIdx = 0 ; iPicIdx < pPicBuf->iCurrentIdx ; ++iPicIdx) { | |
| 145 | + if (pPicBuf->ppPic[iPicIdx] != NULL && pPicBuf->ppPic[iPicIdx]->bAvailableFlag | |
| 146 | + && !pPicBuf->ppPic[iPicIdx]->bUsedAsRef) { | |
| 147 | + pPic = pPicBuf->ppPic[iPicIdx]; | |
| 148 | + break; | |
| 149 | + } | |
| 150 | + } | |
| 151 | + | |
| 152 | + pPicBuf->iCurrentIdx = iPicIdx; | |
| 153 | + return pPic; | |
| 164 | 154 | } |
| 165 | 155 | |
| 166 | 156 | } // namespace WelsDec |