Don't configure SVC params without per layer bitrate configured.
Change-Id: Ieb200ce1a710078e380047ed8af73db0c5e0c751 Bug: none Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239442 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35457}
This commit is contained in:
@ -108,6 +108,7 @@ class LibaomAv1Encoder final : public VideoEncoder {
|
|||||||
|
|
||||||
std::unique_ptr<ScalableVideoController> svc_controller_;
|
std::unique_ptr<ScalableVideoController> svc_controller_;
|
||||||
bool inited_;
|
bool inited_;
|
||||||
|
bool rates_configured_;
|
||||||
absl::optional<aom_svc_params_t> svc_params_;
|
absl::optional<aom_svc_params_t> svc_params_;
|
||||||
VideoCodec encoder_settings_;
|
VideoCodec encoder_settings_;
|
||||||
aom_image_t* frame_for_encode_;
|
aom_image_t* frame_for_encode_;
|
||||||
@ -143,6 +144,7 @@ int32_t VerifyCodecSettings(const VideoCodec& codec_settings) {
|
|||||||
|
|
||||||
LibaomAv1Encoder::LibaomAv1Encoder()
|
LibaomAv1Encoder::LibaomAv1Encoder()
|
||||||
: inited_(false),
|
: inited_(false),
|
||||||
|
rates_configured_(false),
|
||||||
frame_for_encode_(nullptr),
|
frame_for_encode_(nullptr),
|
||||||
encoded_image_callback_(nullptr) {}
|
encoded_image_callback_(nullptr) {}
|
||||||
|
|
||||||
@ -283,15 +285,6 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
|
|||||||
<< " on control AV1E_SET_AQ_MODE.";
|
<< " on control AV1E_SET_AQ_MODE.";
|
||||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
return WEBRTC_VIDEO_CODEC_ERROR;
|
||||||
}
|
}
|
||||||
if (SvcEnabled()) {
|
|
||||||
ret = aom_codec_control(&ctx_, AV1E_SET_SVC_PARAMS, &*svc_params_);
|
|
||||||
if (ret != AOM_CODEC_OK) {
|
|
||||||
RTC_LOG(LS_WARNING) << "LibaomAV1Encoder::EncodeInit returned " << ret
|
|
||||||
<< " on control AV1E_SET_SVC_PARAMS.";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = aom_codec_control(&ctx_, AOME_SET_MAX_INTRA_BITRATE_PCT, 300);
|
ret = aom_codec_control(&ctx_, AOME_SET_MAX_INTRA_BITRATE_PCT, 300);
|
||||||
if (ret != AOM_CODEC_OK) {
|
if (ret != AOM_CODEC_OK) {
|
||||||
RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::EncodeInit returned " << ret
|
RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::EncodeInit returned " << ret
|
||||||
@ -558,13 +551,14 @@ int32_t LibaomAv1Encoder::Release() {
|
|||||||
}
|
}
|
||||||
inited_ = false;
|
inited_ = false;
|
||||||
}
|
}
|
||||||
|
rates_configured_ = false;
|
||||||
return WEBRTC_VIDEO_CODEC_OK;
|
return WEBRTC_VIDEO_CODEC_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t LibaomAv1Encoder::Encode(
|
int32_t LibaomAv1Encoder::Encode(
|
||||||
const VideoFrame& frame,
|
const VideoFrame& frame,
|
||||||
const std::vector<VideoFrameType>* frame_types) {
|
const std::vector<VideoFrameType>* frame_types) {
|
||||||
if (!inited_ || encoded_image_callback_ == nullptr) {
|
if (!inited_ || encoded_image_callback_ == nullptr || !rates_configured_) {
|
||||||
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -797,6 +791,8 @@ void LibaomAv1Encoder::SetRates(const RateControlParameters& parameters) {
|
|||||||
aom_codec_control(&ctx_, AV1E_SET_SVC_PARAMS, &*svc_params_);
|
aom_codec_control(&ctx_, AV1E_SET_SVC_PARAMS, &*svc_params_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rates_configured_ = true;
|
||||||
|
|
||||||
// Set frame rate to closest integer value.
|
// Set frame rate to closest integer value.
|
||||||
encoder_settings_.maxFramerate =
|
encoder_settings_.maxFramerate =
|
||||||
static_cast<uint32_t>(parameters.framerate_fps + 0.5);
|
static_cast<uint32_t>(parameters.framerate_fps + 0.5);
|
||||||
|
|||||||
@ -137,6 +137,11 @@ TEST(LibaomAv1Test, EncodeDecode) {
|
|||||||
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
|
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
|
||||||
WEBRTC_VIDEO_CODEC_OK);
|
WEBRTC_VIDEO_CODEC_OK);
|
||||||
|
|
||||||
|
VideoBitrateAllocation allocation;
|
||||||
|
allocation.SetBitrate(0, 0, 300000);
|
||||||
|
encoder->SetRates(VideoEncoder::RateControlParameters(
|
||||||
|
allocation, codec_settings.maxFramerate));
|
||||||
|
|
||||||
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
|
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
|
||||||
EncodedVideoFrameProducer(*encoder).SetNumInputFrames(4).Encode();
|
EncodedVideoFrameProducer(*encoder).SetNumInputFrames(4).Encode();
|
||||||
for (size_t frame_id = 0; frame_id < encoded_frames.size(); ++frame_id) {
|
for (size_t frame_id = 0; frame_id < encoded_frames.size(); ++frame_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user