Extract bitrate allocation of spatial/temporal layers out of codec impl.
This CL makes a number of intervowen changes: * Add BitrateAllocation struct, that contains a codec independent view of how the target bitrate is distributed over spatial and temporal layers. * Adds the BitrateAllocator interface, which takes a bitrate and frame rate and produces a BitrateAllocation. * A default (non layered) implementation is added, and SimulcastRateAllocator is extended to fully handle VP8 allocation. This includes capturing TemporalLayer instances created by the encoder. * ViEEncoder now owns both the bitrate allocator and the temporal layer factories for VP8. This allows allocation to happen fully outside of the encoder implementation. This refactoring will make it possible for ViEEncoder to signal the full picture of target bitrates to the RTCP module. BUG=webrtc:6301 Review-Url: https://codereview.webrtc.org/2434073003 Cr-Commit-Position: refs/heads/master@{#14998}
This commit is contained in:
@ -152,6 +152,14 @@ static void RtpFragmentize(EncodedImage* encoded_image,
|
||||
|
||||
H264EncoderImpl::H264EncoderImpl()
|
||||
: openh264_encoder_(nullptr),
|
||||
width_(0),
|
||||
height_(0),
|
||||
max_frame_rate_(0.0f),
|
||||
target_bps_(0),
|
||||
max_bps_(0),
|
||||
mode_(kRealtimeVideo),
|
||||
frame_dropping_on_(false),
|
||||
key_frame_interval_(0),
|
||||
number_of_cores_(0),
|
||||
encoded_image_callback_(nullptr),
|
||||
has_reported_init_(false),
|
||||
@ -263,11 +271,13 @@ int32_t H264EncoderImpl::RegisterEncodeCompleteCallback(
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
int32_t H264EncoderImpl::SetRates(uint32_t bitrate, uint32_t framerate) {
|
||||
if (bitrate <= 0 || framerate <= 0) {
|
||||
int32_t H264EncoderImpl::SetRateAllocation(
|
||||
const BitrateAllocation& bitrate_allocation,
|
||||
uint32_t framerate) {
|
||||
if (bitrate_allocation.get_sum_bps() <= 0 || framerate <= 0)
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
target_bps_ = bitrate * 1000;
|
||||
|
||||
target_bps_ = bitrate_allocation.get_sum_bps();
|
||||
max_frame_rate_ = static_cast<float>(framerate);
|
||||
quality_scaler_.ReportFramerate(framerate);
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ class H264EncoderImpl : public H264Encoder {
|
||||
|
||||
int32_t RegisterEncodeCompleteCallback(
|
||||
EncodedImageCallback* callback) override;
|
||||
int32_t SetRates(uint32_t bitrate, uint32_t framerate) override;
|
||||
int32_t SetRateAllocation(const BitrateAllocation& bitrate_allocation,
|
||||
uint32_t framerate) override;
|
||||
|
||||
// The result of encoding - an EncodedImage and RTPFragmentationHeader - are
|
||||
// passed to the encode complete callback.
|
||||
@ -74,8 +75,8 @@ class H264EncoderImpl : public H264Encoder {
|
||||
int width_;
|
||||
int height_;
|
||||
float max_frame_rate_;
|
||||
unsigned int target_bps_;
|
||||
unsigned int max_bps_;
|
||||
uint32_t target_bps_;
|
||||
uint32_t max_bps_;
|
||||
VideoCodecMode mode_;
|
||||
// H.264 specifc parameters
|
||||
bool frame_dropping_on_;
|
||||
|
||||
Reference in New Issue
Block a user