Remove deprecated interface in I420BufferInterface::GetI420
Bug: none
Change-Id: I55895a360308fd0be79099f2466a7487ef10ce47
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134463
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27841}
diff --git a/api/video/video_frame_buffer.cc b/api/video/video_frame_buffer.cc
index 1e5320d..b9fd9cd 100644
--- a/api/video/video_frame_buffer.cc
+++ b/api/video/video_frame_buffer.cc
@@ -14,26 +14,10 @@
namespace webrtc {
-rtc::scoped_refptr<I420BufferInterface> VideoFrameBuffer::GetI420() {
- if (type() == Type::kI420 || type() == Type::kI420A) {
- return static_cast<I420BufferInterface*>(this);
- } else {
- return nullptr;
- }
-}
-
-rtc::scoped_refptr<const I420BufferInterface> VideoFrameBuffer::GetI420()
- const {
- if (type() == Type::kI420 || type() == Type::kI420A) {
- return static_cast<const I420BufferInterface*>(this);
- } else {
- return nullptr;
- }
-}
-
-I420ABufferInterface* VideoFrameBuffer::GetI420A() {
- RTC_CHECK(type() == Type::kI420A);
- return static_cast<I420ABufferInterface*>(this);
+const I420BufferInterface* VideoFrameBuffer::GetI420() const {
+ // Overridden by subclasses that can return an I420 buffer without any
+ // conversion, in particular, I420BufferInterface.
+ return nullptr;
}
const I420ABufferInterface* VideoFrameBuffer::GetI420A() const {
@@ -41,21 +25,11 @@
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);
}
-I010BufferInterface* VideoFrameBuffer::GetI010() {
- RTC_CHECK(type() == Type::kI010);
- return static_cast<I010BufferInterface*>(this);
-}
-
const I010BufferInterface* VideoFrameBuffer::GetI010() const {
RTC_CHECK(type() == Type::kI010);
return static_cast<const I010BufferInterface*>(this);
@@ -77,6 +51,10 @@
return this;
}
+const I420BufferInterface* I420BufferInterface::GetI420() const {
+ return this;
+}
+
VideoFrameBuffer::Type I420ABufferInterface::type() const {
return Type::kI420A;
}
diff --git a/api/video/video_frame_buffer.h b/api/video/video_frame_buffer.h
index af18e57..3b8db14 100644
--- a/api/video/video_frame_buffer.h
+++ b/api/video/video_frame_buffer.h
@@ -71,18 +71,12 @@
// WebrtcVideoFrameAdapter in Chrome - it's I420 buffer backed by a shared
// memory buffer. Therefore it must have type kNative. Yet, ToI420()
// doesn't affect binary data at all. Another example is any I420A buffer.
- // TODO(magjed): Return raw pointers for GetI420 once deprecated interface is
- // removed.
- virtual rtc::scoped_refptr<I420BufferInterface> GetI420();
- virtual rtc::scoped_refptr<const I420BufferInterface> GetI420() const;
+ virtual const I420BufferInterface* GetI420() const;
// These functions should only be called if type() is of the correct type.
// Calling with a different type will result in a crash.
- I420ABufferInterface* GetI420A();
const I420ABufferInterface* GetI420A() const;
- I444BufferInterface* GetI444();
const I444BufferInterface* GetI444() const;
- I010BufferInterface* GetI010();
const I010BufferInterface* GetI010() const;
protected:
@@ -127,6 +121,7 @@
int ChromaHeight() const final;
rtc::scoped_refptr<I420BufferInterface> ToI420() final;
+ const I420BufferInterface* GetI420() const final;
protected:
~I420BufferInterface() override {}
diff --git a/common_video/video_frame_unittest.cc b/common_video/video_frame_unittest.cc
index b7d8c30..70dedc9 100644
--- a/common_video/video_frame_unittest.cc
+++ b/common_video/video_frame_unittest.cc
@@ -320,9 +320,9 @@
VideoFrame frame2(frame1);
EXPECT_EQ(frame1.video_frame_buffer(), frame2.video_frame_buffer());
- rtc::scoped_refptr<I420BufferInterface> yuv1 =
+ const webrtc::I420BufferInterface* yuv1 =
frame1.video_frame_buffer()->GetI420();
- rtc::scoped_refptr<I420BufferInterface> yuv2 =
+ const webrtc::I420BufferInterface* yuv2 =
frame2.video_frame_buffer()->GetI420();
EXPECT_EQ(yuv1->DataY(), yuv2->DataY());
EXPECT_EQ(yuv1->DataU(), yuv2->DataU());
diff --git a/examples/unityplugin/video_observer.cc b/examples/unityplugin/video_observer.cc
index a78ef57..7e33b08 100644
--- a/examples/unityplugin/video_observer.cc
+++ b/examples/unityplugin/video_observer.cc
@@ -33,7 +33,7 @@
} else {
// The buffer has alpha channel.
- webrtc::I420ABufferInterface* i420a_buffer = buffer->GetI420A();
+ const webrtc::I420ABufferInterface* i420a_buffer = buffer->GetI420A();
OnI420FrameReady(i420a_buffer->DataY(), i420a_buffer->DataU(),
i420a_buffer->DataV(), i420a_buffer->DataA(),
diff --git a/modules/video_coding/codecs/h264/h264_decoder_impl.cc b/modules/video_coding/codecs/h264/h264_decoder_impl.cc
index 5c83d69..580b8a8 100644
--- a/modules/video_coding/codecs/h264/h264_decoder_impl.cc
+++ b/modules/video_coding/codecs/h264/h264_decoder_impl.cc
@@ -283,7 +283,7 @@
VideoFrame* input_frame =
static_cast<VideoFrame*>(av_buffer_get_opaque(av_frame_->buf[0]));
RTC_DCHECK(input_frame);
- rtc::scoped_refptr<webrtc::I420BufferInterface> i420_buffer =
+ const webrtc::I420BufferInterface* i420_buffer =
input_frame->video_frame_buffer()->GetI420();
RTC_CHECK_EQ(av_frame_->data[kYPlaneIndex], i420_buffer->DataY());
RTC_CHECK_EQ(av_frame_->data[kUPlaneIndex], i420_buffer->DataU());
diff --git a/modules/video_coding/codecs/vp9/vp9_impl.cc b/modules/video_coding/codecs/vp9/vp9_impl.cc
index abb54b6..45dacfd 100644
--- a/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -912,7 +912,8 @@
// Keep reference to buffer until encode completes.
rtc::scoped_refptr<I420BufferInterface> i420_buffer;
- rtc::scoped_refptr<I010BufferInterface> i010_buffer;
+ const I010BufferInterface* i010_buffer;
+ rtc::scoped_refptr<const I010BufferInterface> i010_copy;
switch (profile_) {
case VP9Profile::kProfile0: {
i420_buffer = input_image.video_frame_buffer()->ToI420();
@@ -935,8 +936,9 @@
break;
}
default: {
- i010_buffer =
+ i010_copy =
I010Buffer::Copy(*input_image.video_frame_buffer()->ToI420());
+ i010_buffer = i010_copy.get();
}
}
raw_->planes[VPX_PLANE_Y] = const_cast<uint8_t*>(