aboutsummaryrefslogtreecommitdiff
path: root/common_video/video_frame_buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'common_video/video_frame_buffer.cc')
-rw-r--r--common_video/video_frame_buffer.cc100
1 files changed, 83 insertions, 17 deletions
diff --git a/common_video/video_frame_buffer.cc b/common_video/video_frame_buffer.cc
index a13548f95e..6e93835c25 100644
--- a/common_video/video_frame_buffer.cc
+++ b/common_video/video_frame_buffer.cc
@@ -9,9 +9,9 @@
*/
#include "common_video/include/video_frame_buffer.h"
+#include "api/make_ref_counted.h"
#include "api/video/i420_buffer.h"
#include "rtc_base/checks.h"
-#include "rtc_base/ref_counted_object.h"
#include "third_party/libyuv/include/libyuv/convert.h"
namespace webrtc {
@@ -30,7 +30,7 @@ class WrappedYuvBuffer : public Base {
int u_stride,
const uint8_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used)
+ std::function<void()> no_longer_used)
: width_(width),
height_(height),
y_plane_(y_plane),
@@ -70,7 +70,7 @@ class WrappedYuvBuffer : public Base {
const int y_stride_;
const int u_stride_;
const int v_stride_;
- rtc::Callback0<void> no_longer_used_cb_;
+ std::function<void()> no_longer_used_cb_;
};
// Template to implement a wrapped buffer for a I4??BufferInterface.
@@ -87,7 +87,7 @@ class WrappedYuvaBuffer : public WrappedYuvBuffer<BaseWithA> {
int v_stride,
const uint8_t* a_plane,
int a_stride,
- const rtc::Callback0<void>& no_longer_used)
+ std::function<void()> no_longer_used)
: WrappedYuvBuffer<BaseWithA>(width,
height,
y_plane,
@@ -124,6 +124,22 @@ rtc::scoped_refptr<I420BufferInterface> I444BufferBase::ToI420() {
return i420_buffer;
}
+class I422BufferBase : public I422BufferInterface {
+ public:
+ rtc::scoped_refptr<I420BufferInterface> ToI420() final;
+};
+
+rtc::scoped_refptr<I420BufferInterface> I422BufferBase::ToI420() {
+ rtc::scoped_refptr<I420Buffer> i420_buffer =
+ I420Buffer::Create(width(), height());
+ libyuv::I422ToI420(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;
+}
+
// Template to implement a wrapped buffer for a PlanarYuv16BBuffer.
template <typename Base>
class WrappedYuv16BBuffer : public Base {
@@ -136,7 +152,7 @@ class WrappedYuv16BBuffer : public Base {
int u_stride,
const uint16_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used)
+ std::function<void()> no_longer_used)
: width_(width),
height_(height),
y_plane_(y_plane),
@@ -176,7 +192,7 @@ class WrappedYuv16BBuffer : public Base {
const int y_stride_;
const int u_stride_;
const int v_stride_;
- rtc::Callback0<void> no_longer_used_cb_;
+ std::function<void()> no_longer_used_cb_;
};
class I010BufferBase : public I010BufferInterface {
@@ -199,6 +215,22 @@ rtc::scoped_refptr<I420BufferInterface> I010BufferBase::ToI420() {
return i420_buffer;
}
+class I210BufferBase : public I210BufferInterface {
+ public:
+ rtc::scoped_refptr<I420BufferInterface> ToI420() final;
+};
+
+rtc::scoped_refptr<I420BufferInterface> I210BufferBase::ToI420() {
+ rtc::scoped_refptr<I420Buffer> i420_buffer =
+ I420Buffer::Create(width(), height());
+ libyuv::I210ToI420(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
rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer(
@@ -210,9 +242,9 @@ rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer(
int u_stride,
const uint8_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used) {
+ std::function<void()> no_longer_used) {
return rtc::scoped_refptr<I420BufferInterface>(
- new rtc::RefCountedObject<WrappedYuvBuffer<I420BufferInterface>>(
+ rtc::make_ref_counted<WrappedYuvBuffer<I420BufferInterface>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, no_longer_used));
}
@@ -228,13 +260,29 @@ rtc::scoped_refptr<I420ABufferInterface> WrapI420ABuffer(
int v_stride,
const uint8_t* a_plane,
int a_stride,
- const rtc::Callback0<void>& no_longer_used) {
+ std::function<void()> no_longer_used) {
return rtc::scoped_refptr<I420ABufferInterface>(
- new rtc::RefCountedObject<WrappedYuvaBuffer<I420ABufferInterface>>(
+ rtc::make_ref_counted<WrappedYuvaBuffer<I420ABufferInterface>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, a_plane, a_stride, no_longer_used));
}
+rtc::scoped_refptr<I422BufferInterface> WrapI422Buffer(
+ 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,
+ std::function<void()> no_longer_used) {
+ return rtc::scoped_refptr<I422BufferBase>(
+ rtc::make_ref_counted<WrappedYuvBuffer<I422BufferBase>>(
+ width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
+ v_stride, no_longer_used));
+}
+
rtc::scoped_refptr<I444BufferInterface> WrapI444Buffer(
int width,
int height,
@@ -244,9 +292,9 @@ rtc::scoped_refptr<I444BufferInterface> WrapI444Buffer(
int u_stride,
const uint8_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used) {
+ std::function<void()> no_longer_used) {
return rtc::scoped_refptr<I444BufferInterface>(
- new rtc::RefCountedObject<WrappedYuvBuffer<I444BufferBase>>(
+ rtc::make_ref_counted<WrappedYuvBuffer<I444BufferBase>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, no_longer_used));
}
@@ -261,17 +309,19 @@ rtc::scoped_refptr<PlanarYuvBuffer> WrapYuvBuffer(
int u_stride,
const uint8_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used) {
+ std::function<void()> no_longer_used) {
switch (type) {
case VideoFrameBuffer::Type::kI420:
return WrapI420Buffer(width, height, y_plane, y_stride, u_plane, u_stride,
v_plane, v_stride, no_longer_used);
+ case VideoFrameBuffer::Type::kI422:
+ return WrapI422Buffer(width, height, y_plane, y_stride, u_plane, u_stride,
+ v_plane, v_stride, no_longer_used);
case VideoFrameBuffer::Type::kI444:
return WrapI444Buffer(width, height, y_plane, y_stride, u_plane, u_stride,
v_plane, v_stride, no_longer_used);
default:
- FATAL() << "Unexpected frame buffer type.";
- return nullptr;
+ RTC_CHECK_NOTREACHED();
}
}
@@ -284,9 +334,25 @@ rtc::scoped_refptr<I010BufferInterface> WrapI010Buffer(
int u_stride,
const uint16_t* v_plane,
int v_stride,
- const rtc::Callback0<void>& no_longer_used) {
+ std::function<void()> no_longer_used) {
return rtc::scoped_refptr<I010BufferInterface>(
- new rtc::RefCountedObject<WrappedYuv16BBuffer<I010BufferBase>>(
+ rtc::make_ref_counted<WrappedYuv16BBuffer<I010BufferBase>>(
+ width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
+ v_stride, no_longer_used));
+}
+
+rtc::scoped_refptr<I210BufferInterface> WrapI210Buffer(
+ int width,
+ int height,
+ const uint16_t* y_plane,
+ int y_stride,
+ const uint16_t* u_plane,
+ int u_stride,
+ const uint16_t* v_plane,
+ int v_stride,
+ std::function<void()> no_longer_used) {
+ return rtc::scoped_refptr<I210BufferInterface>(
+ rtc::make_ref_counted<WrappedYuv16BBuffer<I210BufferBase>>(
width, height, y_plane, y_stride, u_plane, u_stride, v_plane,
v_stride, no_longer_used));
}