Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 4 files). Show all
Unified · Split
| @@ -942,19 +942,27 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) { · 941 unmodified lines | ||
| 942 | 942 | "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_FRAME_RATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %d\n", |
| 943 | 943 | m_uiCountFrameNum, m_iCspInternal, iValue); |
| 944 | 944 | #endif//REC_FRAME_COUNT |
| 945 | − m_pEncContext->pSvcParam->fMaxFrameRate = iValue; | |
| 946 | − | |
| 945 | + if (iValue<=0) { | |
| 946 | + return cmInitParaError; | |
| 947 | + } | |
| 948 | + //adjust to valid range | |
| 949 | + m_pEncContext->pSvcParam->fMaxFrameRate = WELS_CLIP3 (iValue, MIN_FRAME_RATE, MAX_FRAME_RATE); | |
| 950 | + WelsEncoderApplyFrameRate (m_pEncContext->pSvcParam); | |
| 947 | 951 | } |
| 948 | 952 | break; |
| 949 | 953 | case ENCODER_OPTION_BITRATE: { // Target bit-rate |
| 950 | 954 | int32_t iValue = * ((int32_t*)pOption); |
| 951 | 955 | #ifdef REC_FRAME_COUNT |
| 952 | 956 | WelsLog (m_pEncContext, WELS_LOG_INFO, |
| 953 | − "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %d\n", | |
| 954 | − m_uiCountFrameNum, m_iCspInternal, iValue); | |
| 957 | + "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE, m_uiCountFrameNum= %d, m_iCspInternal= 0x%x, iValue= %d\n", | |
| 958 | + m_uiCountFrameNum, m_iCspInternal, iValue); | |
| 955 | 959 | #endif//REC_FRAME_COUNT |
| 956 | − m_pEncContext->pSvcParam->iTargetBitrate = iValue; | |
| 957 | − | |
| 960 | + if (iValue<=0) { | |
| 961 | + return cmInitParaError; | |
| 962 | + } | |
| 963 | + //adjust to valid range | |
| 964 | + m_pEncContext->pSvcParam->iTargetBitrate = WELS_CLIP3 (iValue, MIN_BIT_RATE, MAX_BIT_RATE); | |
| 965 | + WelsEncoderApplyBitRate (m_pEncContext->pSvcParam); | |
| 958 | 966 | } |
| 959 | 967 | break; |
| 960 | 968 | case ENCODER_OPTION_RC_MODE: { // 0:quality mode;1:bit-rate mode |