mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 13:50:40 +01:00

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. In this CL LibvpxVp9Encoder is updated to map kNative buffers of pixel formats it supports and convert ToI420() if the kNative buffer is something else. A fake native buffer that keeps track of which resolutions were mapped, MappableNativeBuffer, is added. Because VP9 is currently an SVC encoder and not a simulcast encoder, it does not need to invoke CropAndScale. This CL also fixes MultiplexEncoderAdapter, but because it simply forwards frames it only cares about the pixel format when |supports_augmented_data_| is true so this is the only time we map it. Because this encoder is not used with kNative in practise, we don't care to make this path optimal. Bug: webrtc:12469, chromium:1157072 Change-Id: I74edf85b18eccd0d250776bbade7a6444478efce Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212580 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@{#33526}
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "modules/video_coding/codecs/multiplex/include/augmented_video_frame_buffer.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <utility>
|
|
|
|
#include "api/video/video_frame_buffer.h"
|
|
|
|
namespace webrtc {
|
|
|
|
AugmentedVideoFrameBuffer::AugmentedVideoFrameBuffer(
|
|
const rtc::scoped_refptr<VideoFrameBuffer>& video_frame_buffer,
|
|
std::unique_ptr<uint8_t[]> augmenting_data,
|
|
uint16_t augmenting_data_size)
|
|
: augmenting_data_size_(augmenting_data_size),
|
|
augmenting_data_(std::move(augmenting_data)),
|
|
video_frame_buffer_(video_frame_buffer) {}
|
|
|
|
rtc::scoped_refptr<VideoFrameBuffer>
|
|
AugmentedVideoFrameBuffer::GetVideoFrameBuffer() const {
|
|
return video_frame_buffer_;
|
|
}
|
|
|
|
uint8_t* AugmentedVideoFrameBuffer::GetAugmentingData() const {
|
|
return augmenting_data_.get();
|
|
}
|
|
|
|
uint16_t AugmentedVideoFrameBuffer::GetAugmentingDataSize() const {
|
|
return augmenting_data_size_;
|
|
}
|
|
|
|
VideoFrameBuffer::Type AugmentedVideoFrameBuffer::type() const {
|
|
return video_frame_buffer_->type();
|
|
}
|
|
|
|
int AugmentedVideoFrameBuffer::width() const {
|
|
return video_frame_buffer_->width();
|
|
}
|
|
|
|
int AugmentedVideoFrameBuffer::height() const {
|
|
return video_frame_buffer_->height();
|
|
}
|
|
|
|
rtc::scoped_refptr<I420BufferInterface> AugmentedVideoFrameBuffer::ToI420() {
|
|
return video_frame_buffer_->ToI420();
|
|
}
|
|
|
|
const I420BufferInterface* AugmentedVideoFrameBuffer::GetI420() const {
|
|
// TODO(https://crbug.com/webrtc/12021): When AugmentedVideoFrameBuffer is
|
|
// updated to implement the buffer interfaces of relevant
|
|
// VideoFrameBuffer::Types, stop overriding GetI420() as a workaround to
|
|
// AugmentedVideoFrameBuffer not being the type that is returned by type().
|
|
return video_frame_buffer_->GetI420();
|
|
}
|
|
} // namespace webrtc
|