Encode frames at the largest layer resolution instead of last layer

The current code assumes that layers are ordered from the smallest
to the largest.
If that assumption is broken and the last layer is smaller than the
others, all layers that are bigger will be scaled up.

Bug: webrtc:10069
Change-Id: Iff87ddba741d5dfe3d0cc25a8f75d898a417eec7
Reviewed-on: https://webrtc-review.googlesource.com/c/112460
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25878}
This commit is contained in:
Florent Castelli 2018-11-29 17:32:47 +01:00 committed by Commit Bot
parent e7673cf922
commit 450b548cad

View File

@ -526,8 +526,13 @@ void VideoStreamEncoder::ReconfigureEncoder() {
// Stream dimensions may be not equal to given because of a simulcast
// restrictions.
int highest_stream_width = static_cast<int>(streams.back().width);
int highest_stream_height = static_cast<int>(streams.back().height);
auto highest_stream = std::max_element(
streams.begin(), streams.end(),
[](const webrtc::VideoStream& a, const webrtc::VideoStream& b) {
return std::tie(a.width, a.height) < std::tie(b.width, b.height);
});
int highest_stream_width = static_cast<int>(highest_stream->width);
int highest_stream_height = static_cast<int>(highest_stream->height);
// Dimension may be reduced to be, e.g. divisible by 4.
RTC_CHECK_GE(last_frame_info_->width, highest_stream_width);
RTC_CHECK_GE(last_frame_info_->height, highest_stream_height);