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

Side by Side Diff: webrtc/common_video/libyuv/webrtc_libyuv.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
« no previous file with comments | « webrtc/common_video/libyuv/libyuv_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int stride, 96 int stride,
97 FILE* file) { 97 FILE* file) {
98 for (int i = 0; i < height; i++, buf += stride) { 98 for (int i = 0; i < height; i++, buf += stride) {
99 if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width)) 99 if (fwrite(buf, 1, width, file) != static_cast<unsigned int>(width))
100 return -1; 100 return -1;
101 } 101 }
102 return 0; 102 return 0;
103 } 103 }
104 104
105 // TODO(nisse): Belongs with the test code? 105 // TODO(nisse): Belongs with the test code?
106 int PrintVideoFrame(const VideoFrame& frame, FILE* file) { 106 int PrintVideoFrame(const VideoFrameBuffer& frame, FILE* file) {
107 if (file == NULL) 107 int width = frame.width();
108 return -1; 108 int height = frame.height();
109 if (frame.IsZeroSize())
110 return -1;
111 int width = frame.video_frame_buffer()->width();
112 int height = frame.video_frame_buffer()->height();
113 int chroma_width = (width + 1) / 2; 109 int chroma_width = (width + 1) / 2;
114 int chroma_height = (height + 1) / 2; 110 int chroma_height = (height + 1) / 2;
115 111
116 if (PrintPlane(frame.video_frame_buffer()->DataY(), width, height, 112 if (PrintPlane(frame.DataY(), width, height,
117 frame.video_frame_buffer()->StrideY(), file) < 0) { 113 frame.StrideY(), file) < 0) {
118 return -1; 114 return -1;
119 } 115 }
120 if (PrintPlane(frame.video_frame_buffer()->DataU(), 116 if (PrintPlane(frame.DataU(),
121 chroma_width, chroma_height, 117 chroma_width, chroma_height,
122 frame.video_frame_buffer()->StrideU(), file) < 0) { 118 frame.StrideU(), file) < 0) {
123 return -1; 119 return -1;
124 } 120 }
125 if (PrintPlane(frame.video_frame_buffer()->DataV(), 121 if (PrintPlane(frame.DataV(),
126 chroma_width, chroma_height, 122 chroma_width, chroma_height,
127 frame.video_frame_buffer()->StrideV(), file) < 0) { 123 frame.StrideV(), file) < 0) {
128 return -1; 124 return -1;
129 } 125 }
130 return 0; 126 return 0;
131 } 127 }
132 128
129 int PrintVideoFrame(const VideoFrame& frame, FILE* file) {
130 if (frame.IsZeroSize())
131 return -1;
132 return PrintVideoFrame(*frame.video_frame_buffer(), file);
133 }
134
133 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame, 135 int ExtractBuffer(const rtc::scoped_refptr<VideoFrameBuffer>& input_frame,
134 size_t size, 136 size_t size,
135 uint8_t* buffer) { 137 uint8_t* buffer) {
136 assert(buffer); 138 assert(buffer);
137 if (!input_frame) 139 if (!input_frame)
138 return -1; 140 return -1;
139 int width = input_frame->width(); 141 int width = input_frame->width();
140 int height = input_frame->height(); 142 int height = input_frame->height();
141 size_t length = CalcBufferSize(kI420, width, height); 143 size_t length = CalcBufferSize(kI420, width, height);
142 if (size < length) { 144 if (size < length) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 244
243 // TODO(nisse): Delete this wrapper, let callers use libyuv directly. 245 // TODO(nisse): Delete this wrapper, let callers use libyuv directly.
244 int ConvertToI420(VideoType src_video_type, 246 int ConvertToI420(VideoType src_video_type,
245 const uint8_t* src_frame, 247 const uint8_t* src_frame,
246 int crop_x, 248 int crop_x,
247 int crop_y, 249 int crop_y,
248 int src_width, 250 int src_width,
249 int src_height, 251 int src_height,
250 size_t sample_size, 252 size_t sample_size,
251 VideoRotation rotation, 253 VideoRotation rotation,
252 VideoFrame* dst_frame) { 254 I420Buffer* dst_buffer) {
253 int dst_width = dst_frame->width(); 255 int dst_width = dst_buffer->width();
254 int dst_height = dst_frame->height(); 256 int dst_height = dst_buffer->height();
255 // LibYuv expects pre-rotation values for dst. 257 // LibYuv expects pre-rotation values for dst.
256 // Stride values should correspond to the destination values. 258 // Stride values should correspond to the destination values.
257 if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) { 259 if (rotation == kVideoRotation_90 || rotation == kVideoRotation_270) {
258 dst_width = dst_frame->height(); 260 std::swap(dst_width, dst_height);
259 dst_height = dst_frame->width();
260 } 261 }
261 return libyuv::ConvertToI420( 262 return libyuv::ConvertToI420(
262 src_frame, sample_size, 263 src_frame, sample_size,
263 dst_frame->video_frame_buffer()->MutableDataY(), 264 dst_buffer->MutableDataY(), dst_buffer->StrideY(),
264 dst_frame->video_frame_buffer()->StrideY(), 265 dst_buffer->MutableDataU(), dst_buffer->StrideU(),
265 dst_frame->video_frame_buffer()->MutableDataU(), 266 dst_buffer->MutableDataV(), dst_buffer->StrideV(),
266 dst_frame->video_frame_buffer()->StrideU(),
267 dst_frame->video_frame_buffer()->MutableDataV(),
268 dst_frame->video_frame_buffer()->StrideV(),
269 crop_x, crop_y, 267 crop_x, crop_y,
270 src_width, src_height, 268 src_width, src_height,
271 dst_width, dst_height, 269 dst_width, dst_height,
272 ConvertRotationMode(rotation), 270 ConvertRotationMode(rotation),
273 ConvertVideoType(src_video_type)); 271 ConvertVideoType(src_video_type));
274 } 272 }
275 273
276 int ConvertFromI420(const VideoFrame& src_frame, 274 int ConvertFromI420(const VideoFrame& src_frame,
277 VideoType dst_video_type, 275 VideoType dst_video_type,
278 int dst_sample_size, 276 int dst_sample_size,
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 src_v, src_uv_width, 383 src_v, src_uv_width,
386 src_width, src_height, 384 src_width, src_height,
387 dst_y, dst_stride_y, 385 dst_y, dst_stride_y,
388 dst_u, dst_stride_u, 386 dst_u, dst_stride_u,
389 dst_v, dst_stride_v, 387 dst_v, dst_stride_v,
390 dst_width, dst_height, 388 dst_width, dst_height,
391 libyuv::kFilterBox); 389 libyuv::kFilterBox);
392 } 390 }
393 391
394 } // namespace webrtc 392 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/libyuv/libyuv_unittest.cc ('k') | webrtc/common_video/video_frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698