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

Side by Side Diff: source/libvpx/vpx_dsp/fastssim.c

Issue 1302353004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 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 | « source/libvpx/vpx_dsp/bitreader.c ('k') | source/libvpx/vpx_dsp/fwd_txfm.c » ('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) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM 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 * This code was originally written by: Nathan E. Egge, at the Daala 10 * This code was originally written by: Nathan E. Egge, at the Daala
11 * project. 11 * project.
12 */ 12 */
13 #include <math.h> 13 #include <math.h>
14 #include <stdlib.h>
14 #include <string.h> 15 #include <string.h>
15 #include "./vpx_config.h" 16 #include "./vpx_config.h"
16 #include "./vp9_rtcd.h" 17 #include "./vpx_dsp_rtcd.h"
17 #include "vp9/encoder/vp9_ssim.h" 18 #include "vpx_dsp/ssim.h"
19 #include "vpx_ports/system_state.h"
18 /* TODO(jbb): High bit depth version of this code needed */ 20 /* TODO(jbb): High bit depth version of this code needed */
19 typedef struct fs_level fs_level; 21 typedef struct fs_level fs_level;
20 typedef struct fs_ctx fs_ctx; 22 typedef struct fs_ctx fs_ctx;
21 23
22 #define SSIM_C1 (255 * 255 * 0.01 * 0.01) 24 #define SSIM_C1 (255 * 255 * 0.01 * 0.01)
23 #define SSIM_C2 (255 * 255 * 0.03 * 0.03) 25 #define SSIM_C2 (255 * 255 * 0.03 * 0.03)
24 26
25 #define FS_MINI(_a, _b) ((_a) < (_b) ? (_a) : (_b)) 27 #define FS_MINI(_a, _b) ((_a) < (_b) ? (_a) : (_b))
26 #define FS_MAXI(_a, _b) ((_a) > (_b) ? (_a) : (_b)) 28 #define FS_MAXI(_a, _b) ((_a) > (_b) ? (_a) : (_b))
27 29
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 fs_apply_luminance(&ctx, l); 438 fs_apply_luminance(&ctx, l);
437 ret *= fs_average(&ctx, l); 439 ret *= fs_average(&ctx, l);
438 fs_ctx_clear(&ctx); 440 fs_ctx_clear(&ctx);
439 return ret; 441 return ret;
440 } 442 }
441 443
442 static double convert_ssim_db(double _ssim, double _weight) { 444 static double convert_ssim_db(double _ssim, double _weight) {
443 return 10 * (log10(_weight) - log10(_weight - _ssim)); 445 return 10 * (log10(_weight) - log10(_weight - _ssim));
444 } 446 }
445 447
446 double vp9_calc_fastssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, 448 double vpx_calc_fastssim(const YV12_BUFFER_CONFIG *source,
449 const YV12_BUFFER_CONFIG *dest,
447 double *ssim_y, double *ssim_u, double *ssim_v) { 450 double *ssim_y, double *ssim_u, double *ssim_v) {
448 double ssimv; 451 double ssimv;
449 vp9_clear_system_state(); 452 vpx_clear_system_state();
450 453
451 *ssim_y = calc_ssim(source->y_buffer, source->y_stride, dest->y_buffer, 454 *ssim_y = calc_ssim(source->y_buffer, source->y_stride, dest->y_buffer,
452 dest->y_stride, source->y_crop_width, 455 dest->y_stride, source->y_crop_width,
453 source->y_crop_height); 456 source->y_crop_height);
454 457
455 *ssim_u = calc_ssim(source->u_buffer, source->uv_stride, dest->u_buffer, 458 *ssim_u = calc_ssim(source->u_buffer, source->uv_stride, dest->u_buffer,
456 dest->uv_stride, source->uv_crop_width, 459 dest->uv_stride, source->uv_crop_width,
457 source->uv_crop_height); 460 source->uv_crop_height);
458 461
459 *ssim_v = calc_ssim(source->v_buffer, source->uv_stride, dest->v_buffer, 462 *ssim_v = calc_ssim(source->v_buffer, source->uv_stride, dest->v_buffer,
460 dest->uv_stride, source->uv_crop_width, 463 dest->uv_stride, source->uv_crop_width,
461 source->uv_crop_height); 464 source->uv_crop_height);
462 ssimv = (*ssim_y) * .8 + .1 * ((*ssim_u) + (*ssim_v)); 465 ssimv = (*ssim_y) * .8 + .1 * ((*ssim_u) + (*ssim_v));
463 466
464 return convert_ssim_db(ssimv, 1.0); 467 return convert_ssim_db(ssimv, 1.0);
465 } 468 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_dsp/bitreader.c ('k') | source/libvpx/vpx_dsp/fwd_txfm.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698