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