[VP9 SVC] Round spatial layers dimensions to ensure integer scaling factors are used
Bug: webrtc:11652 Change-Id: Id3642d607f62b72a567d521d9874b8588c2ce429 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176517 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31465}
This commit is contained in:
committed by
Commit Bot
parent
9766b890a8
commit
09eb6e249d
@ -79,6 +79,11 @@ std::vector<SpatialLayer> ConfigureSvcNormalVideo(size_t input_width,
|
||||
// First active layer must be configured.
|
||||
num_spatial_layers = std::max(num_spatial_layers, first_active_layer + 1);
|
||||
|
||||
// Ensure top layer is even enough.
|
||||
int required_divisiblity = 1 << num_spatial_layers;
|
||||
input_width = input_width - input_width % required_divisiblity;
|
||||
input_height = input_height - input_height % required_divisiblity;
|
||||
|
||||
for (size_t sl_idx = first_active_layer; sl_idx < num_spatial_layers;
|
||||
++sl_idx) {
|
||||
SpatialLayer spatial_layer = {0};
|
||||
|
||||
@ -219,6 +219,14 @@ VideoCodec VideoCodecInitializer::VideoEncoderConfigToVideoCodec(
|
||||
video_codec.spatialLayers[i] = spatial_layers[i];
|
||||
}
|
||||
|
||||
// The top spatial layer dimensions may not be equal to the input
|
||||
// resolution because of the rounding or explicit configuration.
|
||||
// This difference must be propagated to the stream configuration.
|
||||
video_codec.width = spatial_layers.back().width;
|
||||
video_codec.height = spatial_layers.back().height;
|
||||
video_codec.simulcastStream[0].width = spatial_layers.back().width;
|
||||
video_codec.simulcastStream[0].height = spatial_layers.back().height;
|
||||
|
||||
// Update layering settings.
|
||||
video_codec.VP9()->numberOfSpatialLayers =
|
||||
static_cast<unsigned char>(spatial_layers.size());
|
||||
|
||||
Reference in New Issue
Block a user