Support native scaling of VideoFrameBuffers in LibvpxVp8Encoder.
This is a follow-up to the VP9, fixing VP8 this time. Context again: This CL is part of Optimized Scaling efforts. In Chromium, the native frame buffer is getting an optimized CropAndScale() implementation. To support HW accelerated scaling, returning pre-scaled images and skipping unnecessary intermediate downscales, WebRTC needs to 1) use CropAndScale instead of libyuv::XXXXScale and 2) only map buffers it actually intends to encode. - To achieve this, WebRTC encoders are updated to map kNative video buffers so that in a follow-up CL VideoStreamEncoder can stop mapping intermediate buffer sizes. Bug: webrtc:12469, chromium:1157072 Change-Id: I026527ae77e36f66d02e149ad6fe304f6a8ccb05 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212600 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@google.com> Cr-Commit-Position: refs/heads/master@{#33537}
This commit is contained in:
committed by
Commit Bot
parent
6a6715042a
commit
3889de1c4c
@ -1893,7 +1893,7 @@ rtc::scoped_refptr<VideoFrameBuffer> LibvpxVp9Encoder::PrepareBufferForProfile0(
|
||||
mapped_buffer->type() != VideoFrameBuffer::Type::kI420A)) {
|
||||
// Unknown pixel format or unable to map, convert to I420 and prepare that
|
||||
// buffer instead to ensure Scale() is safe to use.
|
||||
rtc::scoped_refptr<VideoFrameBuffer> converted_buffer = buffer->ToI420();
|
||||
auto converted_buffer = buffer->ToI420();
|
||||
if (!converted_buffer) {
|
||||
RTC_LOG(LS_ERROR) << "Failed to convert "
|
||||
<< VideoFrameBufferTypeToString(buffer->type())
|
||||
@ -1902,21 +1902,12 @@ rtc::scoped_refptr<VideoFrameBuffer> LibvpxVp9Encoder::PrepareBufferForProfile0(
|
||||
}
|
||||
// The buffer should now be a mapped I420 or I420A format, but some buffer
|
||||
// implementations incorrectly return the wrong buffer format, such as
|
||||
// kNative. As a workaround to this, we retry GetMappedFrameBuffer+ToI420.
|
||||
// kNative. As a workaround to this, we perform ToI420() a second time.
|
||||
// TODO(https://crbug.com/webrtc/12602): When Android buffers have a correct
|
||||
// ToI420() implementaion, remove his workaround.
|
||||
if (converted_buffer->type() != VideoFrameBuffer::Type::kI420 &&
|
||||
converted_buffer->type() != VideoFrameBuffer::Type::kI420A) {
|
||||
if (converted_buffer->type() == VideoFrameBuffer::Type::kNative) {
|
||||
auto mapped_converted_buffer =
|
||||
converted_buffer->GetMappedFrameBuffer(supported_formats);
|
||||
if (mapped_converted_buffer)
|
||||
converted_buffer = mapped_converted_buffer;
|
||||
}
|
||||
if (converted_buffer->type() != VideoFrameBuffer::Type::kI420 &&
|
||||
converted_buffer->type() != VideoFrameBuffer::Type::kI420A) {
|
||||
converted_buffer = converted_buffer->ToI420();
|
||||
}
|
||||
converted_buffer = converted_buffer->ToI420();
|
||||
RTC_CHECK(converted_buffer->type() == VideoFrameBuffer::Type::kI420 ||
|
||||
converted_buffer->type() == VideoFrameBuffer::Type::kI420A);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user