Adding layering configurator and rate allocator for VP9 SVC.
The configurator decides number of spatial layers, their resolution and bitrate thresholds based on given input resolution and maximum number of spatial layers. The allocator distributes available bitrate across spatial and temporal layers. If there is not enough bitrate to provide acceptable quality for all spatial layers allocator disables enhancement layers one by one until the condition is met or number of layers is reduced to one. VP9 SVC related unit tests have been updated. Input resolution and bitrate in these tests have been increased to the level enough to provide desirable number of spatial layers. Bug: webrtc:8518 Change-Id: I9df790920227c7f7dd4d42a50a856c22f0f4389b Reviewed-on: https://webrtc-review.googlesource.com/60340 Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Michael Horowitz <mhoro@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22672}
This commit is contained in:

committed by
Commit Bot

parent
002e710d07
commit
86684960b3
@ -8,11 +8,12 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_video/include/video_bitrate_allocator.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||
#include "modules/video_coding/include/video_codec_initializer.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "common_video/include/video_bitrate_allocator.h"
|
||||
#include "modules/video_coding/codecs/vp8/temporal_layers.h"
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
|
||||
#include "rtc_base/refcountedobject.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
@ -60,8 +61,13 @@ class VideoCodecInitializerTest : public ::testing::Test {
|
||||
vp8_settings.numberOfTemporalLayers = num_temporal_streams;
|
||||
config_.encoder_specific_settings = new rtc::RefCountedObject<
|
||||
webrtc::VideoEncoderConfig::Vp8EncoderSpecificSettings>(vp8_settings);
|
||||
} else if (type == VideoCodecType::kVideoCodecMultiplex) {
|
||||
} else {
|
||||
} else if (type == VideoCodecType::kVideoCodecVP9) {
|
||||
VideoCodecVP9 vp9_settings = VideoEncoder::GetDefaultVp9Settings();
|
||||
vp9_settings.numberOfSpatialLayers = num_spatial_streams;
|
||||
vp9_settings.numberOfTemporalLayers = num_temporal_streams;
|
||||
config_.encoder_specific_settings = new rtc::RefCountedObject<
|
||||
webrtc::VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings);
|
||||
} else if (type != VideoCodecType::kVideoCodecMultiplex) {
|
||||
ADD_FAILURE() << "Unexpected codec type: " << type;
|
||||
}
|
||||
}
|
||||
@ -241,4 +247,29 @@ TEST_F(VideoCodecInitializerTest, SingleStreamMultiplexCodec) {
|
||||
EXPECT_TRUE(InitializeCodec());
|
||||
}
|
||||
|
||||
TEST_F(VideoCodecInitializerTest, Vp9SvcDefaultLayering) {
|
||||
SetUpFor(VideoCodecType::kVideoCodecVP9, 3, 3, false);
|
||||
VideoStream stream = DefaultStream();
|
||||
stream.num_temporal_layers = 3;
|
||||
streams_.push_back(stream);
|
||||
|
||||
EXPECT_TRUE(InitializeCodec());
|
||||
EXPECT_EQ(codec_out_.VP9()->numberOfSpatialLayers, 3u);
|
||||
EXPECT_EQ(codec_out_.VP9()->numberOfTemporalLayers, 3u);
|
||||
}
|
||||
|
||||
TEST_F(VideoCodecInitializerTest, Vp9SvcAdjustedLayering) {
|
||||
SetUpFor(VideoCodecType::kVideoCodecVP9, 3, 3, false);
|
||||
VideoStream stream = DefaultStream();
|
||||
stream.num_temporal_layers = 3;
|
||||
// Set resolution which is only enough to produce 2 spatial layers.
|
||||
stream.width = kMinVp9SpatialLayerWidth * 2;
|
||||
stream.height = kMinVp9SpatialLayerHeight * 2;
|
||||
|
||||
streams_.push_back(stream);
|
||||
|
||||
EXPECT_TRUE(InitializeCodec());
|
||||
EXPECT_EQ(codec_out_.VP9()->numberOfSpatialLayers, 2u);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
Reference in New Issue
Block a user