webrtc/api/video/video_frame_buffer.cc
Patrik Höglund b5b5bcee72 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}
2017-11-13 14:27:39 +00:00

80 lines
2.1 KiB
C++

/*
* Copyright (c) 2017 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 "api/video/video_frame_buffer.h"
#include "rtc_base/checks.h"
namespace webrtc {
rtc::scoped_refptr<I420BufferInterface> VideoFrameBuffer::GetI420() {
RTC_CHECK(type() == Type::kI420);
return static_cast<I420BufferInterface*>(this);
}
rtc::scoped_refptr<const I420BufferInterface> VideoFrameBuffer::GetI420()
const {
RTC_CHECK(type() == Type::kI420);
return static_cast<const I420BufferInterface*>(this);
}
I420ABufferInterface* VideoFrameBuffer::GetI420A() {
RTC_CHECK(type() == Type::kI420A);
return static_cast<I420ABufferInterface*>(this);
}
const I420ABufferInterface* VideoFrameBuffer::GetI420A() const {
RTC_CHECK(type() == Type::kI420A);
return static_cast<const I420ABufferInterface*>(this);
}
I444BufferInterface* VideoFrameBuffer::GetI444() {
RTC_CHECK(type() == Type::kI444);
return static_cast<I444BufferInterface*>(this);
}
const I444BufferInterface* VideoFrameBuffer::GetI444() const {
RTC_CHECK(type() == Type::kI444);
return static_cast<const I444BufferInterface*>(this);
}
VideoFrameBuffer::Type I420BufferInterface::type() const {
return Type::kI420;
}
int I420BufferInterface::ChromaWidth() const {
return (width() + 1) / 2;
}
int I420BufferInterface::ChromaHeight() const {
return (height() + 1) / 2;
}
rtc::scoped_refptr<I420BufferInterface> I420BufferInterface::ToI420() {
return this;
}
VideoFrameBuffer::Type I420ABufferInterface::type() const {
return Type::kI420A;
}
VideoFrameBuffer::Type I444BufferInterface::type() const {
return Type::kI444;
}
int I444BufferInterface::ChromaWidth() const {
return width();
}
int I444BufferInterface::ChromaHeight() const {
return height();
}
} // namespace webrtc