| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 src_frame.video_frame_buffer()->DataU(), | 283 src_frame.video_frame_buffer()->DataU(), |
| 284 src_frame.video_frame_buffer()->StrideU(), | 284 src_frame.video_frame_buffer()->StrideU(), |
| 285 src_frame.video_frame_buffer()->DataV(), | 285 src_frame.video_frame_buffer()->DataV(), |
| 286 src_frame.video_frame_buffer()->StrideV(), | 286 src_frame.video_frame_buffer()->StrideV(), |
| 287 dst_frame, dst_sample_size, | 287 dst_frame, dst_sample_size, |
| 288 src_frame.width(), src_frame.height(), | 288 src_frame.width(), src_frame.height(), |
| 289 ConvertVideoType(dst_video_type)); | 289 ConvertVideoType(dst_video_type)); |
| 290 } | 290 } |
| 291 | 291 |
| 292 // Compute PSNR for an I420 frame (all planes) | 292 // Compute PSNR for an I420 frame (all planes) |
| 293 double I420PSNR(const VideoFrameBuffer& ref_buffer, |
| 294 const VideoFrameBuffer& test_buffer) { |
| 295 if ((ref_buffer.width() != test_buffer.width()) || |
| 296 (ref_buffer.height() != test_buffer.height())) |
| 297 return -1; |
| 298 else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) |
| 299 return -1; |
| 300 |
| 301 double psnr = libyuv::I420Psnr(ref_buffer.DataY(), ref_buffer.StrideY(), |
| 302 ref_buffer.DataU(), ref_buffer.StrideU(), |
| 303 ref_buffer.DataV(), ref_buffer.StrideV(), |
| 304 test_buffer.DataY(), test_buffer.StrideY(), |
| 305 test_buffer.DataU(), test_buffer.StrideU(), |
| 306 test_buffer.DataV(), test_buffer.StrideV(), |
| 307 test_buffer.width(), test_buffer.height()); |
| 308 // LibYuv sets the max psnr value to 128, we restrict it here. |
| 309 // In case of 0 mse in one frame, 128 can skew the results significantly. |
| 310 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr; |
| 311 } |
| 312 |
| 313 // Compute PSNR for an I420 frame (all planes) |
| 293 double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) { | 314 double I420PSNR(const VideoFrame* ref_frame, const VideoFrame* test_frame) { |
| 294 if (!ref_frame || !test_frame) | 315 if (!ref_frame || !test_frame) |
| 295 return -1; | 316 return -1; |
| 296 else if ((ref_frame->width() != test_frame->width()) || | 317 return I420PSNR(*ref_frame->video_frame_buffer(), |
| 297 (ref_frame->height() != test_frame->height())) | 318 *test_frame->video_frame_buffer()); |
| 298 return -1; | |
| 299 else if (ref_frame->width() < 0 || ref_frame->height() < 0) | |
| 300 return -1; | |
| 301 | |
| 302 double psnr = libyuv::I420Psnr(ref_frame->video_frame_buffer()->DataY(), | |
| 303 ref_frame->video_frame_buffer()->StrideY(), | |
| 304 ref_frame->video_frame_buffer()->DataU(), | |
| 305 ref_frame->video_frame_buffer()->StrideU(), | |
| 306 ref_frame->video_frame_buffer()->DataV(), | |
| 307 ref_frame->video_frame_buffer()->StrideV(), | |
| 308 test_frame->video_frame_buffer()->DataY(), | |
| 309 test_frame->video_frame_buffer()->StrideY(), | |
| 310 test_frame->video_frame_buffer()->DataU(), | |
| 311 test_frame->video_frame_buffer()->StrideU(), | |
| 312 test_frame->video_frame_buffer()->DataV(), | |
| 313 test_frame->video_frame_buffer()->StrideV(), | |
| 314 test_frame->width(), test_frame->height()); | |
| 315 // LibYuv sets the max psnr value to 128, we restrict it here. | |
| 316 // In case of 0 mse in one frame, 128 can skew the results significantly. | |
| 317 return (psnr > kPerfectPSNR) ? kPerfectPSNR : psnr; | |
| 318 } | 319 } |
| 319 | 320 |
| 320 // Compute SSIM for an I420 frame (all planes) | 321 // Compute SSIM for an I420 frame (all planes) |
| 322 double I420SSIM(const VideoFrameBuffer& ref_buffer, |
| 323 const VideoFrameBuffer& test_buffer) { |
| 324 if ((ref_buffer.width() != test_buffer.width()) || |
| 325 (ref_buffer.height() != test_buffer.height())) |
| 326 return -1; |
| 327 else if (ref_buffer.width() < 0 || ref_buffer.height() < 0) |
| 328 return -1; |
| 329 |
| 330 return libyuv::I420Ssim(ref_buffer.DataY(), ref_buffer.StrideY(), |
| 331 ref_buffer.DataU(), ref_buffer.StrideU(), |
| 332 ref_buffer.DataV(), ref_buffer.StrideV(), |
| 333 test_buffer.DataY(), test_buffer.StrideY(), |
| 334 test_buffer.DataU(), test_buffer.StrideU(), |
| 335 test_buffer.DataV(), test_buffer.StrideV(), |
| 336 test_buffer.width(), test_buffer.height()); |
| 337 } |
| 321 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { | 338 double I420SSIM(const VideoFrame* ref_frame, const VideoFrame* test_frame) { |
| 322 if (!ref_frame || !test_frame) | 339 if (!ref_frame || !test_frame) |
| 323 return -1; | 340 return -1; |
| 324 else if ((ref_frame->width() != test_frame->width()) || | 341 return I420SSIM(*ref_frame->video_frame_buffer(), |
| 325 (ref_frame->height() != test_frame->height())) | 342 *test_frame->video_frame_buffer()); |
| 326 return -1; | |
| 327 else if (ref_frame->width() < 0 || ref_frame->height() < 0) | |
| 328 return -1; | |
| 329 | |
| 330 return libyuv::I420Ssim(ref_frame->video_frame_buffer()->DataY(), | |
| 331 ref_frame->video_frame_buffer()->StrideY(), | |
| 332 ref_frame->video_frame_buffer()->DataU(), | |
| 333 ref_frame->video_frame_buffer()->StrideU(), | |
| 334 ref_frame->video_frame_buffer()->DataV(), | |
| 335 ref_frame->video_frame_buffer()->StrideV(), | |
| 336 test_frame->video_frame_buffer()->DataY(), | |
| 337 test_frame->video_frame_buffer()->StrideY(), | |
| 338 test_frame->video_frame_buffer()->DataU(), | |
| 339 test_frame->video_frame_buffer()->StrideU(), | |
| 340 test_frame->video_frame_buffer()->DataV(), | |
| 341 test_frame->video_frame_buffer()->StrideV(), | |
| 342 test_frame->width(), test_frame->height()); | |
| 343 } | 343 } |
| 344 } // namespace webrtc | 344 } // namespace webrtc |
| OLD | NEW |