Separate i420 and i444 implementations to separate targets.

This means we can properly declare the dependency between
libjingle_peerconnection_api and video_frame_api. i420
pulls in system_wrappers, which can't be a dependency of
the public API.

Plan:
1) Land this CL + send out PSA
2) Make all direct users of i420_buffer depend on the
   new video_frame_api_i420 target
3) Move i420_buffer.cc to the new target
4) Make libjingle_peerconnection_api depend on
   video_frame_api, since it no longer contains i420 code

Bug: webrtc:7504
Change-Id: I30d90f2ac7af53748859bbde8aed92386d5501f9
Reviewed-on: https://webrtc-review.googlesource.com/9382
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20656}
This commit is contained in:
Patrik Höglund
2017-11-13 10:19:58 +01:00
committed by Commit Bot
parent 46a2765c56
commit b5b5bcee72
12 changed files with 116 additions and 72 deletions

View File

@ -81,15 +81,16 @@ rtc_static_library("libjingle_peerconnection_api") {
] ]
deps = [ deps = [
# Basically, don't add stuff here. You might break sensitive downstream
# targets like pnacl. API should not depend on anything, really. All these
# should go away, in time.
":optional", ":optional",
":rtc_stats_api", ":rtc_stats_api",
"audio_codecs:audio_codecs_api",
# Basically, don't add stuff here. You might break sensitive downstream
# targets like pnacl. API should not depend on anything outside of this
# file, really. All these should arguably go away in time.
"..:webrtc_common", "..:webrtc_common",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"audio_codecs:audio_codecs_api",
] ]
# This is needed until bugs.webrtc.org/7504 is removed so this target can # This is needed until bugs.webrtc.org/7504 is removed so this target can
@ -214,6 +215,8 @@ rtc_source_set("transport_api") {
rtc_source_set("video_frame_api") { rtc_source_set("video_frame_api") {
sources = [ sources = [
# TODO(phoglund): move i420 files to video_frame_api_i420 after updating
# downstream. See bugs.webrtc.org/7504.
"video/i420_buffer.cc", "video/i420_buffer.cc",
"video/i420_buffer.h", "video/i420_buffer.h",
"video/video_content_type.cc", "video/video_content_type.cc",
@ -245,6 +248,17 @@ rtc_source_set("video_frame_api") {
} }
} }
rtc_source_set("video_frame_api_i420") {
sources = [
"video/i420_buffer.h",
]
deps = [
":video_frame_api",
"../rtc_base:rtc_base_approved",
"../system_wrappers",
]
}
rtc_source_set("array_view") { rtc_source_set("array_view") {
sources = [ sources = [
"array_view.h", "array_view.h",

View File

@ -10,8 +10,6 @@
#include "api/video/video_frame_buffer.h" #include "api/video/video_frame_buffer.h"
#include "libyuv/convert.h"
#include "api/video/i420_buffer.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
@ -79,15 +77,4 @@ int I444BufferInterface::ChromaHeight() const {
return height(); return height();
} }
rtc::scoped_refptr<I420BufferInterface> I444BufferInterface::ToI420() {
rtc::scoped_refptr<I420Buffer> i420_buffer =
I420Buffer::Create(width(), height());
libyuv::I444ToI420(DataY(), StrideY(), DataU(), StrideU(), DataV(), StrideV(),
i420_buffer->MutableDataY(), i420_buffer->StrideY(),
i420_buffer->MutableDataU(), i420_buffer->StrideU(),
i420_buffer->MutableDataV(), i420_buffer->StrideV(),
width(), height());
return i420_buffer;
}
} // namespace webrtc } // namespace webrtc

View File

@ -129,8 +129,6 @@ class I444BufferInterface : public PlanarYuvBuffer {
int ChromaWidth() const final; int ChromaWidth() const final;
int ChromaHeight() const final; int ChromaHeight() const final;
rtc::scoped_refptr<I420BufferInterface> ToI420() final;
protected: protected:
~I444BufferInterface() override {} ~I444BufferInterface() override {}
}; };

View File

@ -58,6 +58,7 @@ rtc_static_library("common_video") {
deps = [ deps = [
"..:webrtc_common", "..:webrtc_common",
"../api:optional", "../api:optional",
"../api:video_frame_api_i420",
"../media:rtc_h264_profile_id", "../media:rtc_h264_profile_id",
"../modules:module_api", "../modules:module_api",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
@ -115,6 +116,7 @@ if (rtc_include_tests) {
deps = [ deps = [
":common_video", ":common_video",
"../api:video_frame_api_i420",
"../modules/video_capture:video_capture", "../modules/video_capture:video_capture",
"../rtc_base:rtc_base", "../rtc_base:rtc_base",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",

View File

@ -13,6 +13,7 @@
#include <algorithm> #include <algorithm>
#include "api/video/i420_buffer.h"
#include "libyuv/convert.h" #include "libyuv/convert.h"
#include "libyuv/planar_functions.h" #include "libyuv/planar_functions.h"
#include "libyuv/scale.h" #include "libyuv/scale.h"
@ -21,57 +22,7 @@
namespace webrtc { namespace webrtc {
WrappedI420Buffer::WrappedI420Buffer(int width, namespace {
int height,
const uint8_t* y_plane,
int y_stride,
const uint8_t* u_plane,
int u_stride,
const uint8_t* v_plane,
int v_stride,
const rtc::Callback0<void>& no_longer_used)
: width_(width),
height_(height),
y_plane_(y_plane),
u_plane_(u_plane),
v_plane_(v_plane),
y_stride_(y_stride),
u_stride_(u_stride),
v_stride_(v_stride),
no_longer_used_cb_(no_longer_used) {
}
WrappedI420Buffer::~WrappedI420Buffer() {
no_longer_used_cb_();
}
int WrappedI420Buffer::width() const {
return width_;
}
int WrappedI420Buffer::height() const {
return height_;
}
const uint8_t* WrappedI420Buffer::DataY() const {
return y_plane_;
}
const uint8_t* WrappedI420Buffer::DataU() const {
return u_plane_;
}
const uint8_t* WrappedI420Buffer::DataV() const {
return v_plane_;
}
int WrappedI420Buffer::StrideY() const {
return y_stride_;
}
int WrappedI420Buffer::StrideU() const {
return u_stride_;
}
int WrappedI420Buffer::StrideV() const {
return v_stride_;
}
// Template to implement a wrapped buffer for a I4??BufferInterface. // Template to implement a wrapped buffer for a I4??BufferInterface.
template <typename Base> template <typename Base>
@ -163,6 +114,76 @@ class WrappedYuvaBuffer : public WrappedYuvBuffer<BaseWithA> {
const int a_stride_; const int a_stride_;
}; };
class I444BufferBase : public I444BufferInterface {
public:
rtc::scoped_refptr<I420BufferInterface> ToI420() final;
};
rtc::scoped_refptr<I420BufferInterface> I444BufferBase::ToI420() {
rtc::scoped_refptr<I420Buffer> i420_buffer =
I420Buffer::Create(width(), height());
libyuv::I444ToI420(DataY(), StrideY(), DataU(), StrideU(), DataV(), StrideV(),
i420_buffer->MutableDataY(), i420_buffer->StrideY(),
i420_buffer->MutableDataU(), i420_buffer->StrideU(),
i420_buffer->MutableDataV(), i420_buffer->StrideV(),
width(), height());
return i420_buffer;
}
} // namespace
WrappedI420Buffer::WrappedI420Buffer(int width,
int height,
const uint8_t* y_plane,
int y_stride,
const uint8_t* u_plane,
int u_stride,
const uint8_t* v_plane,
int v_stride,
const rtc::Callback0<void>& no_longer_used)
: width_(width),
height_(height),
y_plane_(y_plane),
u_plane_(u_plane),
v_plane_(v_plane),
y_stride_(y_stride),
u_stride_(u_stride),
v_stride_(v_stride),
no_longer_used_cb_(no_longer_used) {
}
WrappedI420Buffer::~WrappedI420Buffer() {
no_longer_used_cb_();
}
int WrappedI420Buffer::width() const {
return width_;
}
int WrappedI420Buffer::height() const {
return height_;
}
const uint8_t* WrappedI420Buffer::DataY() const {
return y_plane_;
}
const uint8_t* WrappedI420Buffer::DataU() const {
return u_plane_;
}
const uint8_t* WrappedI420Buffer::DataV() const {
return v_plane_;
}
int WrappedI420Buffer::StrideY() const {
return y_stride_;
}
int WrappedI420Buffer::StrideU() const {
return u_stride_;
}
int WrappedI420Buffer::StrideV() const {
return v_stride_;
}
rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer( rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer(
int width, int width,
int height, int height,
@ -208,7 +229,7 @@ rtc::scoped_refptr<I444BufferInterface> WrapI444Buffer(
int v_stride, int v_stride,
const rtc::Callback0<void>& no_longer_used) { const rtc::Callback0<void>& no_longer_used) {
return rtc::scoped_refptr<I444BufferInterface>( return rtc::scoped_refptr<I444BufferInterface>(
new rtc::RefCountedObject<WrappedYuvBuffer<I444BufferInterface>>( new rtc::RefCountedObject<WrappedYuvBuffer<I444BufferBase>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane, width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, no_longer_used)); v_stride, no_longer_used));
} }

View File

@ -492,7 +492,9 @@ if (is_linux || is_win) {
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
} }
deps = [] deps = [
"../api:video_frame_api_i420",
]
if (is_win) { if (is_win) {
sources += [ sources += [
"peerconnection/client/flagdefs.h", "peerconnection/client/flagdefs.h",

View File

@ -135,6 +135,7 @@ rtc_static_library("rtc_audio_video") {
defines = [] defines = []
libs = [] libs = []
deps = [ deps = [
"../api:video_frame_api_i420",
"../modules/video_coding:video_coding_utility", "../modules/video_coding:video_coding_utility",
] ]
sources = [ sources = [
@ -339,6 +340,7 @@ if (rtc_include_tests) {
include_dirs = [] include_dirs = []
public_deps = [] public_deps = []
deps = [ deps = [
"../api:video_frame_api_i420",
"../call:video_stream_api", "../call:video_stream_api",
"../modules/audio_coding:rent_a_codec", "../modules/audio_coding:rent_a_codec",
"../modules/audio_processing:audio_processing", "../modules/audio_processing:audio_processing",
@ -440,6 +442,7 @@ if (rtc_include_tests) {
defines = [] defines = []
deps = [ deps = [
"../api:video_frame_api_i420",
"../pc:rtc_pc", "../pc:rtc_pc",
"../test:field_trial", "../test:field_trial",
] ]

View File

@ -37,6 +37,7 @@ rtc_source_set("module_api") {
"..:webrtc_common", "..:webrtc_common",
"../api:optional", "../api:optional",
"../api:video_frame_api", "../api:video_frame_api",
"../api:video_frame_api_i420",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"video_coding:codec_globals_headers", "video_coding:codec_globals_headers",
] ]

View File

@ -28,6 +28,7 @@ rtc_static_library("video_capture_module") {
deps = [ deps = [
"..:module_api", "..:module_api",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:video_frame_api_i420",
"../../common_video", "../../common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../system_wrappers", "../../system_wrappers",
@ -200,6 +201,7 @@ if (!build_with_chromium) {
deps = [ deps = [
":video_capture_internal_impl", ":video_capture_internal_impl",
":video_capture_module", ":video_capture_module",
"../../api:video_frame_api_i420",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../system_wrappers:system_wrappers", "../../system_wrappers:system_wrappers",

View File

@ -99,6 +99,7 @@ rtc_static_library("video_coding") {
"..:module_api", "..:module_api",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:optional", "../../api:optional",
"../../api:video_frame_api_i420",
"../../call:video_stream_api", "../../call:video_stream_api",
"../../common_video", "../../common_video",
"../../rtc_base:rtc_base", "../../rtc_base:rtc_base",
@ -189,6 +190,7 @@ rtc_static_library("webrtc_h264") {
defines = [] defines = []
deps = [ deps = [
":video_coding_utility", ":video_coding_utility",
"../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../media:rtc_media_base", "../../media:rtc_media_base",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
@ -229,6 +231,7 @@ rtc_static_library("webrtc_i420") {
deps = [ deps = [
":video_coding_utility", ":video_coding_utility",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:video_frame_api_i420",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../system_wrappers", "../../system_wrappers",
@ -252,6 +255,7 @@ rtc_static_library("webrtc_stereo") {
":video_coding_utility", ":video_coding_utility",
"..:module_api", "..:module_api",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
@ -376,6 +380,7 @@ if (rtc_include_tests) {
":video_coding", ":video_coding",
":webrtc_vp8", ":webrtc_vp8",
"../../api:video_frame_api", "../../api:video_frame_api",
"../../api:video_frame_api_i420",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../test:test_support", "../../test:test_support",
@ -409,6 +414,7 @@ if (rtc_include_tests) {
":video_coding_utility", ":video_coding_utility",
":webrtc_vp8", ":webrtc_vp8",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
@ -471,6 +477,7 @@ if (rtc_include_tests) {
"../../api:mock_video_codec_factory", "../../api:mock_video_codec_factory",
"../../api:optional", "../../api:optional",
"../../api:video_frame_api", "../../api:video_frame_api",
"../../api:video_frame_api_i420",
"../../common_video", "../../common_video",
"../../media:rtc_audio_video", "../../media:rtc_audio_video",
"../../media:rtc_media_base", "../../media:rtc_media_base",
@ -586,6 +593,7 @@ if (rtc_include_tests) {
"..:module_api", "..:module_api",
"../..:webrtc_common", "../..:webrtc_common",
"../../api:video_frame_api", "../../api:video_frame_api",
"../../api:video_frame_api_i420",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../common_video:common_video", "../../common_video:common_video",
"../../rtc_base:rtc_base", "../../rtc_base:rtc_base",

View File

@ -61,6 +61,7 @@ rtc_source_set("video_test_common") {
deps = [ deps = [
"..:webrtc_common", "..:webrtc_common",
"../api:optional", "../api:optional",
"../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api", "../api/video_codecs:video_codecs_api",
"../call:video_stream_api", "../call:video_stream_api",
"../common_video", "../common_video",
@ -212,6 +213,7 @@ if (rtc_include_tests) {
":video_test_common", ":video_test_common",
"..:webrtc_common", "..:webrtc_common",
"../api:video_frame_api", "../api:video_frame_api",
"../api:video_frame_api_i420",
"../common_video", "../common_video",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../system_wrappers", "../system_wrappers",
@ -285,6 +287,7 @@ if (rtc_include_tests) {
":fake_audio_device", ":fake_audio_device",
":rtp_test_utils", ":rtp_test_utils",
"../api:video_frame_api", "../api:video_frame_api",
"../api:video_frame_api_i420",
"../call:call_interfaces", "../call:call_interfaces",
"../common_audio", "../common_audio",
"../modules/rtp_rtcp", "../modules/rtp_rtcp",
@ -553,6 +556,7 @@ rtc_source_set("test_common") {
"..:webrtc_common", "..:webrtc_common",
"../api:transport_api", "../api:transport_api",
"../api:video_frame_api", "../api:video_frame_api",
"../api:video_frame_api_i420",
"../api/audio_codecs:builtin_audio_decoder_factory", "../api/audio_codecs:builtin_audio_decoder_factory",
"../api/audio_codecs:builtin_audio_encoder_factory", "../api/audio_codecs:builtin_audio_encoder_factory",
"../api/video_codecs:video_codecs_api", "../api/video_codecs:video_codecs_api",

View File

@ -57,6 +57,7 @@ rtc_static_library("video") {
"..:webrtc_common", "..:webrtc_common",
"../api:optional", "../api:optional",
"../api:transport_api", "../api:transport_api",
"../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api", "../api/video_codecs:video_codecs_api",
"../call:bitrate_allocator", "../call:bitrate_allocator",
"../call:call_interfaces", "../call:call_interfaces",
@ -273,6 +274,7 @@ if (rtc_include_tests) {
":video", ":video",
"../api:optional", "../api:optional",
"../api:video_frame_api", "../api:video_frame_api",
"../api:video_frame_api_i420",
"../api/video_codecs:video_codecs_api", "../api/video_codecs:video_codecs_api",
"../call:call_interfaces", "../call:call_interfaces",
"../call:mock_rtp_interfaces", "../call:mock_rtp_interfaces",