Provide a default implementation of NV12BufferInterface::CropAndScale.
This avoids falling back on the VideoFrameBuffer::CropAndScale default implementation which performs ToI420. This has two major benefits: 1. We save CPU by not converting to I420 for NV12 frames. 2. We make is possible for simulcast encoders to use Scale() and be able to trust that the scaled simulcast layers have the same pixel format as the top layer, which is required by libvpx. In order to invoke NV12Buffer::CropAndScaleFrom() without introducing a circular dependency, nv12_buffer.[h/cc] is moved to the "video_frame" build target. Bug: webrtc:12595, webrtc:12469 Change-Id: I81aac5c6b3e81c49f32a7be6dc2640e6b40f7692 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212643 Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@google.com> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#33521}
This commit is contained in:
parent
50d79babcd
commit
f412976eca
@ -43,6 +43,8 @@ rtc_library("video_frame") {
|
|||||||
sources = [
|
sources = [
|
||||||
"i420_buffer.cc",
|
"i420_buffer.cc",
|
||||||
"i420_buffer.h",
|
"i420_buffer.h",
|
||||||
|
"nv12_buffer.cc",
|
||||||
|
"nv12_buffer.h",
|
||||||
"video_codec_type.h",
|
"video_codec_type.h",
|
||||||
"video_frame.cc",
|
"video_frame.cc",
|
||||||
"video_frame.h",
|
"video_frame.h",
|
||||||
@ -90,23 +92,6 @@ rtc_library("video_frame_i010") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc_library("video_frame_nv12") {
|
|
||||||
visibility = [ "*" ]
|
|
||||||
sources = [
|
|
||||||
"nv12_buffer.cc",
|
|
||||||
"nv12_buffer.h",
|
|
||||||
]
|
|
||||||
deps = [
|
|
||||||
":video_frame",
|
|
||||||
"..:scoped_refptr",
|
|
||||||
"../../rtc_base",
|
|
||||||
"../../rtc_base:checks",
|
|
||||||
"../../rtc_base/memory:aligned_malloc",
|
|
||||||
"../../rtc_base/system:rtc_export",
|
|
||||||
"//third_party/libyuv",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_source_set("recordable_encoded_frame") {
|
rtc_source_set("recordable_encoded_frame") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
sources = [ "recordable_encoded_frame.h" ]
|
sources = [ "recordable_encoded_frame.h" ]
|
||||||
|
|||||||
@ -20,7 +20,6 @@ rtc_library("rtc_api_video_unittests") {
|
|||||||
"..:video_adaptation",
|
"..:video_adaptation",
|
||||||
"..:video_bitrate_allocation",
|
"..:video_bitrate_allocation",
|
||||||
"..:video_frame",
|
"..:video_frame",
|
||||||
"..:video_frame_nv12",
|
|
||||||
"..:video_rtp_headers",
|
"..:video_rtp_headers",
|
||||||
"../../../test:frame_utils",
|
"../../../test:frame_utils",
|
||||||
"../../../test:test_support",
|
"../../../test:test_support",
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "api/video/video_frame_buffer.h"
|
#include "api/video/video_frame_buffer.h"
|
||||||
|
|
||||||
#include "api/video/i420_buffer.h"
|
#include "api/video/i420_buffer.h"
|
||||||
|
#include "api/video/nv12_buffer.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -139,4 +140,18 @@ int NV12BufferInterface::ChromaWidth() const {
|
|||||||
int NV12BufferInterface::ChromaHeight() const {
|
int NV12BufferInterface::ChromaHeight() const {
|
||||||
return (height() + 1) / 2;
|
return (height() + 1) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc::scoped_refptr<VideoFrameBuffer> NV12BufferInterface::CropAndScale(
|
||||||
|
int offset_x,
|
||||||
|
int offset_y,
|
||||||
|
int crop_width,
|
||||||
|
int crop_height,
|
||||||
|
int scaled_width,
|
||||||
|
int scaled_height) {
|
||||||
|
rtc::scoped_refptr<NV12Buffer> result =
|
||||||
|
NV12Buffer::Create(scaled_width, scaled_height);
|
||||||
|
result->CropAndScaleFrom(*this, offset_x, offset_y, crop_width, crop_height);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -242,6 +242,13 @@ class RTC_EXPORT NV12BufferInterface : public BiplanarYuv8Buffer {
|
|||||||
int ChromaWidth() const final;
|
int ChromaWidth() const final;
|
||||||
int ChromaHeight() const final;
|
int ChromaHeight() const final;
|
||||||
|
|
||||||
|
rtc::scoped_refptr<VideoFrameBuffer> CropAndScale(int offset_x,
|
||||||
|
int offset_y,
|
||||||
|
int crop_width,
|
||||||
|
int crop_height,
|
||||||
|
int scaled_width,
|
||||||
|
int scaled_height) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~NV12BufferInterface() override {}
|
~NV12BufferInterface() override {}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,7 +50,6 @@ rtc_library("common_video") {
|
|||||||
"../api/video:video_bitrate_allocation",
|
"../api/video:video_bitrate_allocation",
|
||||||
"../api/video:video_bitrate_allocator",
|
"../api/video:video_bitrate_allocator",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_frame_nv12",
|
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
"../api/video_codecs:bitstream_parser_api",
|
"../api/video_codecs:bitstream_parser_api",
|
||||||
"../media:rtc_h264_profile_id",
|
"../media:rtc_h264_profile_id",
|
||||||
@ -105,7 +104,6 @@ if (rtc_include_tests && !build_with_chromium) {
|
|||||||
"../api/units:time_delta",
|
"../api/units:time_delta",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_frame_i010",
|
"../api/video:video_frame_i010",
|
||||||
"../api/video:video_frame_nv12",
|
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
"../media:rtc_h264_profile_id",
|
"../media:rtc_h264_profile_id",
|
||||||
"../rtc_base",
|
"../rtc_base",
|
||||||
|
|||||||
@ -56,7 +56,6 @@ rtc_library("frame_generator_impl") {
|
|||||||
"../api/video:encoded_image",
|
"../api/video:encoded_image",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_frame_i010",
|
"../api/video:video_frame_i010",
|
||||||
"../api/video:video_frame_nv12",
|
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
"../api/video_codecs:video_codecs_api",
|
"../api/video_codecs:video_codecs_api",
|
||||||
"../common_video",
|
"../common_video",
|
||||||
|
|||||||
@ -663,7 +663,6 @@ if (rtc_include_tests) {
|
|||||||
"../api/video:video_adaptation",
|
"../api/video:video_adaptation",
|
||||||
"../api/video:video_bitrate_allocation",
|
"../api/video:video_bitrate_allocation",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_frame_nv12",
|
|
||||||
"../api/video:video_frame_type",
|
"../api/video:video_frame_type",
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
"../api/video_codecs:video_codecs_api",
|
"../api/video_codecs:video_codecs_api",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user