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

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

Issue 2397943003: Revert of Delete webrtc::VideoFrame::CopyFrame. (Closed)
Patch Set: Created 4 years, 2 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 const int stride_y = width; 86 const int stride_y = width;
87 const int stride_uv = (width + 1) / 2; 87 const int stride_uv = (width + 1) / 2;
88 88
89 const uint8_t* buffer_y = buffer; 89 const uint8_t* buffer_y = buffer;
90 const uint8_t* buffer_u = buffer_y + stride_y * height; 90 const uint8_t* buffer_u = buffer_y + stride_y * height;
91 const uint8_t* buffer_v = buffer_u + stride_uv * ((height + 1) / 2); 91 const uint8_t* buffer_v = buffer_u + stride_uv * ((height + 1) / 2);
92 CreateFrame(buffer_y, buffer_u, buffer_v, width, height, stride_y, 92 CreateFrame(buffer_y, buffer_u, buffer_v, width, height, stride_y,
93 stride_uv, stride_uv, rotation); 93 stride_uv, stride_uv, rotation);
94 } 94 }
95 95
96 void VideoFrame::CopyFrame(const VideoFrame& videoFrame) {
97 ShallowCopy(videoFrame);
98
99 // If backed by a plain memory buffer, create a new, non-shared, copy.
100 if (video_frame_buffer_ && !video_frame_buffer_->native_handle()) {
101 video_frame_buffer_ = I420Buffer::Copy(video_frame_buffer_);
102 }
103 }
104
96 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { 105 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) {
97 video_frame_buffer_ = videoFrame.video_frame_buffer(); 106 video_frame_buffer_ = videoFrame.video_frame_buffer();
98 timestamp_rtp_ = videoFrame.timestamp_rtp_; 107 timestamp_rtp_ = videoFrame.timestamp_rtp_;
99 ntp_time_ms_ = videoFrame.ntp_time_ms_; 108 ntp_time_ms_ = videoFrame.ntp_time_ms_;
100 timestamp_us_ = videoFrame.timestamp_us_; 109 timestamp_us_ = videoFrame.timestamp_us_;
101 rotation_ = videoFrame.rotation_; 110 rotation_ = videoFrame.rotation_;
102 } 111 }
103 112
104 int VideoFrame::width() const { 113 int VideoFrame::width() const {
105 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; 114 return video_frame_buffer_ ? video_frame_buffer_->width() : 0;
(...skipping 24 matching lines...) Expand all
130 case kVideoCodecULPFEC: 139 case kVideoCodecULPFEC:
131 case kVideoCodecGeneric: 140 case kVideoCodecGeneric:
132 case kVideoCodecUnknown: 141 case kVideoCodecUnknown:
133 return 0; 142 return 0;
134 } 143 }
135 RTC_NOTREACHED(); 144 RTC_NOTREACHED();
136 return 0; 145 return 0;
137 } 146 }
138 147
139 } // namespace webrtc 148 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/i420_video_frame_unittest.cc ('k') | webrtc/modules/video_coding/codecs/vp8/test/vp8_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698