| 697 | } |
| 698 | |
| 699 | int32_t WelsEncoderApplyBitRate (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int iLayer) { |
| 700 | //TODO (Sijia): this is a temporary solution which keep the ratio between layers |
| 701 | //but it is also possible to fulfill the bitrate of lower layer first |
| 702 | |
| 703 | SSpatialLayerConfig* pLayerParam; |
| 704 | const int32_t iNumLayers = pParam->iSpatialLayerNum; |
| 705 | int32_t i, iOrigTotalBitrate = 0; |
| 706 | if (iLayer == SPATIAL_LAYER_ALL) { |
| 707 | //read old BR |
| 708 | for (i = 0; i < iNumLayers; i++) { |
| 709 | iOrigTotalBitrate += pParam->sSpatialLayers[i].iSpatialBitrate; |
| 710 | } |
| 711 | //write new BR |
| 712 | float fRatio = 0.0; |
| 713 | for (i = 0; i < iNumLayers; i++) { |
| 714 | pLayerParam = & (pParam->sSpatialLayers[i]); |
| 715 | fRatio = pLayerParam->iSpatialBitrate / (static_cast<float> (iOrigTotalBitrate)); |
| 716 | pLayerParam->iSpatialBitrate = static_cast<int32_t> (pParam->iTargetBitrate * fRatio); |
| 717 | |
| 718 | if (WelsBitRateVerification (pLogCtx, pLayerParam, i) != ENC_RETURN_SUCCESS) |
| 719 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 720 | } |
| 721 | } else { |
| 722 | return WelsBitRateVerification (pLogCtx, & (pParam->sSpatialLayers[iLayer]), iLayer); |
| 723 | } |
| 724 | return ENC_RETURN_SUCCESS; |
| 725 | } |
| 726 | int32_t WelsEncoderApplyBitVaryRang (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, int32_t iRang) { |
| 727 | SSpatialLayerConfig* pLayerParam; |
| 728 | const int32_t iNumLayers = pParam->iSpatialLayerNum; |
no test coverage detected