Add alpha channel to VideoFrameBuffer containers
- Add alpha accessors to PlanarYuvBuffer interface, null by defualt.
- Add WrapI420ABuffer() that creates a container which implements these
accessors.
- Show the use via StereoDecoderAdapter.
This CL is the step 2 for adding alpha channel support over the wire in webrtc.
See https://webrtc-review.googlesource.com/c/src/+/7800 for the experimental
CL that gives an idea about how it will come together.
Design Doc: https://goo.gl/sFeSUT
Bug: webrtc:7671
Change-Id: Id5691cde00088ec811b63d89080d33ad2d6e3939
Reviewed-on: https://webrtc-review.googlesource.com/21130
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Emircan Uysaler <emircan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20635}
diff --git a/common_video/video_frame_buffer.cc b/common_video/video_frame_buffer.cc
index 19649cf..9c8955c 100644
--- a/common_video/video_frame_buffer.cc
+++ b/common_video/video_frame_buffer.cc
@@ -96,6 +96,8 @@
v_stride_(v_stride),
no_longer_used_cb_(no_longer_used) {}
+ ~WrappedYuvBuffer() override { no_longer_used_cb_(); }
+
int width() const override { return width_; }
int height() const override { return height_; }
@@ -115,8 +117,6 @@
private:
friend class rtc::RefCountedObject<WrappedYuvBuffer>;
- ~WrappedYuvBuffer() override { no_longer_used_cb_(); }
-
const int width_;
const int height_;
const uint8_t* const y_plane_;
@@ -128,6 +128,41 @@
rtc::Callback0<void> no_longer_used_cb_;
};
+// Template to implement a wrapped buffer for a I4??BufferInterface.
+template <typename BaseWithA>
+class WrappedYuvaBuffer : public WrappedYuvBuffer<BaseWithA> {
+ public:
+ WrappedYuvaBuffer(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 uint8_t* a_plane,
+ int a_stride,
+ const rtc::Callback0<void>& no_longer_used)
+ : WrappedYuvBuffer<BaseWithA>(width,
+ height,
+ y_plane,
+ y_stride,
+ u_plane,
+ u_stride,
+ v_plane,
+ v_stride,
+ no_longer_used),
+ a_plane_(a_plane),
+ a_stride_(a_stride) {}
+
+ const uint8_t* DataA() const override { return a_plane_; }
+ int StrideA() const override { return a_stride_; }
+
+ private:
+ const uint8_t* const a_plane_;
+ const int a_stride_;
+};
+
rtc::scoped_refptr<I420BufferInterface> WrapI420Buffer(
int width,
int height,
@@ -144,6 +179,24 @@
v_stride, no_longer_used));
}
+rtc::scoped_refptr<I420ABufferInterface> WrapI420ABuffer(
+ 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 uint8_t* a_plane,
+ int a_stride,
+ const rtc::Callback0<void>& no_longer_used) {
+ return rtc::scoped_refptr<I420ABufferInterface>(
+ new rtc::RefCountedObject<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<I444BufferInterface> WrapI444Buffer(
int width,
int height,