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

Side by Side Diff: webrtc/common_video/video_frame.cc

Issue 1881953002: Delete method webrtc::VideoFrame::native_handle. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Make EqualFramesVector and ExpectEqualFramesVector ignore timestamps. Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 const int stride_uv = (width + 1) / 2; 106 const int stride_uv = (width + 1) / 2;
107 107
108 const uint8_t* buffer_y = buffer; 108 const uint8_t* buffer_y = buffer;
109 const uint8_t* buffer_u = buffer_y + stride_y * height; 109 const uint8_t* buffer_u = buffer_y + stride_y * height;
110 const uint8_t* buffer_v = buffer_u + stride_uv * ((height + 1) / 2); 110 const uint8_t* buffer_v = buffer_u + stride_uv * ((height + 1) / 2);
111 CreateFrame(buffer_y, buffer_u, buffer_v, width, height, stride_y, 111 CreateFrame(buffer_y, buffer_u, buffer_v, width, height, stride_y,
112 stride_uv, stride_uv, rotation); 112 stride_uv, stride_uv, rotation);
113 } 113 }
114 114
115 void VideoFrame::CopyFrame(const VideoFrame& videoFrame) { 115 void VideoFrame::CopyFrame(const VideoFrame& videoFrame) {
116 if (videoFrame.IsZeroSize()) { 116 ShallowCopy(videoFrame);
117 video_frame_buffer_ = nullptr; 117
118 } else if (videoFrame.native_handle()) { 118 // If backed by a plain memory buffer, create a new, non-shared, copy.
119 video_frame_buffer_ = videoFrame.video_frame_buffer(); 119 if (video_frame_buffer_ && !video_frame_buffer_->native_handle()) {
120 } else { 120 video_frame_buffer_ = I420Buffer::Copy(video_frame_buffer_);
121 CreateFrame(videoFrame.buffer(kYPlane), videoFrame.buffer(kUPlane),
122 videoFrame.buffer(kVPlane), videoFrame.width(),
123 videoFrame.height(), videoFrame.stride(kYPlane),
124 videoFrame.stride(kUPlane), videoFrame.stride(kVPlane),
125 kVideoRotation_0);
126 } 121 }
127
128 timestamp_ = videoFrame.timestamp_;
129 ntp_time_ms_ = videoFrame.ntp_time_ms_;
130 render_time_ms_ = videoFrame.render_time_ms_;
131 rotation_ = videoFrame.rotation_;
132 } 122 }
133 123
134 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { 124 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) {
135 video_frame_buffer_ = videoFrame.video_frame_buffer(); 125 video_frame_buffer_ = videoFrame.video_frame_buffer();
136 timestamp_ = videoFrame.timestamp_; 126 timestamp_ = videoFrame.timestamp_;
137 ntp_time_ms_ = videoFrame.ntp_time_ms_; 127 ntp_time_ms_ = videoFrame.ntp_time_ms_;
138 render_time_ms_ = videoFrame.render_time_ms_; 128 render_time_ms_ = videoFrame.render_time_ms_;
139 rotation_ = videoFrame.rotation_; 129 rotation_ = videoFrame.rotation_;
140 } 130 }
141 131
(...skipping 28 matching lines...) Expand all
170 } 160 }
171 161
172 int VideoFrame::height() const { 162 int VideoFrame::height() const {
173 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; 163 return video_frame_buffer_ ? video_frame_buffer_->height() : 0;
174 } 164 }
175 165
176 bool VideoFrame::IsZeroSize() const { 166 bool VideoFrame::IsZeroSize() const {
177 return !video_frame_buffer_; 167 return !video_frame_buffer_;
178 } 168 }
179 169
170 #if ENABLE_WEBRTC_VIDEOFRAME_NATIVE_HANDLE
perkj_webrtc 2016/04/13 05:44:08 ?
nisse-webrtc 2016/04/13 07:28:50 I wanted to disable the code temporarily for a cq
180 void* VideoFrame::native_handle() const { 171 void* VideoFrame::native_handle() const {
181 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; 172 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr;
182 } 173 }
174 #endif
183 175
184 rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const { 176 rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const {
185 return video_frame_buffer_; 177 return video_frame_buffer_;
186 } 178 }
187 179
188 void VideoFrame::set_video_frame_buffer( 180 void VideoFrame::set_video_frame_buffer(
189 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer) { 181 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer) {
190 video_frame_buffer_ = buffer; 182 video_frame_buffer_ = buffer;
191 } 183 }
192 184
193 VideoFrame VideoFrame::ConvertNativeToI420Frame() const { 185 VideoFrame VideoFrame::ConvertNativeToI420Frame() const {
194 RTC_DCHECK(native_handle()); 186 RTC_DCHECK(video_frame_buffer_->native_handle());
195 VideoFrame frame; 187 VideoFrame frame;
196 frame.ShallowCopy(*this); 188 frame.ShallowCopy(*this);
197 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer()); 189 frame.set_video_frame_buffer(video_frame_buffer_->NativeToI420Buffer());
198 return frame; 190 return frame;
199 } 191 }
200 192
201 size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) { 193 size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) {
202 switch (codec_type) { 194 switch (codec_type) {
203 case kVideoCodecVP8: 195 case kVideoCodecVP8:
204 case kVideoCodecVP9: 196 case kVideoCodecVP9:
205 return 0; 197 return 0;
206 case kVideoCodecH264: 198 case kVideoCodecH264:
207 return kBufferPaddingBytesH264; 199 return kBufferPaddingBytesH264;
208 case kVideoCodecI420: 200 case kVideoCodecI420:
209 case kVideoCodecRED: 201 case kVideoCodecRED:
210 case kVideoCodecULPFEC: 202 case kVideoCodecULPFEC:
211 case kVideoCodecGeneric: 203 case kVideoCodecGeneric:
212 case kVideoCodecUnknown: 204 case kVideoCodecUnknown:
213 return 0; 205 return 0;
214 } 206 }
215 RTC_NOTREACHED(); 207 RTC_NOTREACHED();
216 return 0; 208 return 0;
217 } 209 }
218 210
219 } // namespace webrtc 211 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698