| @@ -80,7 +80,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 79 unmodified lines |
| 80 | assert (pCfg != NULL); | 80 | assert (pCfg != NULL); |
| 81 | | 81 | |
| 82 | if ((pCfg->iUsageType != CAMERA_VIDEO_REAL_TIME) && (pCfg->iUsageType != SCREEN_CONTENT_REAL_TIME)) { | 82 | if ((pCfg->iUsageType != CAMERA_VIDEO_REAL_TIME) && (pCfg->iUsageType != SCREEN_CONTENT_REAL_TIME)) { |
| 83 | WelsLog (NULL, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d", pCfg->iUsageType); | 83 | WelsLog (NULL, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d\n", pCfg->iUsageType); |
| 84 | return ENC_RETURN_UNSUPPORTED_PARA; | 84 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 85 | } | 85 | } |
| 86 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { | 86 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { |
| @@ -113,15 +113,16 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 26 unmodified lines |
| 113 | } | 113 | } |
| 114 | | 114 | |
| 115 | //bitrate setting validation | 115 | //bitrate setting validation |
| 116 | if (pCfg->iRCMode != RC_OFF_MODE){ | 116 | if (pCfg->iRCMode != RC_OFF_MODE) { |
| 117 | int32_t iTotalBitrate = 0; | 117 | int32_t iTotalBitrate = 0; |
| 118 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { | 118 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { |
| 119 | SDLayerParam* fDlp = &pCfg->sDependencyLayers[i]; | 119 | SDLayerParam* fDlp = &pCfg->sDependencyLayers[i]; |
| 120 | iTotalBitrate += fDlp->iSpatialBitrate; | 120 | iTotalBitrate += fDlp->iSpatialBitrate; |
| 121 | } | 121 | } |
| 122 | if(iTotalBitrate > pCfg->iTargetBitrate){ | 122 | if (iTotalBitrate > pCfg->iTargetBitrate) { |
| 123 | WelsLog(NULL, WELS_LOG_ERROR,"Invalid setttings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n", | 123 | WelsLog (NULL, WELS_LOG_ERROR, |
| 124 | iTotalBitrate,pCfg->iTargetBitrate); | 124 | "Invalid setttings in bitrate. the sum of each layer bitrate(%d) is larger than total bitrate setting(%d)\n", |
| | 125 | iTotalBitrate, pCfg->iTargetBitrate); |
| 125 | } | 126 | } |
| 126 | } | 127 | } |
| 127 | | 128 | |
| @@ -1303,6 +1304,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 1175 unmodified lines |
| 1303 | (*ppCtx)->pOut->uiSize = iCountBsLen; | 1304 | (*ppCtx)->pOut->uiSize = iCountBsLen; |
| 1304 | (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); | 1305 | (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); |
| 1305 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) | 1306 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx)) |
| | 1307 | (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz(iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| | 1308 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc(ppCtx)) |
| 1306 | (*ppCtx)->pOut->iCountNals = iCountNals; | 1309 | (*ppCtx)->pOut->iCountNals = iCountNals; |
| 1307 | (*ppCtx)->pOut->iNalIndex = 0; | 1310 | (*ppCtx)->pOut->iNalIndex = 0; |
| 1308 | | 1311 | |
| @@ -1497,6 +1500,11 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 188 unmodified lines |
| 1497 | pMa->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList"); | 1500 | pMa->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList"); |
| 1498 | pCtx->pOut->sNalList = NULL; | 1501 | pCtx->pOut->sNalList = NULL; |
| 1499 | } | 1502 | } |
| | 1503 | // NALs len |
| | 1504 | if (NULL != pCtx->pOut->pNalLen) { |
| | 1505 | pMa->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); |
| | 1506 | pCtx->pOut->pNalLen = NULL; |
| | 1507 | } |
| 1500 | pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput"); | 1508 | pMa->WelsFree (pCtx->pOut, "SWelsEncoderOutput"); |
| 1501 | pCtx->pOut = NULL; | 1509 | pCtx->pOut = NULL; |
| 1502 | } | 1510 | } |
| @@ -2443,14 +2451,8 @@ bool SetMeMethod (const uint8_t uiMethod, PSearchMethodFunc& pSearchMethodFunc) · 940 unmodified lines |
| 2443 | pSearchMethodFunc = WelsDiamondCrossFeatureSearch; | 2451 | pSearchMethodFunc = WelsDiamondCrossFeatureSearch; |
| 2444 | break; | 2452 | break; |
| 2445 | case ME_FULL: | 2453 | case ME_FULL: |
| 2446 | #ifdef HAVE_MMX | | |
| 2447 | // make sure your cpu can support x86 sse4.1 instruction set if try it | | |
| 2448 | //pSearchMethodFunc = WelsFullSearch; | | |
| 2449 | #else | | |
| 2450 | pSearchMethodFunc = WelsDiamondSearch; | 2454 | pSearchMethodFunc = WelsDiamondSearch; |
| 2451 | return false; | 2455 | return false; |
| 2452 | #endif//HAVE_MMX | | |
| 2453 | break; | | |
| 2454 | default: | 2456 | default: |
| 2455 | pSearchMethodFunc = WelsDiamondSearch; | 2457 | pSearchMethodFunc = WelsDiamondSearch; |
| 2456 | return false; | 2458 | return false; |
| @@ -2772,7 +2774,6 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 315 unmodified lines |
| 2772 | iPayloadSize = pNalLen[*pNalIdxInLayer]; | 2774 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 2773 | | 2775 | |
| 2774 | pCtx->iPosBsBuffer += iPayloadSize; | 2776 | pCtx->iPosBsBuffer += iPayloadSize; |
| 2775 | pLayerBsInfo->iNalLengthInByte[*pNalIdxInLayer] = iPayloadSize; | | |
| 2776 | | 2777 | |
| 2777 | (*pNalIdxInLayer) ++; | 2778 | (*pNalIdxInLayer) ++; |
| 2778 | } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension | 2779 | } else { // No Prefix NAL Unit RBSP syntax here, but need add NAL Unit Header extension |
| @@ -2789,7 +2790,6 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 10 unmodified lines |
| 2789 | iPayloadSize = pNalLen[*pNalIdxInLayer]; | 2790 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 2790 | | 2791 | |
| 2791 | pCtx->iPosBsBuffer += iPayloadSize; | 2792 | pCtx->iPosBsBuffer += iPayloadSize; |
| 2792 | pLayerBsInfo->iNalLengthInByte[*pNalIdxInLayer] = iPayloadSize; | | |
| 2793 | | 2793 | |
| 2794 | (*pNalIdxInLayer) ++; | 2794 | (*pNalIdxInLayer) ++; |
| 2795 | } | 2795 | } |
| @@ -2855,13 +2855,13 @@ int32_t ForceCodingIDR (sWelsEncCtx* pCtx) { · 59 unmodified lines |
| 2855 | int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { | 2855 | int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { |
| 2856 | SFrameBSInfo* pFbi = (SFrameBSInfo*)pDst; | 2856 | SFrameBSInfo* pFbi = (SFrameBSInfo*)pDst; |
| 2857 | SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; | 2857 | SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; |
| 2858 | int32_t iNalLen[128] = {0}; | | |
| 2859 | int32_t iCountNal = 0; | 2858 | int32_t iCountNal = 0; |
| 2860 | | 2859 | |
| 2861 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs; | 2860 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs; |
| | 2861 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 2862 | InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize); | 2862 | InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize); |
| 2863 | | 2863 | |
| 2864 | int32_t iReturn = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal); | 2864 | int32_t iReturn = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal); |
| 2865 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 2865 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 2866 | | 2866 | |
| 2867 | pLayerBsInfo->uiPriorityId = 0; | 2867 | pLayerBsInfo->uiPriorityId = 0; |
| @@ -2870,9 +2870,6 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { · 2 unmodified lines |
| 2870 | pLayerBsInfo->uiQualityId = 0; | 2870 | pLayerBsInfo->uiQualityId = 0; |
| 2871 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | 2871 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; |
| 2872 | pLayerBsInfo->iNalCount = iCountNal; | 2872 | pLayerBsInfo->iNalCount = iCountNal; |
| 2873 | for (int32_t iNalIndex = 0; iNalIndex < iCountNal; ++ iNalIndex) { | | |
| 2874 | pLayerBsInfo->iNalLengthInByte[iNalIndex] = iNalLen[iNalIndex]; | | |
| 2875 | } | | |
| 2876 | | 2873 | |
| 2877 | pCtx->eLastNalPriority = NRI_PRI_HIGHEST; | 2874 | pCtx->eLastNalPriority = NRI_PRI_HIGHEST; |
| 2878 | pFbi->iLayerNum = 1; | 2875 | pFbi->iLayerNum = 1; |
| @@ -2904,7 +2901,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 25 unmodified lines |
| 2904 | int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame | 2901 | int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame |
| 2905 | int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame | 2902 | int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame |
| 2906 | int32_t iFrameSize = 0; | 2903 | int32_t iFrameSize = 0; |
| 2907 | int32_t iNalLen[128] = {0}; | | |
| 2908 | int32_t iNalIdxInLayer = 0; | 2904 | int32_t iNalIdxInLayer = 0; |
| 2909 | int32_t iCountNal = 0; | 2905 | int32_t iCountNal = 0; |
| 2910 | EVideoFrameType eFrameType = videoFrameTypeInvalid; | 2906 | EVideoFrameType eFrameType = videoFrameTypeInvalid; |
| @@ -2948,13 +2944,14 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 37 unmodified lines |
| 2948 | pCtx->uiTemporalId = iCurTid; | 2944 | pCtx->uiTemporalId = iCurTid; |
| 2949 | | 2945 | |
| 2950 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; | 2946 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs ; |
| | 2947 | pLayerBsInfo->pNalLengthInByte = pCtx->pOut->pNalLen; |
| 2951 | | 2948 | |
| 2952 | if (eFrameType == videoFrameTypeIDR) { | 2949 | if (eFrameType == videoFrameTypeIDR) { |
| 2953 | ++ pCtx->sPSOVector.uiIdrPicId; | 2950 | ++ pCtx->sPSOVector.uiIdrPicId; |
| 2954 | //if ( pSvcParam->bEnableSSEI ) | 2951 | //if ( pSvcParam->bEnableSSEI ) |
| 2955 | | 2952 | |
| 2956 | // write parameter sets bitstream here | 2953 | // write parameter sets bitstream here |
| 2957 | pCtx->iEncoderError = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal); | 2954 | pCtx->iEncoderError = WelsWriteParameterSets (pCtx, &pLayerBsInfo->pNalLengthInByte[0], &iCountNal); |
| 2958 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 2955 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 2959 | | 2956 | |
| 2960 | pLayerBsInfo->uiPriorityId = 0; | 2957 | pLayerBsInfo->uiPriorityId = 0; |
| @@ -2963,12 +2960,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2 unmodified lines |
| 2963 | pLayerBsInfo->uiQualityId = 0; | 2960 | pLayerBsInfo->uiQualityId = 0; |
| 2964 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | 2961 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; |
| 2965 | pLayerBsInfo->iNalCount = iCountNal; | 2962 | pLayerBsInfo->iNalCount = iCountNal; |
| 2966 | for (int32_t iNalIndex = 0; iNalIndex < iCountNal; ++ iNalIndex) { | | |
| 2967 | pLayerBsInfo->iNalLengthInByte[iNalIndex] = iNalLen[iNalIndex]; | | |
| 2968 | } | | |
| 2969 | | 2963 | |
| 2970 | ++ pLayerBsInfo; | 2964 | ++ pLayerBsInfo; |
| 2971 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 2965 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| | 2966 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 2972 | ++ iLayerNum; | 2967 | ++ iLayerNum; |
| 2973 | } | 2968 | } |
| 2974 | | 2969 | |
| @@ -3089,7 +3084,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 114 unmodified lines |
| 3089 | int32_t iPayloadSize = 0; | 3084 | int32_t iPayloadSize = 0; |
| 3090 | | 3085 | |
| 3091 | if (pCtx->bNeedPrefixNalFlag) { | 3086 | if (pCtx->bNeedPrefixNalFlag) { |
| 3092 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | 3087 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc, |
| 3093 | iPayloadSize); | 3088 | iPayloadSize); |
| 3094 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3089 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3095 | iLayerSize += iPayloadSize; | 3090 | iLayerSize += iPayloadSize; |
| @@ -3106,9 +3101,9 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 10 unmodified lines |
| 3106 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | 3101 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, |
| 3107 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | 3102 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, |
| 3108 | pCtx->pFrameBs + pCtx->iPosBsBuffer, | 3103 | pCtx->pFrameBs + pCtx->iPosBsBuffer, |
| 3109 | &iNalLen[iNalIdxInLayer]); | 3104 | &pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]); |
| 3110 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3105 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3111 | iSliceSize = iNalLen[iNalIdxInLayer]; | 3106 | iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; |
| 3112 | | 3107 | |
| 3113 | iLayerSize += iSliceSize; | 3108 | iLayerSize += iSliceSize; |
| 3114 | pCtx->iPosBsBuffer += iSliceSize; | 3109 | pCtx->iPosBsBuffer += iSliceSize; |
| @@ -3117,7 +3112,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 2 unmodified lines |
| 3117 | pLayerBsInfo->uiTemporalId = iCurTid; | 3112 | pLayerBsInfo->uiTemporalId = iCurTid; |
| 3118 | pLayerBsInfo->uiQualityId = 0; | 3113 | pLayerBsInfo->uiQualityId = 0; |
| 3119 | pLayerBsInfo->uiPriorityId = 0; | 3114 | pLayerBsInfo->uiPriorityId = 0; |
| 3120 | pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize; | | |
| 3121 | pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; | 3115 | pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; |
| 3122 | } | 3116 | } |
| 3123 | // for dynamic slicing single threading.. | 3117 | // for dynamic slicing single threading.. |
| @@ -3260,7 +3254,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 136 unmodified lines |
| 3260 | int32_t iSliceSize = 0; | 3254 | int32_t iSliceSize = 0; |
| 3261 | int32_t iPayloadSize = 0; | 3255 | int32_t iPayloadSize = 0; |
| 3262 | if (bNeedPrefix) { | 3256 | if (bNeedPrefix) { |
| 3263 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | 3257 | pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, eNalType, eNalRefIdc, |
| 3264 | iPayloadSize); | 3258 | iPayloadSize); |
| 3265 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3259 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3266 | iLayerSize += iPayloadSize; | 3260 | iLayerSize += iPayloadSize; |
| @@ -3275,13 +3269,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 8 unmodified lines |
| 3275 | pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], | 3269 | pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 3276 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | 3270 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, |
| 3277 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | 3271 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, |
| 3278 | pCtx->pFrameBs + pCtx->iPosBsBuffer, &iNalLen[iNalIdxInLayer]); | 3272 | pCtx->pFrameBs + pCtx->iPosBsBuffer, &pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]); |
| 3279 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | 3273 | WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) |
| 3280 | iSliceSize = iNalLen[iNalIdxInLayer]; | 3274 | iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; |
| 3281 | | 3275 | |
| 3282 | pCtx->iPosBsBuffer += iSliceSize; | 3276 | pCtx->iPosBsBuffer += iSliceSize; |
| 3283 | iLayerSize += iSliceSize; | 3277 | iLayerSize += iSliceSize; |
| 3284 | pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize; | | |
| 3285 | | 3278 | |
| 3286 | #if defined(SLICE_INFO_OUTPUT) | 3279 | #if defined(SLICE_INFO_OUTPUT) |
| 3287 | fprintf (stderr, | 3280 | fprintf (stderr, |
| @@ -3413,10 +3406,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 125 unmodified lines |
| 3413 | } | 3406 | } |
| 3414 | #endif//STAT_OUTPUT | 3407 | #endif//STAT_OUTPUT |
| 3415 | | 3408 | |
| | 3409 | iCountNal = pLayerBsInfo->iNalCount; |
| 3416 | ++ iLayerNum; | 3410 | ++ iLayerNum; |
| 3417 | ++ pLayerBsInfo; | 3411 | ++ pLayerBsInfo; |
| 3418 | | 3412 | |
| 3419 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3413 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| | 3414 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + iCountNal; |
| 3420 | | 3415 | |
| 3421 | if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { | 3416 | if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { |
| 3422 | int32_t iPaddingNalSize = 0; | 3417 | int32_t iPaddingNalSize = 0; |
| @@ -3440,9 +3435,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 17 unmodified lines |
| 3440 | pLayerBsInfo->uiQualityId = 0; | 3435 | pLayerBsInfo->uiQualityId = 0; |
| 3441 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; | 3436 | pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER; |
| 3442 | pLayerBsInfo->iNalCount = 1; | 3437 | pLayerBsInfo->iNalCount = 1; |
| 3443 | pLayerBsInfo->iNalLengthInByte[0] = iPaddingNalSize; | 3438 | pLayerBsInfo->pNalLengthInByte[0] = iPaddingNalSize; |
| 3444 | ++ pLayerBsInfo; | 3439 | ++ pLayerBsInfo; |
| 3445 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; | 3440 | pLayerBsInfo->pBsBuf = pCtx->pFrameBs + pCtx->iPosBsBuffer; |
| | 3441 | pLayerBsInfo->pNalLengthInByte = (pLayerBsInfo - 1)->pNalLengthInByte + 1; |
| 3446 | ++ iLayerNum; | 3442 | ++ iLayerNum; |
| 3447 | } | 3443 | } |
| 3448 | | 3444 | |
| @@ -3696,7 +3692,6 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 247 unmodified lines |
| 3696 | | 3692 | |
| 3697 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | 3693 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 3698 | SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; | 3694 | SSliceCtx* pSliceCtx = pCurLayer->pSliceEncCtx; |
| 3699 | int32_t iNalLen[MAX_NAL_UNITS_IN_LAYER] = {0}; | | |
| 3700 | int32_t iNalIdxInLayer = *pNalIdxInLayer; | 3695 | int32_t iNalIdxInLayer = *pNalIdxInLayer; |
| 3701 | int32_t iSliceIdx = iStartSliceIdx; | 3696 | int32_t iSliceIdx = iStartSliceIdx; |
| 3702 | const int32_t kiSliceStep = pCtx->iActiveThreadsNum; | 3697 | const int32_t kiSliceStep = pCtx->iActiveThreadsNum; |
| @@ -3727,7 +3722,7 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 24 unmodified lines |
| 3727 | } | 3722 | } |
| 3728 | | 3723 | |
| 3729 | if (kbNeedPrefix) { | 3724 | if (kbNeedPrefix) { |
| 3730 | iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize); | 3725 | iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &pLayerBsInfo->pNalLengthInByte[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize); |
| 3731 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3726 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3732 | iPartitionBsSize += iPayloadSize; | 3727 | iPartitionBsSize += iPayloadSize; |
| 3733 | } | 3728 | } |
| @@ -3741,13 +3736,12 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 7 unmodified lines |
| 3741 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | 3736 | &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, |
| 3742 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | 3737 | pCtx->iFrameBsSize - pCtx->iPosBsBuffer, |
| 3743 | pCtx->pFrameBs + pCtx->iPosBsBuffer, | 3738 | pCtx->pFrameBs + pCtx->iPosBsBuffer, |
| 3744 | &iNalLen[iNalIdxInLayer]); | 3739 | &pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]); |
| 3745 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | 3740 | WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) |
| 3746 | iSliceSize = iNalLen[iNalIdxInLayer]; | 3741 | iSliceSize = pLayerBsInfo->pNalLengthInByte[iNalIdxInLayer]; |
| 3747 | | 3742 | |
| 3748 | pCtx->iPosBsBuffer += iSliceSize; | 3743 | pCtx->iPosBsBuffer += iSliceSize; |
| 3749 | iPartitionBsSize += iSliceSize; | 3744 | iPartitionBsSize += iSliceSize; |
| 3750 | pLayerBsInfo->iNalLengthInByte[iNalIdxInLayer] = iSliceSize; | | |
| 3751 | | 3745 | |
| 3752 | #if defined(SLICE_INFO_OUTPUT) | 3746 | #if defined(SLICE_INFO_OUTPUT) |
| 3753 | fprintf (stderr, | 3747 | fprintf (stderr, |