Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 test_buffer.DataV(), test_buffer.StrideV(), | 333 test_buffer.DataV(), test_buffer.StrideV(), |
| 334 test_buffer.width(), test_buffer.height()); | 334 test_buffer.width(), test_buffer.height()); |
| 335 } | 335 } |
| 336 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { | 336 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { |
| 337 if (!ref_frame || !test_frame) | 337 if (!ref_frame || !test_frame) |
| 338 return -1; | 338 return -1; |
| 339 return I420SSIM(*ref_frame->video_frame_buffer(), | 339 return I420SSIM(*ref_frame->video_frame_buffer(), |
| 340 *test_frame->video_frame_buffer()); | 340 *test_frame->video_frame_buffer()); |
| 341 } | 341 } |
| 342 | 342 |
| 343 void NV12Scale(std::vector<uint8_t>* tmp_buffer, | |
|
tkchin_webrtc
2016/10/19 00:48:32
might be worth comparing performance against:
http
magjed_webrtc
2016/10/19 13:19:34
Interesting, I will compare performance if I have
tkchin_webrtc
2016/10/19 22:50:17
Acknowledged.
| |
| 344 const uint8_t* src_y, int src_stride_y, | |
| 345 const uint8_t* src_uv, int src_stride_uv, | |
| 346 int src_width, int src_height, | |
| 347 uint8_t* dst_y, int dst_stride_y, | |
| 348 uint8_t* dst_uv, int dst_stride_uv, | |
| 349 int dst_width, int dst_height) { | |
| 350 const int src_chroma_width = (src_width + 1) / 2; | |
| 351 const int src_chroma_height = (src_height + 1) / 2; | |
| 352 | |
| 353 if (src_width == dst_width && src_height == dst_height) { | |
| 354 // No scaling. | |
| 355 tmp_buffer->clear(); | |
| 356 tmp_buffer->shrink_to_fit(); | |
| 357 libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, src_width, | |
| 358 src_height); | |
| 359 libyuv::CopyPlane(src_uv, src_stride_uv, dst_uv, dst_stride_uv, | |
| 360 src_chroma_width * 2, src_chroma_height); | |
| 361 return; | |
| 362 } | |
| 363 | |
| 364 // Scaling. | |
| 365 // Allocate temporary memory for spitting UV planes and scaling them. | |
| 366 const int dst_chroma_width = (dst_width + 1) / 2; | |
| 367 const int dst_chroma_height = (dst_height + 1) / 2; | |
| 368 tmp_buffer->resize(src_chroma_width * src_chroma_height * 2 + | |
| 369 dst_chroma_width * dst_chroma_height * 2); | |
| 370 tmp_buffer->shrink_to_fit(); | |
| 371 | |
| 372 uint8_t* const src_u = tmp_buffer->data(); | |
| 373 uint8_t* const src_v = src_u + src_chroma_width * src_chroma_height; | |
| 374 uint8_t* const dst_u = src_v + src_chroma_width * src_chroma_height; | |
| 375 uint8_t* const dst_v = dst_u + dst_chroma_width * dst_chroma_height; | |
| 376 | |
| 377 // Split source UV plane into separate U and V plane using the temporary data. | |
| 378 libyuv::SplitUVPlane(src_uv, src_stride_uv, | |
| 379 src_u, src_chroma_width, | |
| 380 src_v, src_chroma_width, | |
| 381 src_chroma_width, src_chroma_height); | |
| 382 | |
| 383 // Scale the planes. | |
| 384 libyuv::I420Scale(src_y, src_stride_y, | |
| 385 src_u, src_chroma_width, | |
| 386 src_v, src_chroma_width, | |
| 387 src_width, src_height, | |
| 388 dst_y, dst_stride_y, | |
| 389 dst_u, dst_chroma_width, | |
| 390 dst_v, dst_chroma_width, | |
| 391 dst_width, dst_height, | |
| 392 libyuv::kFilterBox); | |
| 393 | |
| 394 // Merge the UV planes into the destination. | |
| 395 libyuv::MergeUVPlane(dst_u, dst_chroma_width, | |
| 396 dst_v, dst_chroma_width, | |
| 397 dst_uv, dst_stride_uv, | |
| 398 dst_chroma_width, dst_chroma_height); | |
| 399 } | |
| 400 | |
| 343 void NV12ToI420Scaler::NV12ToI420Scale( | 401 void NV12ToI420Scaler::NV12ToI420Scale( |
| 344 const uint8_t* src_y, int src_stride_y, | 402 const uint8_t* src_y, int src_stride_y, |
| 345 const uint8_t* src_uv, int src_stride_uv, | 403 const uint8_t* src_uv, int src_stride_uv, |
| 346 int src_width, int src_height, | 404 int src_width, int src_height, |
| 347 uint8_t* dst_y, int dst_stride_y, | 405 uint8_t* dst_y, int dst_stride_y, |
| 348 uint8_t* dst_u, int dst_stride_u, | 406 uint8_t* dst_u, int dst_stride_u, |
| 349 uint8_t* dst_v, int dst_stride_v, | 407 uint8_t* dst_v, int dst_stride_v, |
| 350 int dst_width, int dst_height) { | 408 int dst_width, int dst_height) { |
| 351 if (src_width == dst_width && src_height == dst_height) { | 409 if (src_width == dst_width && src_height == dst_height) { |
| 352 // No scaling. | 410 // No scaling. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 383 src_v, src_uv_width, | 441 src_v, src_uv_width, |
| 384 src_width, src_height, | 442 src_width, src_height, |
| 385 dst_y, dst_stride_y, | 443 dst_y, dst_stride_y, |
| 386 dst_u, dst_stride_u, | 444 dst_u, dst_stride_u, |
| 387 dst_v, dst_stride_v, | 445 dst_v, dst_stride_v, |
| 388 dst_width, dst_height, | 446 dst_width, dst_height, |
| 389 libyuv::kFilterBox); | 447 libyuv::kFilterBox); |
| 390 } | 448 } |
| 391 | 449 |
| 392 } // namespace webrtc | 450 } // namespace webrtc |
| OLD | NEW |