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

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

Issue 2278883002: Move MutableDataY{,U,V} methods to I420Buffer only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Delete unused variable. 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 InitToEmptyBuffer(new_width, new_height); 132 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
133 webrtc::I420Buffer::Create(new_width, new_height);
134 video_frame_buffer_ = buffer;
133 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation; 135 rotation_ = apply_rotation ? webrtc::kVideoRotation_0 : rotation;
134 136
135 int horiz_crop = ((w - dw) / 2) & ~1; 137 int horiz_crop = ((w - dw) / 2) & ~1;
136 // ARGB on Windows has negative height. 138 // ARGB on Windows has negative height.
137 // The sample's layout in memory is normal, so just correct crop. 139 // The sample's layout in memory is normal, so just correct crop.
138 int vert_crop = ((abs(h) - dh) / 2) & ~1; 140 int vert_crop = ((abs(h) - dh) / 2) & ~1;
139 // Conversion functions expect negative height to flip the image. 141 // Conversion functions expect negative height to flip the image.
140 int idh = (h < 0) ? -dh : dh; 142 int idh = (h < 0) ? -dh : dh;
141 int r = libyuv::ConvertToI420( 143 int r = libyuv::ConvertToI420(
142 sample, sample_size, 144 sample, sample_size,
143 video_frame_buffer_->MutableDataY(), 145 buffer->MutableDataY(), buffer->StrideY(),
144 video_frame_buffer_->StrideY(), 146 buffer->MutableDataU(), buffer->StrideU(),
145 video_frame_buffer_->MutableDataU(), 147 buffer->MutableDataV(), buffer->StrideV(),
146 video_frame_buffer_->StrideU(), 148 horiz_crop, vert_crop, w, h, dw, idh,
147 video_frame_buffer_->MutableDataV(),
148 video_frame_buffer_->StrideV(),
149 horiz_crop, vert_crop,
150 w, h,
151 dw, idh,
152 static_cast<libyuv::RotationMode>( 149 static_cast<libyuv::RotationMode>(
153 apply_rotation ? rotation : webrtc::kVideoRotation_0), 150 apply_rotation ? rotation : webrtc::kVideoRotation_0),
154 format); 151 format);
155 if (r) { 152 if (r) {
156 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format) 153 LOG(LS_ERROR) << "Error parsing format: " << GetFourccName(format)
157 << " return code : " << r; 154 << " return code : " << r;
158 return false; 155 return false;
159 } 156 }
160 timestamp_us_ = timestamp_us; 157 timestamp_us_ = timestamp_us;
161 return true; 158 return true;
162 } 159 }
163 160
164 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) { 161 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h) {
165 video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h); 162 video_frame_buffer_ = webrtc::I420Buffer::Create(w, h);
166 rotation_ = webrtc::kVideoRotation_0; 163 rotation_ = webrtc::kVideoRotation_0;
167 } 164 }
168 165
169 } // namespace cricket 166 } // 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