Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 225 files). Show all
Unified · Split
| @@ -65,151 +65,136 @@ · 64 unmodified lines | |||
| 65 | 65 | ||
| 66 | namespace WelsDec { | 66 | namespace WelsDec { |
| 67 | 67 | ||
| 68 | extern PPicture AllocPicture( PWelsDecoderContext pCtx,const int32_t kiPicWidth, const int32_t kiPicHeight ); | 68 | extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight); |
| 69 | 69 | ||
| 70 | extern void_t FreePicture( PPicture pPic ); | 70 | extern void_t FreePicture (PPicture pPic); |
| 71 | 71 | ||
| 72 | #ifdef WORDS_BIGENDIAN | 72 | #ifdef WORDS_BIGENDIAN |
| 73 | inline void_t GetValueOf4Bytes( uint8_t* pDstNal, int32_t iDdstIdx ) | 73 | inline void_t GetValueOf4Bytes (uint8_t* pDstNal, int32_t iDdstIdx) { |
| 74 | { | 74 | pDstNal[0] = (iDdstIdx & 0xff000000) >> 24; |
| 75 | pDstNal[0] = (iDdstIdx & 0xff000000) >> 24; | 75 | pDstNal[1] = (iDdstIdx & 0xff0000) >> 16; |
| 76 | pDstNal[1] = (iDdstIdx & 0xff0000) >> 16; | 76 | pDstNal[2] = (iDdstIdx & 0xff00) >> 8; |
| 77 | pDstNal[2] = (iDdstIdx & 0xff00) >> 8; | 77 | pDstNal[3] = (iDdstIdx & 0xff); |
| 78 | pDstNal[3] = (iDdstIdx & 0xff); | ||
| 79 | } | 78 | } |
| 80 | #else //WORDS_BIGENDIAN | 79 | #else //WORDS_BIGENDIAN |
| 81 | inline void_t GetValueOf4Bytes( uint8_t* pDstNal, int32_t iDdstIdx ) | 80 | inline void_t GetValueOf4Bytes (uint8_t* pDstNal, int32_t iDdstIdx) { |
| 82 | { | 81 | pDstNal[0] = (iDdstIdx & 0xff); |
| 83 | pDstNal[0] = (iDdstIdx & 0xff); | 82 | pDstNal[1] = (iDdstIdx & 0xff00) >> 8; |
| 84 | pDstNal[1] = (iDdstIdx & 0xff00) >> 8; | 83 | pDstNal[2] = (iDdstIdx & 0xff0000) >> 16; |
| 85 | pDstNal[2] = (iDdstIdx & 0xff0000) >> 16; | 84 | pDstNal[3] = (iDdstIdx & 0xff000000) >> 24; |
| 86 | pDstNal[3] = (iDdstIdx & 0xff000000) >> 24; | ||
| 87 | } | 85 | } |
| 88 | #endif //WORDS_BIGENDIAN | 86 | #endif //WORDS_BIGENDIAN |
| 89 | 87 | ||
| 90 | static int32_t CreatePicBuff(PWelsDecoderContext pCtx, PPicBuff *ppPicBuf, const int32_t kiSize, const int32_t kiPicWidth, const int32_t kiPicHeight) | 88 | static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize, |
| 91 | { | 89 | const int32_t kiPicWidth, const int32_t kiPicHeight) { |
| 92 | PPicBuff pPicBuf = NULL; | 90 | PPicBuff pPicBuf = NULL; |
| 93 | int32_t iPicIdx = 0; | 91 | int32_t iPicIdx = 0; |
| 94 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) | 92 | if (kiSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 95 | { | 93 | return 1; |
| 96 | return 1; | 94 | } |
| 97 | } | 95 | |
| 98 | 96 | pPicBuf = (PPicBuff)WelsMalloc (sizeof (SPicBuff), "PPicBuff"); | |
| 99 | pPicBuf = (PPicBuff)WelsMalloc( sizeof(SPicBuff), "PPicBuff" ); | 97 | |
| 100 | 98 | if (NULL == pPicBuf) { | |
| 101 | if ( NULL == pPicBuf ) | 99 | return 1; |
| 102 | { | 100 | } |
| 103 | return 1; | 101 | |
| 104 | } | 102 | pPicBuf->ppPic = (PPicture*)WelsMalloc (kiSize * sizeof (PPicture), "PPicture*"); |
| 105 | 103 | ||
| 106 | pPicBuf->ppPic = (PPicture *)WelsMalloc(kiSize * sizeof(PPicture), "PPicture*"); | 104 | if (NULL == pPicBuf->ppPic) { |
| 107 | 105 | return 1; | |
| 108 | if ( NULL == pPicBuf->ppPic ) | 106 | } |
| 109 | { | 107 | for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) { |
| 110 | return 1; | 108 | PPicture pPic = AllocPicture (pCtx, kiPicWidth, kiPicHeight); |
| 111 | } | 109 | if (NULL == pPic) { |
| 112 | for (iPicIdx = 0; iPicIdx < kiSize; ++ iPicIdx) | 110 | return 1; |
| 113 | { | 111 | } |
| 114 | PPicture pPic = AllocPicture( pCtx, kiPicWidth, kiPicHeight ); | 112 | pPicBuf->ppPic[iPicIdx] = pPic; |
| 115 | if ( NULL == pPic ) | 113 | } |
| 116 | { | 114 | |
| 117 | return 1; | 115 | // initialize context in queue |
| 118 | } | 116 | pPicBuf->iCapacity = kiSize; |
| 119 | pPicBuf->ppPic[iPicIdx] = pPic; | 117 | pPicBuf->iCurrentIdx = 0; |
| 120 | } | 118 | *ppPicBuf = pPicBuf; |
| 121 | 119 | ||
| 122 | // initialize context in queue | 120 | return 0; |
| 123 | pPicBuf->iCapacity = kiSize; | ||
| 124 | pPicBuf->iCurrentIdx = 0; | ||
| 125 | *ppPicBuf = pPicBuf; | ||
| 126 | |||
| 127 | return 0; | ||
| 128 | } | 121 | } |
| 129 | 122 | ||
| 130 | static void_t DestroyPicBuff( PPicBuff *ppPicBuf ) | 123 | static void_t DestroyPicBuff (PPicBuff* ppPicBuf) { |
| 131 | { | 124 | PPicBuff pPicBuf = NULL; |
| 132 | PPicBuff pPicBuf = NULL; | 125 | |
| 133 | 126 | if (NULL == ppPicBuf || NULL == *ppPicBuf) | |
| 134 | if ( NULL == ppPicBuf || NULL == *ppPicBuf ) | 127 | return; |
| 135 | return; | 128 | |
| 136 | 129 | pPicBuf = *ppPicBuf; | |
| 137 | pPicBuf = *ppPicBuf; | 130 | while (pPicBuf->ppPic != NULL) { |
| 138 | while(pPicBuf->ppPic != NULL) | 131 | int32_t iPicIdx = 0; |
| 139 | { | 132 | while (iPicIdx < pPicBuf->iCapacity) { |
| 140 | int32_t iPicIdx = 0; | 133 | PPicture pPic = pPicBuf->ppPic[iPicIdx]; |
| 141 | while (iPicIdx < pPicBuf->iCapacity) | 134 | if (pPic != NULL) { |
| 142 | { | 135 | FreePicture (pPic); |
| 143 | PPicture pPic = pPicBuf->ppPic[iPicIdx]; | 136 | } |
| 144 | if(pPic != NULL) | 137 | pPic = NULL; |
| 145 | { | 138 | ++ iPicIdx; |
| 146 | FreePicture( pPic ); | 139 | } |
| 147 | } | 140 | |
| 148 | pPic = NULL; | 141 | WelsFree (pPicBuf->ppPic, "pPicBuf->queue"); |
| 149 | ++ iPicIdx; | 142 | |
| 150 | } | 143 | pPicBuf->ppPic = NULL; |
| 151 | 144 | } | |
| 152 | WelsFree(pPicBuf->ppPic, "pPicBuf->queue"); | 145 | pPicBuf->iCapacity = 0; |
| 153 | 146 | pPicBuf->iCurrentIdx = 0; | |
| 154 | pPicBuf->ppPic = NULL; | 147 | |
| 155 | } | 148 | WelsFree (pPicBuf, "pPicBuf"); |
| 156 | pPicBuf->iCapacity = 0; | 149 | |
| 157 | pPicBuf->iCurrentIdx= 0; | 150 | pPicBuf = NULL; |
| 158 | 151 | *ppPicBuf = NULL; | |
| 159 | WelsFree( pPicBuf, "pPicBuf" ); | ||
| 160 | |||
| 161 | pPicBuf = NULL; | ||
| 162 | *ppPicBuf = NULL; | ||
| 163 | } | 152 | } |
| 164 | /* | 153 | /* |
| 165 | * fill data fields in default for decoder context | 154 | * fill data fields in default for decoder context |
| 166 | */ | 155 | */ |
| 167 | void_t WelsDecoderDefaults( PWelsDecoderContext pCtx ) | 156 | void_t WelsDecoderDefaults (PWelsDecoderContext pCtx) { |
| 168 | { | 157 | int32_t iCpuCores = 1; |
| 169 | int32_t iCpuCores = 1; | 158 | memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first |
| 170 | memset( pCtx, 0, sizeof(SWelsDecoderContext) ); // fill zero first | 159 | |
| 160 | pCtx->pArgDec = NULL; | ||
| 161 | |||
| 162 | pCtx->iOutputColorFormat = videoFormatI420; // yuv in default | ||
| 163 | pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related | ||
| 164 | pCtx->uiCpuFlag = 0; | ||
| 171 | 165 | ||
| 172 | pCtx->pArgDec = NULL; | 166 | pCtx->bAuReadyFlag = 0; // au data is not ready |
| 173 | 167 | ||
| 174 | pCtx->iOutputColorFormat = videoFormatI420; // yuv in default | ||
| 175 | pCtx->bHaveGotMemory = false; // not ever request memory blocks for decoder context related | ||
| 176 | pCtx->uiCpuFlag = 0; | ||
| 177 | |||
| 178 | pCtx->bAuReadyFlag = 0; // au data is not ready | ||
| 179 | |||
| 180 | 168 | ||
| 181 | g_uiCacheLineSize = 16; | 169 | g_uiCacheLineSize = 16; |
| 182 | #if defined(X86_ASM) | 170 | #if defined(X86_ASM) |
| 183 | pCtx->uiCpuFlag = WelsCPUFeatureDetect(&iCpuCores); | 171 | pCtx->uiCpuFlag = WelsCPUFeatureDetect (&iCpuCores); |
| 184 | #ifdef HAVE_CACHE_LINE_ALIGN | 172 | #ifdef HAVE_CACHE_LINE_ALIGN |
| 185 | if ( pCtx->uiCpuFlag & WELS_CPU_CACHELINE_64 ) | 173 | if (pCtx->uiCpuFlag & WELS_CPU_CACHELINE_64) { |
| 186 | { | 174 | g_uiCacheLineSize = 64; |
| 187 | g_uiCacheLineSize = 64; | 175 | } else if (pCtx->uiCpuFlag & WELS_CPU_CACHELINE_32) { |
| 188 | } | 176 | g_uiCacheLineSize = 32; |
| 189 | else if ( pCtx->uiCpuFlag & WELS_CPU_CACHELINE_32 ) | 177 | } |
| 190 | { | ||
| 191 | g_uiCacheLineSize = 32; | ||
| 192 | } | ||
| 193 | #endif//HAVE_CACHE_LINE_ALIGN | 178 | #endif//HAVE_CACHE_LINE_ALIGN |
| 194 | #endif//X86_ASM | 179 | #endif//X86_ASM |
| 195 | 180 | ||
| 196 | pCtx->iImgWidthInPixel = 0; | 181 | pCtx->iImgWidthInPixel = 0; |
| 197 | pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available | 182 | pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available |
| 183 | |||
| 184 | pCtx->iFrameNum = -1; | ||
| 185 | pCtx->iPrevFrameNum = -1; | ||
| 186 | pCtx->iErrorCode = ERR_NONE; | ||
| 187 | |||
| 188 | pCtx->pDec = NULL; | ||
| 198 | 189 | ||
| 199 | pCtx->iFrameNum = -1; | 190 | WelsResetRefPic (pCtx); |
| 200 | pCtx->iPrevFrameNum = -1; | ||
| 201 | pCtx->iErrorCode = ERR_NONE; | ||
| 202 | |||
| 203 | pCtx->pDec = NULL; | ||
| 204 | 191 | ||
| 205 | WelsResetRefPic(pCtx); | 192 | pCtx->iActiveFmoNum = 0; |
| 206 | |||
| 207 | pCtx->iActiveFmoNum = 0; | ||
| 208 | 193 | ||
| 209 | pCtx->pPicBuff[LIST_0] = NULL; | 194 | pCtx->pPicBuff[LIST_0] = NULL; |
| 210 | pCtx->pPicBuff[LIST_1] = NULL; | 195 | pCtx->pPicBuff[LIST_1] = NULL; |
| 211 | 196 | ||
| 212 | pCtx->bAvcBasedFlag = true; | 197 | pCtx->bAvcBasedFlag = true; |
| 213 | 198 | ||
| 214 | } | 199 | } |
| 215 | 200 | ||
| @@ -221,231 +206,212 @@ void_t WelsDecoderDefaults( PWelsDecoderContext pCtx ) · 5 unmodified lines | |||
| 221 | /* | 206 | /* |
| 222 | * get size of reference picture list in target layer incoming, = (iNumRefFrames x 2) | 207 | * get size of reference picture list in target layer incoming, = (iNumRefFrames x 2) |
| 223 | */ | 208 | */ |
| 224 | static inline int32_t GetTargetRefListSize( PWelsDecoderContext pCtx ) | 209 | static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { |
| 225 | { | 210 | bool_t* pSubsetSpsAvail = &pCtx->bSubspsAvailFlags[0]; |
| 226 | bool_t *pSubsetSpsAvail= &pCtx->bSubspsAvailFlags[0]; | 211 | bool_t* pSpsAvail = &pCtx->bSpsAvailFlags[0]; |
| 227 | bool_t *pSpsAvail = &pCtx->bSpsAvailFlags[0]; | 212 | int32_t iSubsetIdx = -1; |
| 228 | int32_t iSubsetIdx = -1; | 213 | int32_t iSpsIdx = -1; |
| 229 | int32_t iSpsIdx = -1; | 214 | bool_t bExistSubsetSps = false; |
| 230 | bool_t bExistSubsetSps = false; | 215 | int32_t bExistSps = false; |
| 231 | int32_t bExistSps = false; | 216 | int32_t iPos = MAX_SPS_COUNT - 1; |
| 232 | int32_t iPos = MAX_SPS_COUNT - 1; | 217 | int32_t iNumRefFrames = 0; |
| 233 | int32_t iNumRefFrames = 0; | 218 | |
| 234 | 219 | while (iPos >= 0) { | |
| 235 | while (iPos >= 0) | 220 | if (pSubsetSpsAvail[iPos]) { |
| 236 | { | 221 | bExistSubsetSps = true; |
| 237 | if ( pSubsetSpsAvail[iPos] ) | 222 | iSubsetIdx = iPos; |
| 238 | { | 223 | break; |
| 239 | bExistSubsetSps = true; | 224 | } |
| 240 | iSubsetIdx = iPos; | 225 | -- iPos; |
| 241 | break; | 226 | } |
| 242 | } | 227 | |
| 243 | -- iPos; | 228 | if (!bExistSubsetSps) { |
| 244 | } | 229 | iPos = MAX_SPS_COUNT - 1; |
| 245 | 230 | while (iPos >= 0) { | |
| 246 | if ( !bExistSubsetSps ) | 231 | if (pSpsAvail[iPos]) { |
| 247 | { | 232 | bExistSps = true; |
| 248 | iPos = MAX_SPS_COUNT - 1; | 233 | iSpsIdx = iPos; |
| 249 | while (iPos >= 0) | 234 | break; |
| 250 | { | 235 | } |
| 251 | if ( pSpsAvail[iPos] ) | 236 | -- iPos; |
| 252 | { | 237 | } |
| 253 | bExistSps = true; | 238 | } |
| 254 | iSpsIdx = iPos; | 239 | |
| 255 | break; | 240 | if (! (bExistSubsetSps || bExistSps)) { |
| 256 | } | 241 | iNumRefFrames = MAX_REF_PIC_COUNT; |
| 257 | -- iPos; | 242 | } else { |
| 258 | } | 243 | PSps pSps = bExistSubsetSps ? (&pCtx->sSubsetSpsBuffer[iSubsetIdx].sSps) : (&pCtx->sSpsBuffer[iSpsIdx]); |
| 259 | } | 244 | |
| 260 | 245 | iNumRefFrames = (pSps->iNumRefFrames) + 1; | |
| 261 | if ( !(bExistSubsetSps || bExistSps) ) | 246 | } |
| 262 | { | 247 | |
| 263 | iNumRefFrames = MAX_REF_PIC_COUNT; | 248 | if (0 == iNumRefFrames) |
| 264 | } | 249 | iNumRefFrames = (MIN_REF_PIC_COUNT); |
| 265 | else | 250 | |
| 266 | { | ||
| 267 | PSps pSps = bExistSubsetSps ? (&pCtx->sSubsetSpsBuffer[iSubsetIdx].sSps) : (&pCtx->sSpsBuffer[iSpsIdx]); | ||
| 268 | |||
| 269 | iNumRefFrames = (pSps->iNumRefFrames ) + 1; | ||
| 270 | } | ||
| 271 | |||
| 272 | if ( 0 == iNumRefFrames ) | ||
| 273 | iNumRefFrames = (MIN_REF_PIC_COUNT); | ||
| 274 | |||
| 275 | #ifdef LONG_TERM_REF | 251 | #ifdef LONG_TERM_REF |
| 276 | //pic_queue size minimum set 2 | 252 | //pic_queue size minimum set 2 |
| 277 | if (iNumRefFrames <2) | 253 | if (iNumRefFrames < 2) { |
| 278 | { | 254 | iNumRefFrames = 2; |
| 279 | iNumRefFrames = 2; | 255 | } |
| 280 | } | ||
| 281 | #endif | 256 | #endif |
| 282 | 257 | ||
| 283 | return iNumRefFrames; | 258 | return iNumRefFrames; |
| 284 | } | 259 | } |
| 285 | 260 | ||
| 286 | /* | 261 | /* |
| 287 | * request memory blocks for decoder avc part | 262 | * request memory blocks for decoder avc part |
| 288 | */ | 263 | */ |
| 289 | int32_t WelsRequestMem( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight ) | 264 | int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { |
| 290 | { | 265 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 291 | const int32_t kiPicWidth = kiMbWidth << 4; | 266 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 292 | const int32_t kiPicHeight = kiMbHeight << 4; | 267 | int32_t iErr = ERR_NONE; |
| 293 | int32_t iErr = ERR_NONE; | 268 | |
| 294 | 269 | int32_t iListIdx = 0; //, mb_blocks = 0; | |
| 295 | int32_t iListIdx = 0; //, mb_blocks = 0; | 270 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 296 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 271 | bool_t bNeedChangePicQueue = true; |
| 297 | bool_t bNeedChangePicQueue = true; | 272 | |
| 298 | 273 | WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0)) | |
| 299 | WELS_VERIFY_RETURN_IF( ERR_INFO_INVALID_PARAM, ( NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0 ) ) | 274 | |
| 300 | 275 | // Fixed the issue about different gop size over last, 5/17/2010 | |
| 301 | // Fixed the issue about different gop size over last, 5/17/2010 | 276 | // get picture queue size currently |
| 302 | // get picture queue size currently | 277 | iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 303 | iPicQueueSize = GetTargetRefListSize( pCtx ); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 278 | pCtx->iPicQueueNumber = iPicQueueSize; |
| 304 | pCtx->iPicQueueNumber = iPicQueueSize; | 279 | if (pCtx->pPicBuff[LIST_0] != NULL |
| 305 | if ( pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity == iPicQueueSize ) // comparing current picture queue size requested and previous allocation picture queue | 280 | && pCtx->pPicBuff[LIST_0]->iCapacity == |
| 306 | bNeedChangePicQueue = false; | 281 | iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue |
| 307 | // HD based pic buffer need consider memory size consumed when switch from 720p to other lower size | 282 | bNeedChangePicQueue = false; |
| 308 | WELS_VERIFY_RETURN_IF( ERR_NONE, pCtx->bHaveGotMemory && ( kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel ) && (!bNeedChangePicQueue) ) // have same scaled buffer | 283 | // HD based pic buffer need consider memory size consumed when switch from 720p to other lower size |
| 309 | 284 | WELS_VERIFY_RETURN_IF (ERR_NONE, pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel | |
| 310 | // sync update pRefList | 285 | && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer |
| 311 | WelsResetRefPic( pCtx ); // added to sync update ref list due to pictures are free | 286 | |
| 312 | 287 | // sync update pRefList | |
| 313 | // for Recycled_Pic_Queue | 288 | WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free |
| 314 | for ( iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx ) | 289 | |
| 315 | { | 290 | // for Recycled_Pic_Queue |
| 316 | PPicBuff *ppPic = &pCtx->pPicBuff[iListIdx]; | 291 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 317 | if ( NULL != ppPic && NULL != *ppPic ) | 292 | PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx]; |
| 318 | { | 293 | if (NULL != ppPic && NULL != *ppPic) { |
| 319 | DestroyPicBuff( ppPic ); | 294 | DestroyPicBuff (ppPic); |
| 320 | } | 295 | } |
| 321 | } | 296 | } |
| 322 | 297 | ||
| 323 | // currently only active for LIST_0 due to have no B frames | 298 | // currently only active for LIST_0 due to have no B frames |
| 324 | iErr = CreatePicBuff( pCtx, &pCtx->pPicBuff[LIST_0], iPicQueueSize, kiPicWidth, kiPicHeight ); | 299 | iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], iPicQueueSize, kiPicWidth, kiPicHeight); |
| 325 | if ( iErr != ERR_NONE ) | 300 | if (iErr != ERR_NONE) |
| 326 | return iErr; | 301 | return iErr; |
| 327 | 302 | ||
| 328 | 303 | ||
| 329 | pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding | 304 | pCtx->iImgWidthInPixel = kiPicWidth; // target width of image to be reconstruted while decoding |
| 330 | pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding | 305 | pCtx->iImgHeightInPixel = kiPicHeight; // target height of image to be reconstruted while decoding |
| 331 | 306 | ||
| 332 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested | 307 | pCtx->bHaveGotMemory = true; // global memory for decoder context related is requested |
| 333 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed | 308 | pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed |
| 334 | return ERR_NONE; | 309 | return ERR_NONE; |
| 335 | } | 310 | } |
| 336 | 311 | ||
| 337 | /* | 312 | /* |
| 338 | * free memory blocks in avc | 313 | * free memory blocks in avc |
| 339 | */ | 314 | */ |
| 340 | void_t WelsFreeMem( PWelsDecoderContext pCtx ) | 315 | void_t WelsFreeMem (PWelsDecoderContext pCtx) { |
| 341 | { | 316 | int32_t iListIdx = 0; |
| 342 | int32_t iListIdx = 0; | 317 | |
| 343 | 318 | /* TODO: free memory blocks introduced in avc */ | |
| 344 | /* TODO: free memory blocks introduced in avc */ | 319 | ResetFmoList (pCtx); |
| 345 | ResetFmoList( pCtx ); | 320 | |
| 346 | 321 | WelsResetRefPic (pCtx); | |
| 347 | WelsResetRefPic( pCtx ); | 322 | |
| 348 | 323 | // for sPicBuff | |
| 349 | // for sPicBuff | 324 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { |
| 350 | for ( iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx ) | 325 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; |
| 351 | { | 326 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| 352 | PPicBuff *pPicBuff = &pCtx->pPicBuff[iListIdx]; | 327 | DestroyPicBuff (pPicBuff); |
| 353 | if ( NULL != pPicBuff && NULL != *pPicBuff ) | 328 | } |
| 354 | { | 329 | } |
| 355 | DestroyPicBuff( pPicBuff ); | 330 | |
| 356 | } | 331 | // added for safe memory |
| 357 | } | 332 | pCtx->iImgWidthInPixel = 0; |
| 358 | 333 | pCtx->iImgHeightInPixel = 0; | |
| 359 | // added for safe memory | 334 | pCtx->bHaveGotMemory = false; |
| 360 | pCtx->iImgWidthInPixel = 0; | 335 | |
| 361 | pCtx->iImgHeightInPixel = 0; | ||
| 362 | pCtx->bHaveGotMemory = false; | ||
| 363 | |||
| 364 | } | 336 | } |
| 365 | 337 | ||
| 366 | /*! | 338 | /*! |
| 367 | * \brief Open decoder | 339 | * \brief Open decoder |
| 368 | */ | 340 | */ |
| 369 | void_t WelsOpenDecoder( PWelsDecoderContext pCtx ) | 341 | void_t WelsOpenDecoder (PWelsDecoderContext pCtx) { |
| 370 | { | 342 | // function pointers |
| 371 | // function pointers | 343 | //initial MC function pointer-- |
| 372 | //initial MC function pointer-- | 344 | InitMcFunc (& (pCtx->sMcFunc), pCtx->uiCpuFlag); |
| 373 | InitMcFunc(&(pCtx->sMcFunc), pCtx->uiCpuFlag); | 345 | |
| 374 | 346 | InitExpandPictureFunc (& (pCtx->sExpandPicFunc), pCtx->uiCpuFlag); | |
| 375 | InitExpandPictureFunc(&(pCtx->sExpandPicFunc), pCtx->uiCpuFlag); | 347 | AssignFuncPointerForRec (pCtx); |
| 376 | AssignFuncPointerForRec(pCtx); | 348 | |
| 377 | 349 | // vlc tables | |
| 378 | // vlc tables | 350 | InitVlcTable (&pCtx->sVlcTable); |
| 379 | InitVlcTable(&pCtx->sVlcTable); | 351 | |
| 380 | 352 | // startup memory | |
| 381 | // startup memory | 353 | if (ERR_NONE != WelsInitMemory (pCtx)) |
| 382 | if ( ERR_NONE != WelsInitMemory( pCtx ) ) | 354 | return; |
| 383 | return; | 355 | |
| 384 | 356 | pCtx->iMaxWidthInSps = 0; | |
| 385 | pCtx->iMaxWidthInSps = 0; | 357 | pCtx->iMaxHeightInSps = 0; |
| 386 | pCtx->iMaxHeightInSps = 0; | ||
| 387 | #ifdef LONG_TERM_REF | 358 | #ifdef LONG_TERM_REF |
| 388 | pCtx->bParamSetsLostFlag = true; | 359 | pCtx->bParamSetsLostFlag = true; |
| 389 | #else | 360 | #else |
| 390 | pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 | 361 | pCtx->bReferenceLostAtT0Flag = true; // should be true to waiting IDR at incoming AU bits following, 6/4/2010 |
| 391 | #endif //LONG_TERM_REF | 362 | #endif //LONG_TERM_REF |
| 392 | } | 363 | } |
| 393 | 364 | ||
| 394 | /*! | 365 | /*! |
| 395 | * \brief Close decoder | 366 | * \brief Close decoder |
| 396 | */ | 367 | */ |
| 397 | void_t WelsCloseDecoder( PWelsDecoderContext pCtx ) | 368 | void_t WelsCloseDecoder (PWelsDecoderContext pCtx) { |
| 398 | { | 369 | WelsFreeMem (pCtx); |
| 399 | WelsFreeMem( pCtx ); | ||
| 400 | |||
| 401 | WelsFreeMemory( pCtx ); | ||
| 402 | 370 | ||
| 403 | UninitialDqLayersContext( pCtx ); | 371 | WelsFreeMemory (pCtx); |
| 372 | |||
| 373 | UninitialDqLayersContext (pCtx); | ||
| 404 | 374 | ||
| 405 | #ifdef LONG_TERM_REF | 375 | #ifdef LONG_TERM_REF |
| 406 | pCtx->bParamSetsLostFlag = false; | 376 | pCtx->bParamSetsLostFlag = false; |
| 407 | #else | 377 | #else |
| 408 | pCtx->bReferenceLostAtT0Flag = false; | 378 | pCtx->bReferenceLostAtT0Flag = false; |
| 409 | #endif | 379 | #endif |
| 410 | } | 380 | } |
| 411 | 381 | ||
| 412 | /*! | 382 | /*! |
| 413 | * \brief configure decoder parameters | 383 | * \brief configure decoder parameters |
| 414 | */ | 384 | */ |
| 415 | int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam ) | 385 | int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const void_t* kpParam) { |
| 416 | { | 386 | if (NULL == pCtx || NULL == kpParam) |
| 417 | if ( NULL == pCtx || NULL == kpParam ) | 387 | return 1; |
| 418 | return 1; | ||
| 419 | 388 | ||
| 420 | pCtx->pParam = (SDecodingParam *)WelsMalloc( sizeof(SDecodingParam), "SDecodingParam" ); | 389 | pCtx->pParam = (SDecodingParam*)WelsMalloc (sizeof (SDecodingParam), "SDecodingParam"); |
| 421 | 390 | ||
| 422 | if ( NULL == pCtx->pParam ) | 391 | if (NULL == pCtx->pParam) |
| 423 | return 1; | 392 | return 1; |
| 424 | 393 | ||
| 425 | memcpy( pCtx->pParam, kpParam, sizeof(SDecodingParam) ); | 394 | memcpy (pCtx->pParam, kpParam, sizeof (SDecodingParam)); |
| 426 | pCtx->iOutputColorFormat = pCtx->pParam->iOutputColorFormat; | 395 | pCtx->iOutputColorFormat = pCtx->pParam->iOutputColorFormat; |
| 427 | pCtx->bErrorResilienceFlag = pCtx->pParam->uiEcActiveFlag ? true : false; | 396 | pCtx->bErrorResilienceFlag = pCtx->pParam->uiEcActiveFlag ? true : false; |
| 428 | 397 | ||
| 429 | if ( VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType || | 398 | if (VIDEO_BITSTREAM_SVC == pCtx->pParam->sVideoProperty.eVideoBsType || |
| 430 | VIDEO_BITSTREAM_AVC == pCtx->pParam->sVideoProperty.eVideoBsType ) | 399 | VIDEO_BITSTREAM_AVC == pCtx->pParam->sVideoProperty.eVideoBsType) { |
| 431 | { | 400 | pCtx->eVideoType = pCtx->pParam->sVideoProperty.eVideoBsType; |
| 432 | pCtx->eVideoType = pCtx->pParam->sVideoProperty.eVideoBsType; | 401 | } else { |
| 433 | } | 402 | pCtx->eVideoType = VIDEO_BITSTREAM_DEFAULT; |
| 434 | else | 403 | } |
| 435 | { | ||
| 436 | pCtx->eVideoType = VIDEO_BITSTREAM_DEFAULT; | ||
| 437 | } | ||
| 438 | 404 | ||
| 439 | WelsLog(pCtx, WELS_LOG_INFO, "eVideoType: %d\n", pCtx->eVideoType); | 405 | WelsLog (pCtx, WELS_LOG_INFO, "eVideoType: %d\n", pCtx->eVideoType); |
| 440 | 406 | ||
| 441 | return 0; | 407 | return 0; |
| 442 | } | 408 | } |
| 443 | 409 | ||
| 444 | /*! | 410 | /*! |
| 445 | ************************************************************************************* | 411 | ************************************************************************************* |
| 446 | * \brief Initialize Wels decoder parameters and memory | 412 | * \brief Initialize Wels decoder parameters and memory |
| 447 | * | 413 | * |
| 448 | * \param pCtx input context to be initialized at first stage | 414 | * \param pCtx input context to be initialized at first stage |
| 449 | * | 415 | * |
| 450 | * \return 0 - successed | 416 | * \return 0 - successed |
| 451 | * \return 1 - failed | 417 | * \return 1 - failed |
| @@ -453,59 +419,56 @@ int32_t DecoderConfigParam ( PWelsDecoderContext pCtx, const void_t* kpParam ) · 1 unmodified line | |||
| 453 | * \note N/A | 419 | * \note N/A |
| 454 | ************************************************************************************* | 420 | ************************************************************************************* |
| 455 | */ | 421 | */ |
| 456 | int32_t WelsInitDecoder( PWelsDecoderContext pCtx, void_t * pTraceHandle, PWelsLogCallbackFunc pLog ) | 422 | int32_t WelsInitDecoder (PWelsDecoderContext pCtx, void_t* pTraceHandle, PWelsLogCallbackFunc pLog) { |
| 457 | { | 423 | if (pCtx == NULL) { |
| 458 | if ( pCtx == NULL ){ | 424 | return ERR_INFO_INVALID_PTR; |
| 459 | return ERR_INFO_INVALID_PTR; | 425 | } |
| 460 | } | 426 | |
| 427 | // default | ||
| 428 | WelsDecoderDefaults (pCtx); | ||
| 461 | 429 | ||
| 462 | // default | 430 | pCtx->pTraceHandle = pTraceHandle; |
| 463 | WelsDecoderDefaults( pCtx ); | ||
| 464 | 431 | ||
| 465 | pCtx->pTraceHandle = pTraceHandle; | 432 | g_pLog = pLog; |
| 466 | 433 | ||
| 467 | g_pLog = pLog; | 434 | // open decoder |
| 435 | WelsOpenDecoder (pCtx); | ||
| 468 | 436 | ||
| 469 | // open decoder | 437 | // decode mode setting |
| 470 | WelsOpenDecoder( pCtx ); | 438 | pCtx->iDecoderMode = SW_MODE; |
| 471 | 439 | pCtx->iSetMode = AUTO_MODE; | |
| 472 | // decode mode setting | 440 | pCtx->iDecoderOutputProperty = BUFFER_HOST; |
| 473 | pCtx->iDecoderMode = SW_MODE; | 441 | pCtx->iModeSwitchType = 0; // 0: do not do mode switch |
| 474 | pCtx->iSetMode = AUTO_MODE; | ||
| 475 | pCtx->iDecoderOutputProperty = BUFFER_HOST; | ||
| 476 | pCtx->iModeSwitchType = 0; // 0: do not do mode switch | ||
| 477 | 442 | ||
| 478 | 443 | ||
| 479 | return ERR_NONE; | 444 | return ERR_NONE; |
| 480 | } | 445 | } |
| 481 | 446 | ||
| 482 | /*! | 447 | /*! |
| 483 | ************************************************************************************* | 448 | ************************************************************************************* |
| 484 | * \brief Uninitialize Wels decoder parameters and memory | 449 | * \brief Uninitialize Wels decoder parameters and memory |
| 485 | * | 450 | * |
| 486 | * \param pCtx input context to be uninitialized at release stage | 451 | * \param pCtx input context to be uninitialized at release stage |
| 487 | * | 452 | * |
| 488 | * \return NONE | 453 | * \return NONE |
| 489 | * | 454 | * |
| 490 | * \note N/A | 455 | * \note N/A |
| 491 | ************************************************************************************* | 456 | ************************************************************************************* |
| 492 | */ | 457 | */ |
| 493 | void_t WelsEndDecoder( PWelsDecoderContext pCtx ) | 458 | void_t WelsEndDecoder (PWelsDecoderContext pCtx) { |
| 494 | { | 459 | // close decoder |
| 495 | // close decoder | 460 | WelsCloseDecoder (pCtx); |
| 496 | WelsCloseDecoder( pCtx ); | ||
| 497 | } | 461 | } |
| 498 | 462 | ||
| 499 | void_t GetVclNalTemporalId( PWelsDecoderContext pCtx ) | 463 | void_t GetVclNalTemporalId (PWelsDecoderContext pCtx) { |
| 500 | { | 464 | PAccessUnit pAccessUnit = pCtx->pAccessUnitList; |
| 501 | PAccessUnit pAccessUnit = pCtx->pAccessUnitList; | 465 | int32_t idx = pAccessUnit->uiStartPos; |
| 502 | int32_t idx = pAccessUnit->uiStartPos; | ||
| 503 | 466 | ||
| 504 | pCtx->iFeedbackVclNalInAu = FEEDBACK_VCL_NAL; | 467 | pCtx->iFeedbackVclNalInAu = FEEDBACK_VCL_NAL; |
| 505 | pCtx->iFeedbackTidInAu = pAccessUnit->pNalUnitsList[idx]->sNalHeaderExt.uiTemporalId; | 468 | pCtx->iFeedbackTidInAu = pAccessUnit->pNalUnitsList[idx]->sNalHeaderExt.uiTemporalId; |
| 506 | } | 469 | } |
| 507 | 470 | ||
| 508 | /*! | 471 | /*! |
| 509 | ************************************************************************************* | 472 | ************************************************************************************* |
| 510 | * \brief First entrance to decoding core interface. | 473 | * \brief First entrance to decoding core interface. |
| 511 | * | 474 | * |
| @@ -521,210 +484,183 @@ void_t GetVclNalTemporalId( PWelsDecoderContext pCtx ) · 9 unmodified lines | |||
| 521 | * \note N/A | 484 | * \note N/A |
| 522 | ************************************************************************************* | 485 | ************************************************************************************* |
| 523 | */ | 486 | */ |
| 524 | int32_t WelsDecodeBs( PWelsDecoderContext pCtx, const uint8_t *kpBsBuf, const int32_t kiBsLen, | 487 | int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const int32_t kiBsLen, |
| 525 | uint8_t **ppDst, SBufferInfo* pDstBufInfo) | 488 | uint8_t** ppDst, SBufferInfo* pDstBufInfo) { |
| 526 | { | 489 | if (!pCtx->bEndOfStreamFlag) { |
| 527 | if ( !pCtx->bEndOfStreamFlag) | 490 | SDataBuffer* pRawData = &pCtx->sRawData; |
| 528 | { | 491 | |
| 529 | SDataBuffer* pRawData = &pCtx->sRawData; | 492 | int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs |
| 530 | 493 | int32_t iSrcConsumed = 0; // consumed bit count of source bs | |
| 531 | int32_t iSrcIdx = 0; //the index of source bit-stream till now after parsing one or more NALs | 494 | int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal |
| 532 | int32_t iSrcConsumed = 0; // consumed bit count of source bs | 495 | int32_t iSrcLength = 0; //the total size of current AU or NAL |
| 533 | int32_t iDstIdx = 0; //the size of current NAL after 0x03 removal and 00 00 01 removal | 496 | |
| 534 | int32_t iSrcLength = 0; //the total size of current AU or NAL | 497 | int32_t iConsumedBytes = 0; |
| 535 | 498 | int32_t iOffset = 0; | |
| 536 | int32_t iConsumedBytes = 0; | 499 | |
| 537 | int32_t iOffset = 0; | 500 | uint8_t* pSrcNal = NULL; |
| 538 | 501 | uint8_t* pDstNal = NULL; | |
| 539 | uint8_t* pSrcNal = NULL; | 502 | uint8_t* pNalPayload = NULL; |
| 540 | uint8_t* pDstNal = NULL; | 503 | |
| 541 | uint8_t *pNalPayload = NULL; | 504 | |
| 542 | 505 | if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset, | |
| 543 | 506 | kiBsLen)) { //CAN'T find the 00 00 01 start prefix from the source buffer | |
| 544 | if ( NULL == DetectStartCodePrefix( kpBsBuf, &iOffset, kiBsLen ) ) //CAN'T find the 00 00 01 start prefix from the source buffer | 507 | return dsBitstreamError; |
| 545 | { | 508 | } |
| 546 | return dsBitstreamError; | 509 | |
| 547 | } | 510 | pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset; |
| 548 | 511 | iSrcLength = kiBsLen - iOffset; | |
| 549 | pSrcNal = const_cast<uint8_t*> (kpBsBuf) + iOffset; | 512 | |
| 550 | iSrcLength = kiBsLen - iOffset; | 513 | if ((kiBsLen + 4) > (pRawData->pEnd - pRawData->pCurPos)) { |
| 551 | 514 | pRawData->pCurPos = pRawData->pHead; | |
| 552 | if ( (kiBsLen + 4) > ( pRawData->pEnd - pRawData->pCurPos ) ) | 515 | } |
| 553 | { | 516 | |
| 554 | pRawData->pCurPos = pRawData->pHead; | 517 | |
| 555 | } | 518 | //copy raw data from source buffer (application) to raw data buffer (codec inside) |
| 556 | 519 | //0x03 removal and extract all of NAL Unit from current raw data | |
| 557 | 520 | pDstNal = pRawData->pCurPos + 4; //4-bytes used to write the length of current NAL rbsp | |
| 558 | //copy raw data from source buffer (application) to raw data buffer (codec inside) | 521 | |
| 559 | //0x03 removal and extract all of NAL Unit from current raw data | 522 | while (iSrcConsumed < iSrcLength) { |
| 560 | pDstNal = pRawData->pCurPos + 4; //4-bytes used to write the length of current NAL rbsp | 523 | if ((2 + iSrcConsumed < iSrcLength) && |
| 561 | 524 | (0 == LD16 (pSrcNal + iSrcIdx)) && | |
| 562 | while ( iSrcConsumed < iSrcLength ) | 525 | ((pSrcNal[2 + iSrcIdx] == 0x03) || (pSrcNal[2 + iSrcIdx] == 0x01))) { |
| 563 | { | 526 | if (pSrcNal[2 + iSrcIdx] == 0x03) { |
| 564 | if ( ( 2 + iSrcConsumed < iSrcLength ) && | 527 | ST16 (pDstNal + iDstIdx, 0); |
| 565 | ( 0 == LD16(pSrcNal+iSrcIdx) ) && | 528 | iDstIdx += 2; |
| 566 | ( (pSrcNal[2+iSrcIdx]==0x03) || (pSrcNal[2+iSrcIdx]==0x01) ) ) | 529 | iSrcIdx += 3; |
| 567 | { | 530 | iSrcConsumed += 3; |
| 568 | if ( pSrcNal[2+iSrcIdx] == 0x03 ) | 531 | } else { |
| 569 | { | 532 | GetValueOf4Bytes (pDstNal - 4, iDstIdx); //pDstNal-4 (non-aligned by 4) in Solaris10(SPARC). Given value by byte. |
| 570 | ST16(pDstNal+iDstIdx, 0); | 533 | |
| 571 | iDstIdx += 2; | 534 | iConsumedBytes = 0; |
| 572 | iSrcIdx += 3; | 535 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); |
| 573 | iSrcConsumed += 3; | 536 | |
| 574 | } | 537 | if (pCtx->bAuReadyFlag) { |
| 575 | else | 538 | ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); |
| 576 | { | 539 | |
| 577 | GetValueOf4Bytes( pDstNal-4, iDstIdx ); //pDstNal-4 (non-aligned by 4) in Solaris10(SPARC). Given value by byte. | 540 | if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) { |
| 578 | |||
| 579 | iConsumedBytes = 0; | ||
| 580 | pNalPayload = ParseNalHeader( pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal-3, iSrcIdx+3, &iConsumedBytes ); | ||
| 581 | |||
| 582 | if (pCtx->bAuReadyFlag) | ||
| 583 | { | ||
| 584 | ConstructAccessUnit( pCtx, ppDst, pDstBufInfo ); | ||
| 585 | |||
| 586 | if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) | ||
| 587 | { | ||
| 588 | #ifdef LONG_TERM_REF | 541 | #ifdef LONG_TERM_REF |
| 589 | pCtx->bParamSetsLostFlag = true; | 542 | pCtx->bParamSetsLostFlag = true; |
| 590 | #else | 543 | #else |
| 591 | pCtx->bReferenceLostAtT0Flag = true; | 544 | pCtx->bReferenceLostAtT0Flag = true; |
| 592 | #endif | 545 | #endif |
| 593 | ResetParameterSetsState( pCtx ); | 546 | ResetParameterSetsState (pCtx); |
| 594 | 547 | ||
| 595 | if( dsOutOfMemory & pCtx->iErrorCode){ | 548 | if (dsOutOfMemory & pCtx->iErrorCode) { |
| 596 | return pCtx->iErrorCode; | 549 | return pCtx->iErrorCode; |
| 597 | } | 550 | } |
| 598 | } | 551 | } |
| 599 | } | 552 | } |
| 600 | 553 | ||
| 601 | if( (IS_PARAM_SETS_NALS(pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL(pCtx->sCurNalHead.eNalUnitType)) && | 554 | if ((IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL (pCtx->sCurNalHead.eNalUnitType)) && |
| 602 | pNalPayload ) | 555 | pNalPayload) { |
| 603 | { | 556 | if (ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes)) { |
| 604 | if ( ParseNonVclNal( pCtx, pNalPayload, iDstIdx-iConsumedBytes ) ) | 557 | if (dsNoParamSets & pCtx->iErrorCode) { |
| 605 | { | ||
| 606 | if ( dsNoParamSets & pCtx->iErrorCode ) | ||
| 607 | { | ||
| 608 | #ifdef LONG_TERM_REF | 558 | #ifdef LONG_TERM_REF |
| 609 | pCtx->bParamSetsLostFlag = true; | 559 | pCtx->bParamSetsLostFlag = true; |
| 610 | #else | 560 | #else |
| 611 | pCtx->bReferenceLostAtT0Flag = true; | 561 | pCtx->bReferenceLostAtT0Flag = true; |
| 612 | #endif | 562 | #endif |
| 613 | ResetParameterSetsState( pCtx ); | 563 | ResetParameterSetsState (pCtx); |
| 614 | } | 564 | } |
| 615 | return pCtx->iErrorCode; | 565 | return pCtx->iErrorCode; |
| 616 | } | 566 | } |
| 617 | } | 567 | } |
| 618 | 568 | ||
| 619 | pDstNal += iDstIdx; //update current position | 569 | pDstNal += iDstIdx; //update current position |
| 620 | if ( (iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal) ) | 570 | if ((iSrcLength - iSrcConsumed + 4) > (pRawData->pEnd - pDstNal)) { |
| 621 | { | 571 | pRawData->pCurPos = pRawData->pHead; |
| 622 | pRawData->pCurPos = pRawData->pHead; | 572 | } else { |
| 623 | } | 573 | pRawData->pCurPos = pDstNal; |
| 624 | else | 574 | } |
| 625 | { | 575 | pDstNal = pRawData->pCurPos + 4; //init, 4 bytes used to store the next NAL |
| 626 | pRawData->pCurPos = pDstNal; | 576 | |
| 627 | } | 577 | pSrcNal += iSrcIdx + 3; |
| 628 | pDstNal = pRawData->pCurPos + 4; //init, 4 bytes used to store the next NAL | 578 | iSrcConsumed += 3; |
| 629 | 579 | iSrcIdx = 0; | |
| 630 | pSrcNal += iSrcIdx+3; | 580 | iDstIdx = 0; //reset 0, used to statistic the length of next NAL |
| 631 | iSrcConsumed += 3; | 581 | } |
| 632 | iSrcIdx = 0; | 582 | continue; |
| 633 | iDstIdx = 0; //reset 0, used to statistic the length of next NAL | 583 | } |
| 634 | } | 584 | pDstNal[iDstIdx++] = pSrcNal[iSrcIdx++]; |
| 635 | continue; | 585 | iSrcConsumed++; |
| 636 | } | 586 | } |
| 637 | pDstNal[iDstIdx++] = pSrcNal[iSrcIdx++]; | 587 | |
| 638 | iSrcConsumed++; | 588 | //last NAL decoding |
| 639 | } | 589 | GetValueOf4Bytes (pDstNal - 4, iDstIdx); //pDstNal-4 (non-aligned by 4) in Solaris10(SPARC). Given value by byte. |
| 640 | 590 | ||
| 641 | //last NAL decoding | 591 | iConsumedBytes = 0; |
| 642 | GetValueOf4Bytes( pDstNal-4, iDstIdx ); //pDstNal-4 (non-aligned by 4) in Solaris10(SPARC). Given value by byte. | 592 | pNalPayload = ParseNalHeader (pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal - 3, iSrcIdx + 3, &iConsumedBytes); |
| 643 | 593 | ||
| 644 | iConsumedBytes = 0; | 594 | if (pCtx->bAuReadyFlag) { |
| 645 | pNalPayload = ParseNalHeader( pCtx, &pCtx->sCurNalHead, pDstNal, iDstIdx, pSrcNal-3, iSrcIdx+3, &iConsumedBytes ); | 595 | ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); |
| 646 | 596 | ||
| 647 | if (pCtx->bAuReadyFlag) | 597 | if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) { |
| 648 | { | ||
| 649 | ConstructAccessUnit( pCtx, ppDst, pDstBufInfo ); | ||
| 650 | |||
| 651 | if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) | ||
| 652 | { | ||
| 653 | #ifdef LONG_TERM_REF | 598 | #ifdef LONG_TERM_REF |
| 654 | pCtx->bParamSetsLostFlag = true; | 599 | pCtx->bParamSetsLostFlag = true; |
| 655 | #else | 600 | #else |
| 656 | pCtx->bReferenceLostAtT0Flag = true; | 601 | pCtx->bReferenceLostAtT0Flag = true; |
| 657 | #endif | 602 | #endif |
| 658 | ResetParameterSetsState( pCtx ); | 603 | ResetParameterSetsState (pCtx); |
| 659 | return pCtx->iErrorCode; | 604 | return pCtx->iErrorCode; |
| 660 | } | 605 | } |
| 661 | } | 606 | } |
| 662 | 607 | ||
| 663 | if( (IS_PARAM_SETS_NALS(pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL(pCtx->sCurNalHead.eNalUnitType)) && pNalPayload ) | 608 | if ((IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType) || IS_SEI_NAL (pCtx->sCurNalHead.eNalUnitType)) |
| 664 | { | 609 | && pNalPayload) { |
| 665 | if ( ParseNonVclNal( pCtx, pNalPayload, iDstIdx-iConsumedBytes ) ) | 610 | if (ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes)) { |
| 666 | { | 611 | if (dsNoParamSets & pCtx->iErrorCode) { |
| 667 | if ( dsNoParamSets & pCtx->iErrorCode ) | ||
| 668 | { | ||
| 669 | #ifdef LONG_TERM_REF | 612 | #ifdef LONG_TERM_REF |
| 670 | pCtx->bParamSetsLostFlag = true; | 613 | pCtx->bParamSetsLostFlag = true; |
| 671 | #else | 614 | #else |
| 672 | pCtx->bReferenceLostAtT0Flag = true; | 615 | pCtx->bReferenceLostAtT0Flag = true; |
| 673 | #endif | 616 | #endif |
| 674 | ResetParameterSetsState( pCtx ); | 617 | ResetParameterSetsState (pCtx); |
| 675 | } | 618 | } |
| 676 | return pCtx->iErrorCode; | 619 | return pCtx->iErrorCode; |
| 677 | } | 620 | } |
| 678 | } | 621 | } |
| 679 | 622 | ||
| 680 | pDstNal += iDstIdx; | 623 | pDstNal += iDstIdx; |
| 681 | pRawData->pCurPos = pDstNal; //init the pCurPos for next NAL(s) storage | 624 | pRawData->pCurPos = pDstNal; //init the pCurPos for next NAL(s) storage |
| 682 | } | 625 | } else { /* no supplementary picture payload input, but stored a picture */ |
| 683 | else /* no supplementary picture payload input, but stored a picture */ | 626 | PAccessUnit pCurAu = |
| 684 | { | 627 | pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization |
| 685 | PAccessUnit pCurAu = pCtx->pAccessUnitList; // current access unit, it will never point to NULL after decode's successful initialization | 628 | |
| 686 | 629 | if (pCurAu->uiAvailUnitsNum == 0) { | |
| 687 | if ( pCurAu->uiAvailUnitsNum == 0 ) | 630 | return pCtx->iErrorCode; |
| 688 | { | 631 | } else { |
| 689 | return pCtx->iErrorCode; | 632 | pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; |
| 690 | } | 633 | |
| 691 | else | 634 | ConstructAccessUnit (pCtx, ppDst, pDstBufInfo); |
| 692 | { | 635 | |
| 693 | pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; | 636 | if ((dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) { |
| 694 | |||
| 695 | ConstructAccessUnit( pCtx, ppDst, pDstBufInfo ); | ||
| 696 | |||
| 697 | if ( (dsOutOfMemory | dsNoParamSets) & pCtx->iErrorCode) | ||
| 698 | { | ||
| 699 | #ifdef LONG_TERM_REF | 637 | #ifdef LONG_TERM_REF |
| 700 | pCtx->bParamSetsLostFlag = true; | 638 | pCtx->bParamSetsLostFlag = true; |
| 701 | #else | 639 | #else |
| 702 | pCtx->bReferenceLostAtT0Flag = true; | 640 | pCtx->bReferenceLostAtT0Flag = true; |
| 703 | #endif | 641 | #endif |
| 704 | ResetParameterSetsState( pCtx ); | 642 | ResetParameterSetsState (pCtx); |
| 705 | return pCtx->iErrorCode; | 643 | return pCtx->iErrorCode; |
| 706 | } | 644 | } |
| 707 | 645 | ||
| 708 | } | 646 | } |
| 709 | } | 647 | } |
| 710 | 648 | ||
| 711 | return pCtx->iErrorCode; | 649 | return pCtx->iErrorCode; |
| 712 | } | 650 | } |
| 713 | 651 | ||
| 714 | /* | 652 | /* |
| 715 | * set colorspace format in decoder | 653 | * set colorspace format in decoder |
| 716 | */ | 654 | */ |
| 717 | int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat) | 655 | int32_t DecoderSetCsp (PWelsDecoderContext pCtx, const int32_t kiColorFormat) { |
| 718 | { | 656 | WELS_VERIFY_RETURN_IF (1, (NULL == pCtx)); |
| 719 | WELS_VERIFY_RETURN_IF( 1, (NULL == pCtx) ); | ||
| 720 | 657 | ||
| 721 | pCtx->iOutputColorFormat = kiColorFormat; | 658 | pCtx->iOutputColorFormat = kiColorFormat; |
| 722 | if ( pCtx->pParam != NULL ) | 659 | if (pCtx->pParam != NULL) { |
| 723 | { | 660 | pCtx->pParam->iOutputColorFormat = kiColorFormat; |
| 724 | pCtx->pParam->iOutputColorFormat = kiColorFormat; | 661 | } |
| 725 | } | ||
| 726 | 662 | ||
| 727 | return 0; | 663 | return 0; |
| 728 | } | 664 | } |
| 729 | 665 | ||
| 730 | /*! | 666 | /*! |
| @@ -733,118 +669,110 @@ int32_t DecoderSetCsp(PWelsDecoderContext pCtx, const int32_t kiColorFormat) · 2 unmodified lines | |||
| 733 | * ( MB coordinate and parts of data within decoder context structure ) | 669 | * ( MB coordinate and parts of data within decoder context structure ) |
| 734 | * \param pCtx Wels decoder context | 670 | * \param pCtx Wels decoder context |
| 735 | * \param iMbWidth MB width | 671 | * \param iMbWidth MB width |
| 736 | * \pram iMbHeight MB height | 672 | * \pram iMbHeight MB height |
| 737 | * \return 0 - successful; none 0 - something wrong | 673 | * \return 0 - successful; none 0 - something wrong |
| 738 | */ | 674 | */ |
| 739 | int32_t SyncPictureResolutionExt( PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight ) | 675 | int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { |
| 740 | { | 676 | int32_t iErr = ERR_NONE; |
| 741 | int32_t iErr = ERR_NONE; | 677 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 742 | const int32_t kiPicWidth = kiMbWidth << 4; | 678 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 743 | const int32_t kiPicHeight = kiMbHeight<< 4; | 679 | |
| 744 | 680 | iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used | |
| 745 | iErr = WelsRequestMem( pCtx, kiMbWidth, kiMbHeight ); // common memory used | 681 | if (ERR_NONE != iErr) { |
| 746 | if ( ERR_NONE != iErr ) | 682 | WelsLog (pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.\n"); |
| 747 | { | 683 | pCtx->iErrorCode = dsOutOfMemory; |
| 748 | WelsLog( pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.\n" ); | 684 | return iErr; |
| 749 | pCtx->iErrorCode = dsOutOfMemory; | 685 | } |
| 750 | return iErr; | 686 | |
| 751 | } | 687 | iErr = InitialDqLayersContext (pCtx, kiPicWidth, kiPicHeight); |
| 752 | 688 | if (ERR_NONE != iErr) { | |
| 753 | iErr = InitialDqLayersContext( pCtx, kiPicWidth, kiPicHeight ); | 689 | WelsLog (pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure.\n"); |
| 754 | if ( ERR_NONE != iErr ) | 690 | pCtx->iErrorCode = dsOutOfMemory; |
| 755 | { | 691 | } |
| 756 | WelsLog( pCtx, WELS_LOG_WARNING, "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure.\n" ); | 692 | |
| 757 | pCtx->iErrorCode = dsOutOfMemory; | 693 | return iErr; |
| 758 | } | ||
| 759 | |||
| 760 | return iErr; | ||
| 761 | } | 694 | } |
| 762 | 695 | ||
| 763 | /*! | 696 | /*! |
| 764 | * \brief update maximal picture width and height if applicable when receiving a SPS NAL | 697 | * \brief update maximal picture width and height if applicable when receiving a SPS NAL |
| 765 | */ | 698 | */ |
| 766 | void_t UpdateMaxPictureResolution( PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight ) | 699 | void_t UpdateMaxPictureResolution (PWelsDecoderContext pCtx, const int32_t kiCurWidth, const int32_t kiCurHeight) { |
| 767 | { | 700 | //any dimension larger than that of current dimension, should modify the max-dimension |
| 768 | //any dimension larger than that of current dimension, should modify the max-dimension | 701 | if (kiCurWidth > pCtx->iMaxWidthInSps || kiCurHeight > pCtx->iMaxHeightInSps) { |
| 769 | if ( kiCurWidth > pCtx->iMaxWidthInSps || kiCurHeight > pCtx->iMaxHeightInSps) | 702 | pCtx->iMaxWidthInSps = kiCurWidth; |
| 770 | { | 703 | pCtx->iMaxHeightInSps = kiCurHeight; |
| 771 | pCtx->iMaxWidthInSps = kiCurWidth; | 704 | } |
| 772 | pCtx->iMaxHeightInSps = kiCurHeight; | 705 | |
| 773 | } | 706 | return; |
| 774 | |||
| 775 | return; | ||
| 776 | } | 707 | } |
| 777 | 708 | ||
| 778 | void_t AssignFuncPointerForRec(PWelsDecoderContext pCtx) | 709 | void_t AssignFuncPointerForRec (PWelsDecoderContext pCtx) { |
| 779 | { | 710 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; |
| 780 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V ] = WelsI16x16LumaPredV_c; | 711 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; |
| 781 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H ] = WelsI16x16LumaPredH_c; | 712 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; |
| 782 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC ] = WelsI16x16LumaPredDc_c; | 713 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P ] = WelsI16x16LumaPredPlane_c; |
| 783 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P ] = WelsI16x16LumaPredPlane_c; | 714 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_L ] = WelsI16x16LumaPredDcLeft_c; |
| 784 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_L ] = WelsI16x16LumaPredDcLeft_c; | 715 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_T ] = WelsI16x16LumaPredDcTop_c; |
| 785 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_T ] = WelsI16x16LumaPredDcTop_c; | 716 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_128] = WelsI16x16LumaPredDcNA_c; |
| 786 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_128] = WelsI16x16LumaPredDcNA_c; | 717 | |
| 787 | 718 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_V ] = WelsI4x4LumaPredV_c; | |
| 788 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_V ] = WelsI4x4LumaPredV_c; | 719 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H ] = WelsI4x4LumaPredH_c; |
| 789 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_H ] = WelsI4x4LumaPredH_c; | 720 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC ] = WelsI4x4LumaPredDc_c; |
| 790 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC ] = WelsI4x4LumaPredDc_c; | 721 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_L ] = WelsI4x4LumaPredDcLeft_c; |
| 791 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_L ] = WelsI4x4LumaPredDcLeft_c; | 722 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_T ] = WelsI4x4LumaPredDcTop_c; |
| 792 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_T ] = WelsI4x4LumaPredDcTop_c; | 723 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_128] = WelsI4x4LumaPredDcNA_c; |
| 793 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DC_128] = WelsI4x4LumaPredDcNA_c; | 724 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL ] = WelsI4x4LumaPredDDL_c; |
| 794 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL ] = WelsI4x4LumaPredDDL_c; | 725 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL_TOP] = WelsI4x4LumaPredDDLTop_c; |
| 795 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL_TOP] = WelsI4x4LumaPredDDLTop_c; | 726 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDR ] = WelsI4x4LumaPredDDR_c; |
| 796 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDR ] = WelsI4x4LumaPredDDR_c; | 727 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsI4x4LumaPredVL_c; |
| 797 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsI4x4LumaPredVL_c; | 728 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL_TOP] = WelsI4x4LumaPredVLTop_c; |
| 798 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL_TOP] = WelsI4x4LumaPredVLTop_c; | 729 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VR ] = WelsI4x4LumaPredVR_c; |
| 799 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VR ] = WelsI4x4LumaPredVR_c; | 730 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_c; |
| 800 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_c; | 731 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_c; |
| 801 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_c; | 732 | |
| 802 | 733 | pCtx->pGetIChromaPredFunc[C_PRED_DC ] = WelsIChromaPredDc_c; | |
| 803 | pCtx->pGetIChromaPredFunc[C_PRED_DC ] = WelsIChromaPredDc_c; | 734 | pCtx->pGetIChromaPredFunc[C_PRED_H ] = WelsIChromaPredH_c; |
| 804 | pCtx->pGetIChromaPredFunc[C_PRED_H ] = WelsIChromaPredH_c; | 735 | pCtx->pGetIChromaPredFunc[C_PRED_V ] = WelsIChromaPredV_c; |
| 805 | pCtx->pGetIChromaPredFunc[C_PRED_V ] = WelsIChromaPredV_c; | 736 | pCtx->pGetIChromaPredFunc[C_PRED_P ] = WelsIChromaPredPlane_c; |
| 806 | pCtx->pGetIChromaPredFunc[C_PRED_P ] = WelsIChromaPredPlane_c; | 737 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsIChromaPredDcLeft_c; |
| 807 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsIChromaPredDcLeft_c; | 738 | pCtx->pGetIChromaPredFunc[C_PRED_DC_T ] = WelsIChromaPredDcTop_c; |
| 808 | pCtx->pGetIChromaPredFunc[C_PRED_DC_T ] = WelsIChromaPredDcTop_c; | 739 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c; |
| 809 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_c; | 740 | |
| 810 | 741 | InitDctClipTable(); | |
| 811 | InitDctClipTable(); | 742 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; |
| 812 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; | ||
| 813 | 743 | ||
| 814 | #if defined(X86_ASM) | 744 | #if defined(X86_ASM) |
| 815 | if ( pCtx->uiCpuFlag & WELS_CPU_MMXEXT ) | 745 | if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { |
| 816 | { | 746 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; |
| 817 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; | 747 | |
| 818 | 748 | /////////mmx code opt--- | |
| 819 | /////////mmx code opt--- | 749 | pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsIChromaPredH_mmx; |
| 820 | pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsIChromaPredH_mmx; | 750 | pCtx->pGetIChromaPredFunc[C_PRED_V] = WelsIChromaPredV_mmx; |
| 821 | pCtx->pGetIChromaPredFunc[C_PRED_V] = WelsIChromaPredV_mmx; | 751 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsIChromaPredDcLeft_mmx; |
| 822 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsIChromaPredDcLeft_mmx; | 752 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_mmx; |
| 823 | pCtx->pGetIChromaPredFunc[C_PRED_DC_128] = WelsIChromaPredDcNA_mmx; | 753 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDR] = WelsI4x4LumaPredDDR_mmx; |
| 824 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDR] = WelsI4x4LumaPredDDR_mmx; | 754 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_mmx; |
| 825 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_mmx; | 755 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_mmx; |
| 826 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_mmx; | 756 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VR ] = WelsI4x4LumaPredVR_mmx; |
| 827 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VR ] = WelsI4x4LumaPredVR_mmx; | 757 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsI4x4LumaPredDDL_mmx; |
| 828 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_DDL] = WelsI4x4LumaPredDDL_mmx; | 758 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsI4x4LumaPredVL_mmx; |
| 829 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_VL ] = WelsI4x4LumaPredVL_mmx; | 759 | } |
| 830 | } | 760 | if (pCtx->uiCpuFlag & WELS_CPU_SSE2) { |
| 831 | if ( pCtx->uiCpuFlag & WELS_CPU_SSE2 ) | 761 | /////////sse2 code opt--- |
| 832 | { | 762 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsI16x16LumaPredDc_sse2; |
| 833 | /////////sse2 code opt--- | 763 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsI16x16LumaPredPlane_sse2; |
| 834 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC] = WelsI16x16LumaPredDc_sse2; | 764 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H] = WelsI16x16LumaPredH_sse2; |
| 835 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_P] = WelsI16x16LumaPredPlane_sse2; | 765 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V] = WelsI16x16LumaPredV_sse2; |
| 836 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_H] = WelsI16x16LumaPredH_sse2; | 766 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_T ] = WelsI16x16LumaPredDcTop_sse2; |
| 837 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_V] = WelsI16x16LumaPredV_sse2; | 767 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_128] = WelsI16x16LumaPredDcNA_sse2; |
| 838 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_T ] = WelsI16x16LumaPredDcTop_sse2; | 768 | pCtx->pGetIChromaPredFunc[C_PRED_P ] = WelsIChromaPredPlane_sse2; |
| 839 | pCtx->pGetI16x16LumaPredFunc[I16_PRED_DC_128] = WelsI16x16LumaPredDcNA_sse2; | 769 | pCtx->pGetIChromaPredFunc[C_PRED_DC] = WelsIChromaPredDc_sse2; |
| 840 | pCtx->pGetIChromaPredFunc[C_PRED_P ] = WelsIChromaPredPlane_sse2; | 770 | pCtx->pGetIChromaPredFunc[C_PRED_DC_T] = WelsIChromaPredDcTop_sse2; |
| 841 | pCtx->pGetIChromaPredFunc[C_PRED_DC] = WelsIChromaPredDc_sse2; | 771 | } |
| 842 | pCtx->pGetIChromaPredFunc[C_PRED_DC_T] = WelsIChromaPredDcTop_sse2; | ||
| 843 | } | ||
| 844 | #endif | 772 | #endif |
| 845 | DeblockingInit(&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); | 773 | DeblockingInit (&pCtx->sDeblockingFunc, pCtx->uiCpuFlag); |
| 846 | 774 | ||
| 847 | WelsBlockFuncInit(&pCtx->sBlockFunc, pCtx->uiCpuFlag); | 775 | WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag); |
| 848 | } | 776 | } |
| 849 | 777 | ||
| 850 | } // namespace WelsDec | 778 | } // namespace WelsDec |