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

Side by Side Diff: webrtc/common_video/libyuv/webrtc_libyuv.cc

Issue 2332213011: Reland of Optimize Android NV12 capture (Closed)
Patch Set: Fix dst vs src width/height bug 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/include/webrtc_libyuv.h ('k') | no next file » | 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 ref_frame->video_frame_buffer()->DataV(), 334 ref_frame->video_frame_buffer()->DataV(),
335 ref_frame->video_frame_buffer()->StrideV(), 335 ref_frame->video_frame_buffer()->StrideV(),
336 test_frame->video_frame_buffer()->DataY(), 336 test_frame->video_frame_buffer()->DataY(),
337 test_frame->video_frame_buffer()->StrideY(), 337 test_frame->video_frame_buffer()->StrideY(),
338 test_frame->video_frame_buffer()->DataU(), 338 test_frame->video_frame_buffer()->DataU(),
339 test_frame->video_frame_buffer()->StrideU(), 339 test_frame->video_frame_buffer()->StrideU(),
340 test_frame->video_frame_buffer()->DataV(), 340 test_frame->video_frame_buffer()->DataV(),
341 test_frame->video_frame_buffer()->StrideV(), 341 test_frame->video_frame_buffer()->StrideV(),
342 test_frame->width(), test_frame->height()); 342 test_frame->width(), test_frame->height());
343 } 343 }
344
345 void NV12ToI420Scaler::NV12ToI420Scale(
346 const uint8_t* src_y, int src_stride_y,
347 const uint8_t* src_uv, int src_stride_uv,
348 int src_width, int src_height,
349 uint8_t* dst_y, int dst_stride_y,
350 uint8_t* dst_u, int dst_stride_u,
351 uint8_t* dst_v, int dst_stride_v,
352 int dst_width, int dst_height) {
353 if (src_width == dst_width && src_height == dst_height) {
354 // No scaling.
355 tmp_uv_planes_.clear();
356 tmp_uv_planes_.shrink_to_fit();
357 libyuv::NV12ToI420(
358 src_y, src_stride_y,
359 src_uv, src_stride_uv,
360 dst_y, dst_stride_y,
361 dst_u, dst_stride_u,
362 dst_v, dst_stride_v,
363 src_width, src_height);
364 return;
365 }
366
367 // Scaling.
368 // Allocate temporary memory for spitting UV planes.
369 const int src_uv_width = (src_width + 1) / 2;
370 const int src_uv_height = (src_height + 1) / 2;
371 tmp_uv_planes_.resize(src_uv_width * src_uv_height * 2);
372 tmp_uv_planes_.shrink_to_fit();
373
374 // Split source UV plane into separate U and V plane using the temporary data.
375 uint8_t* const src_u = tmp_uv_planes_.data();
376 uint8_t* const src_v = tmp_uv_planes_.data() + src_uv_width * src_uv_height;
377 libyuv::SplitUVPlane(src_uv, src_stride_uv,
378 src_u, src_uv_width,
379 src_v, src_uv_width,
380 src_uv_width, src_uv_height);
381
382 // Scale the planes into the destination.
383 libyuv::I420Scale(src_y, src_stride_y,
384 src_u, src_uv_width,
385 src_v, src_uv_width,
386 src_width, src_height,
387 dst_y, dst_stride_y,
388 dst_u, dst_stride_u,
389 dst_v, dst_stride_v,
390 dst_width, dst_height,
391 libyuv::kFilterBox);
392 }
393
344 } // namespace webrtc 394 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/common_video/libyuv/include/webrtc_libyuv.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698