Prevent possible out-of-bounds access
It read from simulcast_layers[0] even if vector is empty. Bug: none Change-Id: I293890feda70022beae4247ab10cf8182b4cf4a5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/209706 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33391}
This commit is contained in:
parent
4a4273bf05
commit
964a88fce1
@ -720,16 +720,20 @@ bool VideoStreamEncoderResourceManager::IsSimulcast(
|
||||
const VideoEncoderConfig& encoder_config) {
|
||||
const std::vector<VideoStream>& simulcast_layers =
|
||||
encoder_config.simulcast_layers;
|
||||
if (simulcast_layers.size() <= 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (simulcast_layers[0].active) {
|
||||
// We can't distinguish between simulcast and singlecast when only the
|
||||
// lowest spatial layer is active. Treat this case as simulcast.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_simulcast = simulcast_layers.size() > 1;
|
||||
bool is_lowest_layer_active = simulcast_layers[0].active;
|
||||
int num_active_layers =
|
||||
std::count_if(simulcast_layers.begin(), simulcast_layers.end(),
|
||||
[](const VideoStream& layer) { return layer.active; });
|
||||
|
||||
// We can't distinguish between simulcast and singlecast when only the
|
||||
// lowest spatial layer is active. Treat this case as simulcast.
|
||||
return is_simulcast && (num_active_layers > 1 || is_lowest_layer_active);
|
||||
return num_active_layers > 1;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user