| Index: webrtc/api/video/i420_buffer.cc
|
| diff --git a/webrtc/common_video/video_frame_buffer.cc b/webrtc/api/video/i420_buffer.cc
|
| similarity index 67%
|
| copy from webrtc/common_video/video_frame_buffer.cc
|
| copy to webrtc/api/video/i420_buffer.cc
|
| index d23b4c5d45417e2d738cf226235479ceae06a8aa..031b15940a275ad75b629b623b3de006e048656a 100644
|
| --- a/webrtc/common_video/video_frame_buffer.cc
|
| +++ b/webrtc/api/video/i420_buffer.cc
|
| @@ -7,11 +7,12 @@
|
| * in the file PATENTS. All contributing project authors may
|
| * be found in the AUTHORS file in the root of the source tree.
|
| */
|
| -#include "webrtc/common_video/include/video_frame_buffer.h"
|
| +#include "webrtc/api/video/i420_buffer.h"
|
|
|
| #include <string.h>
|
|
|
| #include <algorithm>
|
| +#include <utility>
|
|
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/base/keep_ref_until_done.h"
|
| @@ -32,8 +33,6 @@ int I420DataSize(int height, int stride_y, int stride_u, int stride_v) {
|
|
|
| } // namespace
|
|
|
| -VideoFrameBuffer::~VideoFrameBuffer() {}
|
| -
|
| I420Buffer::I420Buffer(int width, int height)
|
| : I420Buffer(width, height, width, (width + 1) / 2, (width + 1) / 2) {
|
| }
|
| @@ -104,19 +103,14 @@ rtc::scoped_refptr<I420Buffer> I420Buffer::Copy(
|
| }
|
|
|
| // static
|
| -rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
|
| - rtc::scoped_refptr<VideoFrameBuffer> src,
|
| - VideoRotation rotation) {
|
| - RTC_CHECK(src->DataY());
|
| - RTC_CHECK(src->DataU());
|
| - RTC_CHECK(src->DataV());
|
| -
|
| - if (rotation == webrtc::kVideoRotation_0) {
|
| - return src;
|
| - }
|
| -
|
| - int rotated_width = src->width();
|
| - int rotated_height = src->height();
|
| +rtc::scoped_refptr<I420Buffer> I420Buffer::Rotate(
|
| + const VideoFrameBuffer& src, VideoRotation rotation) {
|
| + RTC_CHECK(src.DataY());
|
| + RTC_CHECK(src.DataU());
|
| + RTC_CHECK(src.DataV());
|
| +
|
| + int rotated_width = src.width();
|
| + int rotated_height = src.height();
|
| if (rotation == webrtc::kVideoRotation_90 ||
|
| rotation == webrtc::kVideoRotation_270) {
|
| std::swap(rotated_width, rotated_height);
|
| @@ -126,17 +120,28 @@ rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
|
| I420Buffer::Create(rotated_width, rotated_height);
|
|
|
| RTC_CHECK_EQ(0, libyuv::I420Rotate(
|
| - src->DataY(), src->StrideY(),
|
| - src->DataU(), src->StrideU(),
|
| - src->DataV(), src->StrideV(),
|
| + src.DataY(), src.StrideY(),
|
| + src.DataU(), src.StrideU(),
|
| + src.DataV(), src.StrideV(),
|
| buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
|
| buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
|
| - src->width(), src->height(),
|
| + src.width(), src.height(),
|
| static_cast<libyuv::RotationMode>(rotation)));
|
|
|
| return buffer;
|
| }
|
|
|
| +// static
|
| +rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::Rotate(
|
| + rtc::scoped_refptr<VideoFrameBuffer> src,
|
| + VideoRotation rotation) {
|
| + if (rotation == webrtc::kVideoRotation_0) {
|
| + return src;
|
| + } else {
|
| + return Rotate(*src, rotation);
|
| + }
|
| +}
|
| +
|
| void I420Buffer::InitializeData() {
|
| memset(data_.get(), 0,
|
| I420DataSize(height_, stride_y_, stride_u_, stride_v_));
|
| @@ -160,16 +165,6 @@ const uint8_t* I420Buffer::DataV() const {
|
| return data_.get() + stride_y_ * height_ + stride_u_ * ((height_ + 1) / 2);
|
| }
|
|
|
| -uint8_t* I420Buffer::MutableDataY() {
|
| - return const_cast<uint8_t*>(DataY());
|
| -}
|
| -uint8_t* I420Buffer::MutableDataU() {
|
| - return const_cast<uint8_t*>(DataU());
|
| -}
|
| -uint8_t* I420Buffer::MutableDataV() {
|
| - return const_cast<uint8_t*>(DataV());
|
| -}
|
| -
|
| int I420Buffer::StrideY() const {
|
| return stride_y_;
|
| }
|
| @@ -189,11 +184,22 @@ rtc::scoped_refptr<VideoFrameBuffer> I420Buffer::NativeToI420Buffer() {
|
| return nullptr;
|
| }
|
|
|
| -void I420Buffer::SetToBlack() {
|
| - RTC_CHECK(libyuv::I420Rect(MutableDataY(), StrideY(),
|
| - MutableDataU(), StrideU(),
|
| - MutableDataV(), StrideV(),
|
| - 0, 0, width(), height(),
|
| +uint8_t* I420Buffer::MutableDataY() {
|
| + return const_cast<uint8_t*>(DataY());
|
| +}
|
| +uint8_t* I420Buffer::MutableDataU() {
|
| + return const_cast<uint8_t*>(DataU());
|
| +}
|
| +uint8_t* I420Buffer::MutableDataV() {
|
| + return const_cast<uint8_t*>(DataV());
|
| +}
|
| +
|
| +// static
|
| +void I420Buffer::SetBlack(I420Buffer* buffer) {
|
| + RTC_CHECK(libyuv::I420Rect(buffer->MutableDataY(), buffer->StrideY(),
|
| + buffer->MutableDataU(), buffer->StrideU(),
|
| + buffer->MutableDataV(), buffer->StrideV(),
|
| + 0, 0, buffer->width(), buffer->height(),
|
| 0, 128, 128) == 0);
|
| }
|
|
|
| @@ -251,112 +257,4 @@ void I420Buffer::ScaleFrom(const VideoFrameBuffer& src) {
|
| CropAndScaleFrom(src, 0, 0, src.width(), src.height());
|
| }
|
|
|
| -NativeHandleBuffer::NativeHandleBuffer(void* native_handle,
|
| - int width,
|
| - int height)
|
| - : native_handle_(native_handle), width_(width), height_(height) {
|
| - RTC_DCHECK(native_handle != nullptr);
|
| - RTC_DCHECK_GT(width, 0);
|
| - RTC_DCHECK_GT(height, 0);
|
| -}
|
| -
|
| -int NativeHandleBuffer::width() const {
|
| - return width_;
|
| -}
|
| -
|
| -int NativeHandleBuffer::height() const {
|
| - return height_;
|
| -}
|
| -
|
| -const uint8_t* NativeHandleBuffer::DataY() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return nullptr;
|
| -}
|
| -const uint8_t* NativeHandleBuffer::DataU() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return nullptr;
|
| -}
|
| -const uint8_t* NativeHandleBuffer::DataV() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return nullptr;
|
| -}
|
| -
|
| -int NativeHandleBuffer::StrideY() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return 0;
|
| -}
|
| -int NativeHandleBuffer::StrideU() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return 0;
|
| -}
|
| -int NativeHandleBuffer::StrideV() const {
|
| - RTC_NOTREACHED(); // Should not be called.
|
| - return 0;
|
| -}
|
| -
|
| -void* NativeHandleBuffer::native_handle() const {
|
| - return native_handle_;
|
| -}
|
| -
|
| -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_;
|
| -}
|
| -
|
| -void* WrappedI420Buffer::native_handle() const {
|
| - return nullptr;
|
| -}
|
| -
|
| -rtc::scoped_refptr<VideoFrameBuffer> WrappedI420Buffer::NativeToI420Buffer() {
|
| - RTC_NOTREACHED();
|
| - return nullptr;
|
| -}
|
| -
|
| } // namespace webrtc
|
|
|