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

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