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

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

Issue 2681683003: Added Vp9 simulcast tests. (Closed)
Patch Set: rebase Created 3 years, 10 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 | « no previous file | webrtc/modules/video_coding/codecs/vp9/vp9_impl.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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 src_frame.video_frame_buffer()->StrideY(), 281 src_frame.video_frame_buffer()->StrideY(),
282 src_frame.video_frame_buffer()->DataU(), 282 src_frame.video_frame_buffer()->DataU(),
283 src_frame.video_frame_buffer()->StrideU(), 283 src_frame.video_frame_buffer()->StrideU(),
284 src_frame.video_frame_buffer()->DataV(), 284 src_frame.video_frame_buffer()->DataV(),
285 src_frame.video_frame_buffer()->StrideV(), 285 src_frame.video_frame_buffer()->StrideV(),
286 dst_frame, dst_sample_size, 286 dst_frame, dst_sample_size,
287 src_frame.width(), src_frame.height(), 287 src_frame.width(), src_frame.height(),
288 ConvertVideoType(dst_video_type)); 288 ConvertVideoType(dst_video_type));
289 } 289 }
290 290
291 // Compute PSNR for an I420 frame (all planes) 291 // Compute PSNR for an I420 frame (all planes). Can upscale test frame.
292 double I420PSNR(const VideoFrameBuffer& ref_buffer, 292 double I420PSNR(const VideoFrameBuffer& ref_buffer,
293 const VideoFrameBuffer& test_buffer) { 293 const VideoFrameBuffer& test_buffer) {
294 if ((ref_buffer.width() != test_buffer.width()) || 294 rtc::scoped_refptr<const VideoFrameBuffer> temp_buffer(&test_buffer);
295 (ref_buffer.height() != test_buffer.height())) 295 if ((ref_buffer.width() < test_buffer.width()) ||
magjed_webrtc 2017/02/13 15:35:11 I don't think we need these checks. Can we simply
ilnik 2017/02/13 16:54:25 Scaling down is not an intended behavior here, so
magjed_webrtc 2017/02/14 12:47:49 I don't see the problem of making the code more ge
296 (ref_buffer.height() < test_buffer.height())) {
296 return -1; 297 return -1;
297 else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) 298 } else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) {
298 return -1; 299 return -1;
299 300 } else if ((ref_buffer.width() > test_buffer.width()) ||
300 double psnr = libyuv::I420Psnr(ref_buffer.DataY(), ref_buffer.StrideY(), 301 (ref_buffer.height() > test_buffer.height())) {
301 ref_buffer.DataU(), ref_buffer.StrideU(), 302 rtc::scoped_refptr<I420Buffer> scaled_buffer =
302 ref_buffer.DataV(), ref_buffer.StrideV(), 303 I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
303 test_buffer.DataY(), test_buffer.StrideY(), 304 if (libyuv::I420Scale(
magjed_webrtc 2017/02/13 15:35:11 Can you use 'scaled_buffer.ScaleFrom(test_buffer)'
ilnik 2017/02/13 16:54:25 Yes, it turns out, it will be equivalent. Will cha
304 test_buffer.DataU(), test_buffer.StrideU(), 305 test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
305 test_buffer.DataV(), test_buffer.StrideV(), 306 test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
306 test_buffer.width(), test_buffer.height()); 307 test_buffer.width(), test_buffer.height(),
308 scaled_buffer->MutableDataY(), scaled_buffer->StrideY(),
309 scaled_buffer->MutableDataU(), scaled_buffer->StrideU(),
310 scaled_buffer->MutableDataV(), scaled_buffer->StrideV(),
311 scaled_buffer->width(), scaled_buffer->height(),
312 libyuv::kFilterBilinear) != 0)
313 return -1;
314 temp_buffer = static_cast<VideoFrameBuffer*>(scaled_buffer.release());
315 }
316 double psnr = libyuv::I420Psnr(
317 ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
318 ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
319 temp_buffer->DataY(), temp_buffer->StrideY(), temp_buffer->DataU(),
320 temp_buffer->StrideU(), temp_buffer->DataV(), temp_buffer->StrideV(),
321 temp_buffer->width(), temp_buffer->height());
307 // LibYuv sets the max psnr value to 128, we restrict it here. 322 // LibYuv sets the max psnr value to 128, we restrict it here.
308 // In case of 0 mse in one frame, 128 can skew the results significantly. 323 // In case of 0 mse in one frame, 128 can skew the results significantly.
309 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr; 324 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr;
310 } 325 }
311 326
312 // Compute PSNR for an I420 frame (all planes) 327 // Compute PSNR for an I420 frame (all planes)
313 double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) { 328 double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
314 if (!ref_frame || !test_frame) 329 if (!ref_frame || !test_frame)
315 return -1; 330 return -1;
316 return I420PSNR(*ref_frame->video_frame_buffer(), 331 return I420PSNR(*ref_frame->video_frame_buffer(),
317 *test_frame->video_frame_buffer()); 332 *test_frame->video_frame_buffer());
318 } 333 }
319 334
320 // Compute SSIM for an I420 frame (all planes) 335 // Compute SSIM for an I420 frame (all planes). Can upscale test_buffer.
321 double I420SSIM(const VideoFrameBuffer& ref_buffer, 336 double I420SSIM(const VideoFrameBuffer& ref_buffer,
322 const VideoFrameBuffer& test_buffer) { 337 const VideoFrameBuffer& test_buffer) {
323 if ((ref_buffer.width() != test_buffer.width()) || 338 rtc::scoped_refptr<const VideoFrameBuffer> temp_buffer(&test_buffer);
324 (ref_buffer.height() != test_buffer.height())) 339 if ((ref_buffer.width() < test_buffer.width()) ||
340 (ref_buffer.height() < test_buffer.height())) {
325 return -1; 341 return -1;
326 else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) 342 } else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) {
327 return -1; 343 return -1;
328 344 } else if ((ref_buffer.width() > test_buffer.width()) ||
329 return libyuv::I420Ssim(ref_buffer.DataY(), ref_buffer.StrideY(), 345 (ref_buffer.height() > test_buffer.height())) {
330 ref_buffer.DataU(), ref_buffer.StrideU(), 346 rtc::scoped_refptr<I420Buffer> scaled_buffer =
331 ref_buffer.DataV(), ref_buffer.StrideV(), 347 I420Buffer::Create(ref_buffer.width(), ref_buffer.height());
332 test_buffer.DataY(), test_buffer.StrideY(), 348 if (libyuv::I420Scale(
333 test_buffer.DataU(), test_buffer.StrideU(), 349 test_buffer.DataY(), test_buffer.StrideY(), test_buffer.DataU(),
334 test_buffer.DataV(), test_buffer.StrideV(), 350 test_buffer.StrideU(), test_buffer.DataV(), test_buffer.StrideV(),
335 test_buffer.width(), test_buffer.height()); 351 test_buffer.width(), test_buffer.height(),
352 scaled_buffer->MutableDataY(), scaled_buffer->StrideY(),
353 scaled_buffer->MutableDataU(), scaled_buffer->StrideU(),
354 scaled_buffer->MutableDataV(), scaled_buffer->StrideV(),
355 scaled_buffer->width(), scaled_buffer->height(),
356 libyuv::kFilterBilinear) != 0)
357 return -1;
358 temp_buffer = static_cast<VideoFrameBuffer*>(scaled_buffer.release());
ilnik 2017/02/13 16:54:25 Fixed potential memory corruption. If no scaling w
359 }
360 return libyuv::I420Ssim(
361 ref_buffer.DataY(), ref_buffer.StrideY(), ref_buffer.DataU(),
362 ref_buffer.StrideU(), ref_buffer.DataV(), ref_buffer.StrideV(),
363 temp_buffer->DataY(), temp_buffer->StrideY(), temp_buffer->DataU(),
364 temp_buffer->StrideU(), temp_buffer->DataV(), temp_buffer->StrideV(),
365 temp_buffer->width(), temp_buffer->height());
336 } 366 }
337 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { 367 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) {
338 if (!ref_frame || !test_frame) 368 if (!ref_frame || !test_frame)
339 return -1; 369 return -1;
340 return I420SSIM(*ref_frame->video_frame_buffer(), 370 return I420SSIM(*ref_frame->video_frame_buffer(),
341 *test_frame->video_frame_buffer()); 371 *test_frame->video_frame_buffer());
342 } 372 }
343 373
344 void NV12Scale(std::vector<uint8_t>* tmp_buffer, 374 void NV12Scale(std::vector<uint8_t>* tmp_buffer,
345 const uint8_t* src_y, int src_stride_y, 375 const uint8_t* src_y, int src_stride_y,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 src_v, src_uv_width, 472 src_v, src_uv_width,
443 src_width, src_height, 473 src_width, src_height,
444 dst_y, dst_stride_y, 474 dst_y, dst_stride_y,
445 dst_u, dst_stride_u, 475 dst_u, dst_stride_u,
446 dst_v, dst_stride_v, 476 dst_v, dst_stride_v,
447 dst_width, dst_height, 477 dst_width, dst_height,
448 libyuv::kFilterBox); 478 libyuv::kFilterBox);
449 } 479 }
450 480
451 } // namespace webrtc 481 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698