@@ -3445,9 +3445,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
3445
3445
SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo [0 ];
3446
3446
SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam ;
3447
3447
SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap [0 ];
3448
- #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC)
3449
3448
SPicture* fsnr = NULL ;
3450
- #endif // ENABLE_FRAME_DUMP || ENABLE_PSNR_CALC
3451
3449
SPicture* pEncPic = NULL ; // to be decided later
3452
3450
#if defined(MT_DEBUG)
3453
3451
int32_t iDidList[MAX_DEPENDENCY_LAYER] = {0 };
@@ -3469,9 +3467,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
3469
3467
int32_t iCurTid = 0 ;
3470
3468
bool bAvcBased = false ;
3471
3469
SLogContext* pLogCtx = & (pCtx->sLogCtx );
3472
- #if defined(ENABLE_PSNR_CALC)
3473
3470
float fSnrY = .0f , fSnrU = .0f , fSnrV = .0f ;
3474
- #endif // ENABLE_PSNR_CALC
3475
3471
3476
3472
#if defined(_DEBUG)
3477
3473
int32_t i = 0 , j = 0 , k = 0 ;
@@ -3624,9 +3620,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
3624
3620
pCtx->eNalPriority = eNalRefIdc;
3625
3621
3626
3622
pCtx->pDecPic = pCtx->ppRefPicListExt [iCurDid]->pNextBuffer ;
3627
- #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC)
3628
3623
fsnr = pCtx->pDecPic ;
3629
- #endif // #if defined(ENABLE_FRAME_DUMP) || defined(ENABLE_PSNR_CALC)
3630
3624
pCtx->pDecPic ->iPictureType = pCtx->eSliceType ;
3631
3625
pCtx->pDecPic ->iFramePoc = pParamInternal->iPOC ;
3632
3626
@@ -3921,26 +3915,30 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
3921
3915
}
3922
3916
#endif // ENABLE_FRAME_DUMP
3923
3917
3924
- #if defined(ENABLE_PSNR_CALC)
3925
- fSnrY = WelsCalcPsnr (fsnr->pData [0 ],
3926
- fsnr->iLineSize [0 ],
3927
- pEncPic->pData [0 ],
3928
- pEncPic->iLineSize [0 ],
3929
- iCurWidth,
3930
- iCurHeight);
3931
- fSnrU = WelsCalcPsnr (fsnr->pData [1 ],
3932
- fsnr->iLineSize [1 ],
3933
- pEncPic->pData [1 ],
3934
- pEncPic->iLineSize [1 ],
3935
- (iCurWidth >> 1 ),
3936
- (iCurHeight >> 1 ));
3937
- fSnrV = WelsCalcPsnr (fsnr->pData [2 ],
3938
- fsnr->iLineSize [2 ],
3939
- pEncPic->pData [2 ],
3940
- pEncPic->iLineSize [2 ],
3941
- (iCurWidth >> 1 ),
3942
- (iCurHeight >> 1 ));
3943
- #endif // ENABLE_PSNR_CALC
3918
+ if (fsnr && (pSvcParam->bPsnrY || pSrcPic->bPsnrY )) {
3919
+ fSnrY = WelsCalcPsnr (fsnr->pData [0 ],
3920
+ fsnr->iLineSize [0 ],
3921
+ pEncPic->pData [0 ],
3922
+ pEncPic->iLineSize [0 ],
3923
+ iCurWidth,
3924
+ iCurHeight);
3925
+ }
3926
+ if (fsnr && (pSvcParam->bPsnrU || pSrcPic->bPsnrU )) {
3927
+ fSnrU = WelsCalcPsnr (fsnr->pData [1 ],
3928
+ fsnr->iLineSize [1 ],
3929
+ pEncPic->pData [1 ],
3930
+ pEncPic->iLineSize [1 ],
3931
+ (iCurWidth >> 1 ),
3932
+ (iCurHeight >> 1 ));
3933
+ }
3934
+ if (fsnr && (pSvcParam->bPsnrV || pSrcPic->bPsnrV )) {
3935
+ fSnrV = WelsCalcPsnr (fsnr->pData [2 ],
3936
+ fsnr->iLineSize [2 ],
3937
+ pEncPic->pData [2 ],
3938
+ pEncPic->iLineSize [2 ],
3939
+ (iCurWidth >> 1 ),
3940
+ (iCurHeight >> 1 ));
3941
+ }
3944
3942
3945
3943
#if defined(LAYER_INFO_OUTPUT)
3946
3944
fprintf (stderr, " %2s %5d: %-5d %2s T%1d D%1d Q%-2d QP%3d Y%2.2f U%2.2f V%2.2f %8d bits\n " ,
@@ -3960,13 +3958,29 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
3960
3958
3961
3959
#if defined(STAT_OUTPUT)
3962
3960
3963
- #if defined(ENABLE_PSNR_CALC)
3964
3961
{
3965
- pCtx->sStatData [iCurDid][0 ].sQualityStat .rYPsnr [pCtx->eSliceType ] += fSnrY ;
3966
- pCtx->sStatData [iCurDid][0 ].sQualityStat .rUPsnr [pCtx->eSliceType ] += fSnrU ;
3967
- pCtx->sStatData [iCurDid][0 ].sQualityStat .rVPsnr [pCtx->eSliceType ] += fSnrV ;
3962
+ if (pSvcParam->bPsnrY ) {
3963
+ pCtx->sStatData [iCurDid][0 ].sQualityStat .rYPsnr [pCtx->eSliceType ] += fSnrY ;
3964
+ }
3965
+ if (pSvcParam->bPsnrU ) {
3966
+ pCtx->sStatData [iCurDid][0 ].sQualityStat .rUPsnr [pCtx->eSliceType ] += fSnrU ;
3967
+ }
3968
+ if (pSvcParam->bPsnrV ) {
3969
+ pCtx->sStatData [iCurDid][0 ].sQualityStat .rVPsnr [pCtx->eSliceType ] += fSnrV ;
3970
+ }
3971
+ }
3972
+ pLayerBsInfo->rPsnr [0 ] = NAN;
3973
+ pLayerBsInfo->rPsnr [1 ] = NAN;
3974
+ pLayerBsInfo->rPsnr [2 ] = NAN;
3975
+ if (pSrcPic->bPsnrY ) {
3976
+ pLayerBsInfo->rPsnr [0 ] = fSnrY ;
3977
+ }
3978
+ if (pSrcPic->bPsnrU ) {
3979
+ pLayerBsInfo->rPsnr [1 ] = fSnrU ;
3980
+ }
3981
+ if (pSrcPic->bPsnrV ) {
3982
+ pLayerBsInfo->rPsnr [2 ] = fSnrV ;
3968
3983
}
3969
- #endif // ENABLE_PSNR_CALC
3970
3984
3971
3985
#if defined(MB_TYPES_CHECK) // 091025, frame output
3972
3986
if (pCtx->eSliceType == P_SLICE) {
0 commit comments