OLD | NEW |
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 Loading... |
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 | |
105 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { | 96 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { |
106 video_frame_buffer_ = videoFrame.video_frame_buffer(); | 97 video_frame_buffer_ = videoFrame.video_frame_buffer(); |
107 timestamp_rtp_ = videoFrame.timestamp_rtp_; | 98 timestamp_rtp_ = videoFrame.timestamp_rtp_; |
108 ntp_time_ms_ = videoFrame.ntp_time_ms_; | 99 ntp_time_ms_ = videoFrame.ntp_time_ms_; |
109 timestamp_us_ = videoFrame.timestamp_us_; | 100 timestamp_us_ = videoFrame.timestamp_us_; |
110 rotation_ = videoFrame.rotation_; | 101 rotation_ = videoFrame.rotation_; |
111 } | 102 } |
112 | 103 |
113 int VideoFrame::width() const { | 104 int VideoFrame::width() const { |
114 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; | 105 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; |
(...skipping 24 matching lines...) Expand all Loading... |
139 case kVideoCodecULPFEC: | 130 case kVideoCodecULPFEC: |
140 case kVideoCodecGeneric: | 131 case kVideoCodecGeneric: |
141 case kVideoCodecUnknown: | 132 case kVideoCodecUnknown: |
142 return 0; | 133 return 0; |
143 } | 134 } |
144 RTC_NOTREACHED(); | 135 RTC_NOTREACHED(); |
145 return 0; | 136 return 0; |
146 } | 137 } |
147 | 138 |
148 } // namespace webrtc | 139 } // namespace webrtc |
OLD | NEW |