Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: webrtc/common_video/video_frame_buffer.cc

Issue 1304143003: VideoFrameBuffer: Make non-const data access explicit (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/common_video/video_frame_buffer.cc
diff --git a/webrtc/common_video/video_frame_buffer.cc b/webrtc/common_video/video_frame_buffer.cc
index cad33e8e97d4968c813d649de5d5dbc37b9bb05c..4c15958041cc05629e47fee92d0cf6a69ede626a 100644
--- a/webrtc/common_video/video_frame_buffer.cc
+++ b/webrtc/common_video/video_frame_buffer.cc
@@ -24,6 +24,11 @@ static void NoLongerUsedCallback(rtc::scoped_refptr<VideoFrameBuffer> dummy) {}
} // anonymous namespace
+uint8_t* VideoFrameBuffer::MutableData(PlaneType type) {
+ RTC_NOTREACHED();
+ return nullptr;
+}
+
VideoFrameBuffer::~VideoFrameBuffer() {}
I420Buffer::I420Buffer(int width, int height)
@@ -76,7 +81,7 @@ const uint8_t* I420Buffer::data(PlaneType type) const {
}
}
-uint8_t* I420Buffer::data(PlaneType type) {
+uint8_t* I420Buffer::MutableData(PlaneType type) {
DCHECK(HasOneRef());
return const_cast<uint8_t*>(
static_cast<const VideoFrameBuffer*>(this)->data(type));
@@ -127,11 +132,6 @@ const uint8_t* NativeHandleBuffer::data(PlaneType type) const {
return nullptr;
}
-uint8_t* NativeHandleBuffer::data(PlaneType type) {
- RTC_NOTREACHED(); // Should not be called.
- return nullptr;
-}
-
int NativeHandleBuffer::stride(PlaneType type) const {
RTC_NOTREACHED(); // Should not be called.
return 0;
@@ -187,11 +187,6 @@ const uint8_t* WrappedI420Buffer::data(PlaneType type) const {
}
}
-uint8_t* WrappedI420Buffer::data(PlaneType type) {
- RTC_NOTREACHED();
- return nullptr;
-}
-
int WrappedI420Buffer::stride(PlaneType type) const {
switch (type) {
case kYPlane:
@@ -232,13 +227,11 @@ rtc::scoped_refptr<VideoFrameBuffer> ShallowCenterCrop(
const int offset_x = uv_offset_x * 2;
const int offset_y = uv_offset_y * 2;
- // Const cast to call the correct const-version of data().
- const VideoFrameBuffer* const_buffer(buffer.get());
- const uint8_t* y_plane = const_buffer->data(kYPlane) +
+ const uint8_t* y_plane = buffer->data(kYPlane) +
buffer->stride(kYPlane) * offset_y + offset_x;
- const uint8_t* u_plane = const_buffer->data(kUPlane) +
+ const uint8_t* u_plane = buffer->data(kUPlane) +
buffer->stride(kUPlane) * uv_offset_y + uv_offset_x;
- const uint8_t* v_plane = const_buffer->data(kVPlane) +
+ const uint8_t* v_plane = buffer->data(kVPlane) +
buffer->stride(kVPlane) * uv_offset_y + uv_offset_x;
return new rtc::RefCountedObject<WrappedI420Buffer>(
cropped_width, cropped_height,
« no previous file with comments | « webrtc/common_video/video_frame.cc ('k') | webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698