Set rates for av1 svc tests

Bug: webrtc:11404
Change-Id: I79c4cee99d1bee1cdd3a8e0f901fadc6178a07a6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235602
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Jerome Jiang <jianj@google.com>
Cr-Commit-Position: refs/heads/main@{#35250}
This commit is contained in:
Jerome Jiang
2021-10-19 11:03:19 -07:00
committed by WebRTC LUCI CQ
parent 1f30c2ba9b
commit f33fc35277
2 changed files with 47 additions and 4 deletions

View File

@ -86,13 +86,22 @@ TEST(LibaomAv1EncoderTest, NoBitrateOnTopLayerRefecltedInActiveDecodeTargets) {
} }
TEST(LibaomAv1EncoderTest, SetsEndOfPictureForLastFrameInTemporalUnit) { TEST(LibaomAv1EncoderTest, SetsEndOfPictureForLastFrameInTemporalUnit) {
VideoBitrateAllocation allocation;
allocation.SetBitrate(0, 0, 30000);
allocation.SetBitrate(1, 0, 40000);
allocation.SetBitrate(2, 0, 30000);
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder(); std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
VideoCodec codec_settings = DefaultCodecSettings(); VideoCodec codec_settings = DefaultCodecSettings();
// Configure encoder with 3 spatial layers. // Configure encoder with 3 spatial layers.
codec_settings.SetScalabilityMode("L3T1"); codec_settings.SetScalabilityMode("L3T1");
codec_settings.maxBitrate = allocation.get_sum_kbps();
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
WEBRTC_VIDEO_CODEC_OK); WEBRTC_VIDEO_CODEC_OK);
encoder->SetRates(VideoEncoder::RateControlParameters(
allocation, codec_settings.maxFramerate));
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames = std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
EncodedVideoFrameProducer(*encoder).SetNumInputFrames(2).Encode(); EncodedVideoFrameProducer(*encoder).SetNumInputFrames(2).Encode();
ASSERT_THAT(encoded_frames, SizeIs(6)); ASSERT_THAT(encoded_frames, SizeIs(6));
@ -105,6 +114,10 @@ TEST(LibaomAv1EncoderTest, SetsEndOfPictureForLastFrameInTemporalUnit) {
} }
TEST(LibaomAv1EncoderTest, CheckOddDimensionsWithSpatialLayers) { TEST(LibaomAv1EncoderTest, CheckOddDimensionsWithSpatialLayers) {
VideoBitrateAllocation allocation;
allocation.SetBitrate(0, 0, 30000);
allocation.SetBitrate(1, 0, 40000);
allocation.SetBitrate(2, 0, 30000);
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder(); std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
VideoCodec codec_settings = DefaultCodecSettings(); VideoCodec codec_settings = DefaultCodecSettings();
// Configure encoder with 3 spatial layers. // Configure encoder with 3 spatial layers.
@ -112,8 +125,11 @@ TEST(LibaomAv1EncoderTest, CheckOddDimensionsWithSpatialLayers) {
// Odd width and height values should not make encoder crash. // Odd width and height values should not make encoder crash.
codec_settings.width = 623; codec_settings.width = 623;
codec_settings.height = 405; codec_settings.height = 405;
codec_settings.maxBitrate = allocation.get_sum_kbps();
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
WEBRTC_VIDEO_CODEC_OK); WEBRTC_VIDEO_CODEC_OK);
encoder->SetRates(VideoEncoder::RateControlParameters(
allocation, codec_settings.maxFramerate));
EncodedVideoFrameProducer evfp(*encoder); EncodedVideoFrameProducer evfp(*encoder);
evfp.SetResolution(RenderResolution{623, 405}); evfp.SetResolution(RenderResolution{623, 405});
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames = std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
@ -137,14 +153,20 @@ TEST(LibaomAv1EncoderTest, EncoderInfoProvidesFpsAllocation) {
} }
TEST(LibaomAv1EncoderTest, PopulatesEncodedFrameSize) { TEST(LibaomAv1EncoderTest, PopulatesEncodedFrameSize) {
VideoBitrateAllocation allocation;
allocation.SetBitrate(0, 0, 30000);
allocation.SetBitrate(1, 0, 40000);
allocation.SetBitrate(2, 0, 30000);
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder(); std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
VideoCodec codec_settings = DefaultCodecSettings(); VideoCodec codec_settings = DefaultCodecSettings();
codec_settings.maxBitrate = allocation.get_sum_kbps();
ASSERT_GT(codec_settings.width, 4); ASSERT_GT(codec_settings.width, 4);
// Configure encoder with 3 spatial layers. // Configure encoder with 3 spatial layers.
codec_settings.SetScalabilityMode("L3T1"); codec_settings.SetScalabilityMode("L3T1");
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
WEBRTC_VIDEO_CODEC_OK); WEBRTC_VIDEO_CODEC_OK);
encoder->SetRates(VideoEncoder::RateControlParameters(
allocation, codec_settings.maxFramerate));
using Frame = EncodedVideoFrameProducer::EncodedFrame; using Frame = EncodedVideoFrameProducer::EncodedFrame;
std::vector<Frame> encoded_frames = std::vector<Frame> encoded_frames =
EncodedVideoFrameProducer(*encoder).SetNumInputFrames(1).Encode(); EncodedVideoFrameProducer(*encoder).SetNumInputFrames(1).Encode();

View File

@ -178,15 +178,36 @@ struct SvcTestParam {
class LibaomAv1SvcTest : public ::testing::TestWithParam<SvcTestParam> {}; class LibaomAv1SvcTest : public ::testing::TestWithParam<SvcTestParam> {};
TEST_P(LibaomAv1SvcTest, EncodeAndDecodeAllDecodeTargets) { TEST_P(LibaomAv1SvcTest, EncodeAndDecodeAllDecodeTargets) {
size_t num_decode_targets = CreateScalabilityStructure(GetParam().name) const SvcTestParam param = GetParam();
->DependencyStructure() std::unique_ptr<ScalableVideoController> svc_controller =
.num_decode_targets; CreateScalabilityStructure(param.name);
ASSERT_TRUE(svc_controller);
VideoBitrateAllocation allocation;
if (param.configured_bitrates.empty()) {
ScalableVideoController::StreamLayersConfig config =
svc_controller->StreamConfig();
for (int sid = 0; sid < config.num_spatial_layers; ++sid) {
for (int tid = 0; tid < config.num_temporal_layers; ++tid) {
allocation.SetBitrate(sid, tid, 100'000);
}
}
} else {
for (const auto& kv : param.configured_bitrates) {
allocation.SetBitrate(kv.first.spatial_id, kv.first.temporal_id,
kv.second.bps());
}
}
size_t num_decode_targets =
svc_controller->DependencyStructure().num_decode_targets;
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder(); std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
VideoCodec codec_settings = DefaultCodecSettings(); VideoCodec codec_settings = DefaultCodecSettings();
codec_settings.SetScalabilityMode(GetParam().name); codec_settings.SetScalabilityMode(GetParam().name);
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()), ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
WEBRTC_VIDEO_CODEC_OK); WEBRTC_VIDEO_CODEC_OK);
encoder->SetRates(VideoEncoder::RateControlParameters(
allocation, codec_settings.maxFramerate));
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames = std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
EncodedVideoFrameProducer(*encoder) EncodedVideoFrameProducer(*encoder)
.SetNumInputFrames(GetParam().num_frames_to_generate) .SetNumInputFrames(GetParam().num_frames_to_generate)