Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 1 file). Show all
Unified · Split
| @@ -378,14 +378,16 @@ int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSIn · 377 unmodified lines | ||
| 378 | 378 | return cmInitParaError; |
| 379 | 379 | } |
| 380 | 380 | if (kpSrcPic->iColorFormat != videoFormatI420) { |
| 381 | − WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::EncodeFrame(), wrong iColorFormat %d", kpSrcPic->iColorFormat); | |
| 381 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::EncodeFrame(), wrong iColorFormat %d", | |
| 382 | + kpSrcPic->iColorFormat); | |
| 382 | 383 | return cmInitParaError; |
| 383 | 384 | } |
| 384 | 385 | |
| 385 | 386 | const int32_t kiEncoderReturn = EncodeFrameInternal (kpSrcPic, pBsInfo); |
| 386 | 387 | |
| 387 | 388 | if (kiEncoderReturn != cmResultSuccess) { |
| 388 | − WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::EncodeFrame(), kiEncoderReturn %d", kiEncoderReturn); | |
| 389 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsH264SVCEncoder::EncodeFrame(), kiEncoderReturn %d", | |
| 390 | + kiEncoderReturn); | |
| 389 | 391 | return kiEncoderReturn; |
| 390 | 392 | } |
| 391 | 393 | |
| @@ -644,11 +646,10 @@ void CWelsH264SVCEncoder::UpdateStatistics (SFrameBSInfo* pBsInfo, · 252 unmodified lines | ||
| 644 | 646 | pStatistics->iLastStatisticsFrameCount); |
| 645 | 647 | if (kiDeltaFrames > (m_pEncContext->pSvcParam->fMaxFrameRate * 2)) { |
| 646 | 648 | if (kiTimeDiff >= m_pEncContext->iStatisticsLogInterval) { |
| 649 | + float fTimeDiffSec = kiTimeDiff / 1000.0; | |
| 647 | 650 | pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount - |
| 648 | − pStatistics->iLastStatisticsFrameCount) * 1000 / | |
| 649 | − kiTimeDiff); | |
| 650 | − pStatistics->uiBitRate = static_cast<unsigned int> ((pStatistics->iTotalEncodedBytes - | |
| 651 | − pStatistics->iLastStatisticsBytes) * 8 * 1000 / kiTimeDiff); | |
| 651 | + pStatistics->iLastStatisticsFrameCount) / fTimeDiffSec); | |
| 652 | + pStatistics->uiBitRate = static_cast<unsigned int> ((pStatistics->iTotalEncodedBytes) * 8 / fTimeDiffSec); | |
| 652 | 653 | |
| 653 | 654 | if (WELS_ABS (pStatistics->fLatestFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 30) { |
| 654 | 655 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, |
| @@ -669,26 +670,15 @@ void CWelsH264SVCEncoder::UpdateStatistics (SFrameBSInfo* pBsInfo, · 14 unmodified lines | ||
| 669 | 670 | // update variables |
| 670 | 671 | pStatistics->iLastStatisticsBytes = pStatistics->iTotalEncodedBytes; |
| 671 | 672 | pStatistics->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount; |
| 672 | − | |
| 673 | + m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 674 | + LogStatistics (kiCurrentFrameTs, iMaxDid); | |
| 675 | + pStatistics->iTotalEncodedBytes = 0; | |
| 673 | 676 | //TODO: the following statistics will be calculated and added later |
| 674 | 677 | //pStatistics->uiLTRSentNum |
| 675 | 678 | |
| 676 | 679 | } |
| 677 | 680 | } |
| 678 | 681 | } |
| 679 | − if (((m_pEncContext->iStatisticsLogInterval > 0) && (kiTimeDiff >= m_pEncContext->iStatisticsLogInterval)) | |
| 680 | − || (0 == iMaxInputFrame % 300)) { | |
| 681 | − | |
| 682 | − if ((iMaxFrameRate > 0) && WELS_ABS (iMaxFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 30) { | |
| 683 | − WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, | |
| 684 | − "Actual input framerate fAverageFrameRate = %f is quite different from framerate in setting %f, please check setting or timestamp unit (ms), start_Ts = %" | |
| 685 | − PRId64, | |
| 686 | − iMaxFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate, m_pEncContext->uiStartTimestamp); | |
| 687 | − } | |
| 688 | − | |
| 689 | − LogStatistics (kiCurrentFrameTs, iMaxDid); | |
| 690 | − m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 691 | − } | |
| 692 | 682 | |
| 693 | 683 | } |
| 694 | 684 | |
| @@ -727,7 +717,7 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 32 unmodified lines | ||
| 727 | 717 | int32_t iValue = * ((int32_t*)pOption); |
| 728 | 718 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 729 | 719 | "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IDR_INTERVAL iValue = %d", iValue); |
| 730 | − if ( iValue <= -1 ) { | |
| 720 | + if (iValue <= -1) { | |
| 731 | 721 | iValue = 0; |
| 732 | 722 | } |
| 733 | 723 | if (iValue == (int32_t)m_pEncContext->pSvcParam->uiIntraPeriod) { |
| @@ -735,7 +725,8 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 1 unmodified line | ||
| 735 | 725 | } |
| 736 | 726 | m_pEncContext->pSvcParam->uiIntraPeriod = (uint32_t)iValue; |
| 737 | 727 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 738 | − "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IDR_INTERVAL uiIntraPeriod updated to %d", m_pEncContext->pSvcParam->uiIntraPeriod); | |
| 728 | + "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_IDR_INTERVAL uiIntraPeriod updated to %d", | |
| 729 | + m_pEncContext->pSvcParam->uiIntraPeriod); | |
| 739 | 730 | } |
| 740 | 731 | break; |
| 741 | 732 | case ENCODER_OPTION_SVC_ENCODE_PARAM_BASE: { // SVC Encoding Parameter |