Revert "Replace usage of old SetRates/SetRateAllocation methods"
This reverts commit 7ac0d5f348f0b956089c4ed65c46e65bac125508. Reason for revert: <INSERT REASONING HERE> Original change's description: > Replace usage of old SetRates/SetRateAllocation methods > > This rather large CL replaces all relevant usage of the old > VideoEncoder::SetRates()/SetRateAllocation() methods in WebRTC. > API is unchanged to allow downstream projects to update without > breakage. > > Bug: webrtc:10481 > Change-Id: Iab8f292ce6be6c3f5056a239d26361962b14bb38 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131949 > Commit-Queue: Erik Språng <sprang@webrtc.org> > Reviewed-by: Per Kjellander <perkj@webrtc.org> > Reviewed-by: Niels Moller <nisse@webrtc.org> > Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27554} TBR=brandtr@webrtc.org,sakal@webrtc.org,nisse@webrtc.org,sprang@webrtc.org,perkj@webrtc.org Change-Id: I576760b584e3f258013b0279c0c173c895bbb37e No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:10481 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132561 Reviewed-by: Minyue Li <minyue@webrtc.org> Commit-Queue: Minyue Li <minyue@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27559}
This commit is contained in:
@ -306,8 +306,7 @@ int32_t H264EncoderImpl::InitEncode(const VideoCodec* inst,
|
||||
SimulcastRateAllocator init_allocator(codec_);
|
||||
VideoBitrateAllocation allocation = init_allocator.GetAllocation(
|
||||
codec_.startBitrate * 1000, codec_.maxFramerate);
|
||||
SetRates(RateControlParameters(allocation, codec_.maxFramerate));
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
return SetRateAllocation(allocation, codec_.maxFramerate);
|
||||
}
|
||||
|
||||
int32_t H264EncoderImpl::Release() {
|
||||
@ -332,40 +331,36 @@ int32_t H264EncoderImpl::RegisterEncodeCompleteCallback(
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
void H264EncoderImpl::SetRates(const RateControlParameters& parameters) {
|
||||
if (encoders_.empty()) {
|
||||
RTC_LOG(LS_WARNING) << "SetRates() while uninitialized.";
|
||||
return;
|
||||
}
|
||||
int32_t H264EncoderImpl::SetRateAllocation(
|
||||
const VideoBitrateAllocation& bitrate,
|
||||
uint32_t new_framerate) {
|
||||
if (encoders_.empty())
|
||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||
|
||||
if (parameters.framerate_fps < 1.0) {
|
||||
RTC_LOG(LS_WARNING) << "Invalid frame rate: " << parameters.framerate_fps;
|
||||
return;
|
||||
}
|
||||
if (new_framerate < 1)
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
|
||||
if (parameters.bitrate.get_sum_bps() == 0) {
|
||||
if (bitrate.get_sum_bps() == 0) {
|
||||
// Encoder paused, turn off all encoding.
|
||||
for (size_t i = 0; i < configurations_.size(); ++i)
|
||||
configurations_[i].SetStreamState(false);
|
||||
return;
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
// At this point, bitrate allocation should already match codec settings.
|
||||
if (codec_.maxBitrate > 0)
|
||||
RTC_DCHECK_LE(parameters.bitrate.get_sum_kbps(), codec_.maxBitrate);
|
||||
RTC_DCHECK_GE(parameters.bitrate.get_sum_kbps(), codec_.minBitrate);
|
||||
RTC_DCHECK_LE(bitrate.get_sum_kbps(), codec_.maxBitrate);
|
||||
RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.minBitrate);
|
||||
if (codec_.numberOfSimulcastStreams > 0)
|
||||
RTC_DCHECK_GE(parameters.bitrate.get_sum_kbps(),
|
||||
codec_.simulcastStream[0].minBitrate);
|
||||
RTC_DCHECK_GE(bitrate.get_sum_kbps(), codec_.simulcastStream[0].minBitrate);
|
||||
|
||||
codec_.maxFramerate = static_cast<uint32_t>(parameters.framerate_fps);
|
||||
codec_.maxFramerate = new_framerate;
|
||||
|
||||
size_t stream_idx = encoders_.size() - 1;
|
||||
for (size_t i = 0; i < encoders_.size(); ++i, --stream_idx) {
|
||||
// Update layer config.
|
||||
configurations_[i].target_bps =
|
||||
parameters.bitrate.GetSpatialLayerSum(stream_idx);
|
||||
configurations_[i].max_frame_rate = parameters.framerate_fps;
|
||||
configurations_[i].target_bps = bitrate.GetSpatialLayerSum(stream_idx);
|
||||
configurations_[i].max_frame_rate = static_cast<float>(new_framerate);
|
||||
|
||||
if (configurations_[i].target_bps) {
|
||||
configurations_[i].SetStreamState(true);
|
||||
@ -382,6 +377,8 @@ void H264EncoderImpl::SetRates(const RateControlParameters& parameters) {
|
||||
configurations_[i].SetStreamState(false);
|
||||
}
|
||||
}
|
||||
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
int32_t H264EncoderImpl::Encode(
|
||||
|
Reference in New Issue
Block a user