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

Side by Side Diff: webrtc/media/engine/webrtcvideoframe.cc

Issue 2354223002: Revert of Move MutableDataY{,U,V} methods to I420Buffer only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 3 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // Set up a new buffer. 122 // Set up a new buffer.
123 // TODO(fbarchard): Support lazy allocation. 123 // TODO(fbarchard): Support lazy allocation.
124 int new_width = dw; 124 int new_width = dw;
125 int new_height = dh; 125 int new_height = dh;
126 // If rotated swap width, height. 126 // If rotated swap width, height.
127 if (apply_rotation && (rotation == 90 || rotation == 270)) { 127 if (apply_rotation && (rotation == 90 || rotation == 270)) {
128 new_width = dh; 128 new_width = dh;
129 new_height = dw; 129 new_height = dw;
130 } 130 }
131 131
132 rtc::scoped_refptr<webrtc::I420Buffer> buffer = 132 InitToEmptyBuffer(new_width, new_height);
133 webrtc::I420Buffer::Create(new_width, new_height);
134 video_frame_buffer_ = buffer;
135 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation; 133 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
136 134
137 int horiz_crop = ((w - dw) / 2) & ~1; 135 int horiz_crop = ((w - dw) / 2) & ~1;
138 // ARGB on Windows has negative height. 136 // ARGB on Windows has negative height.
139 // The sample's layout in memory is normal, so just correct crop. 137 // The sample's layout in memory is normal, so just correct crop.
140 int vert_crop = ((abs(h) - dh) / 2) & ~1; 138 int vert_crop = ((abs(h) - dh) / 2) & ~1;
141 // Conversion functions expect negative height to flip the image. 139 // Conversion functions expect negative height to flip the image.
142 int idh = (h < 0) ? -dh : dh; 140 int idh = (h < 0) ? -dh : dh;
143 int r = libyuv::ConvertToI420( 141 int r = libyuv::ConvertToI420(
144 sample, sample_size, 142 sample, sample_size,
145 buffer->MutableDataY(), buffer->StrideY(), 143 video_frame_buffer_->MutableDataY(),
146 buffer->MutableDataU(), buffer->StrideU(), 144 video_frame_buffer_->StrideY(),
147 buffer->MutableDataV(), buffer->StrideV(), 145 video_frame_buffer_->MutableDataU(),
148 horiz_crop, vert_crop, w, h, dw, idh, 146 video_frame_buffer_->StrideU(),
147 video_frame_buffer_->MutableDataV(),
148 video_frame_buffer_->StrideV(),
149 horiz_crop, vert_crop,
150 w, h,
151 dw, idh,
149 static_cast<libyuv::RotationMode>( 152 static_cast<libyuv::RotationMode>(
150 apply_rotation ? rotation : webrtc::kVideoRotation_0), 153 apply_rotation ? rotation : webrtc::kVideoRotation_0),
151 format); 154 format);
152 if (r) { 155 if (r) {
153 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format) 156 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format)
154 << " return code : " << r; 157 << " return code : " << r;
155 return false; 158 return false;
156 } 159 }
157 timestamp_us_ = timestamp_us; 160 timestamp_us_ = timestamp_us;
158 return true; 161 return true;
159 } 162 }
160 163
161 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) { 164 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) {
162 video_frame_buffer_ = webrtc::I420Buffer::Create(w, h); 165 video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h);
163 rotation_ = webrtc::kVideoRotation_0; 166 rotation_ = webrtc::kVideoRotation_0;
164 } 167 }
165 168
166 } // namespace cricket 169 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2_unittest.cc ('k') | webrtc/modules/video_capture/test/video_capture_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698