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

Side by Side Diff: third_party/libwebp/enc/picture_psnr.c

Issue 2149863002: libwebp: update to v0.5.1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « third_party/libwebp/enc/picture_csp.c ('k') | third_party/libwebp/enc/quant.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 // Copyright 2014 Google Inc. All Rights Reserved. 1 // Copyright 2014 Google Inc. All Rights Reserved.
2 // 2 //
3 // Use of this source code is governed by a BSD-style license 3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the COPYING file in the root of the source 4 // that can be found in the COPYING file in the root of the source
5 // tree. An additional intellectual property rights grant can be found 5 // tree. An additional intellectual property rights grant can be found
6 // in the file PATENTS. All contributing project authors may 6 // in the file PATENTS. All contributing project authors may
7 // be found in the AUTHORS file in the root of the source tree. 7 // be found in the AUTHORS file in the root of the source tree.
8 // ----------------------------------------------------------------------------- 8 // -----------------------------------------------------------------------------
9 // 9 //
10 // WebPPicture tools for measuring distortion 10 // WebPPicture tools for measuring distortion
11 // 11 //
12 // Author: Skal (pascal.massimino@gmail.com) 12 // Author: Skal (pascal.massimino@gmail.com)
13 13
14 #include <math.h> 14 #include <math.h>
15 #include <stdlib.h> 15 #include <stdlib.h>
16 16
17 #include "./vp8enci.h" 17 #include "./vp8enci.h"
18 #include "../utils/utils.h" 18 #include "../utils/utils.h"
19 19
20 //------------------------------------------------------------------------------ 20 //------------------------------------------------------------------------------
21 // local-min distortion 21 // local-min distortion
22 // 22 //
23 // For every pixel in the *reference* picture, we search for the local best 23 // For every pixel in the *reference* picture, we search for the local best
24 // match in the compressed image. This is not a symmetrical measure. 24 // match in the compressed image. This is not a symmetrical measure.
25 25
26 #define RADIUS 2 // search radius. Shouldn't be too large. 26 #define RADIUS 2 // search radius. Shouldn't be too large.
27 27
28 static void AccumulateLSIM(const uint8_t* src, int src_stride, 28 static void AccumulateLSIM(const uint8_t* src, int src_stride,
29 const uint8_t* ref, int ref_stride, 29 const uint8_t* ref, int ref_stride,
30 int w, int h, DistoStats* stats) { 30 int w, int h, VP8DistoStats* stats) {
31 int x, y; 31 int x, y;
32 double total_sse = 0.; 32 double total_sse = 0.;
33 for (y = 0; y < h; ++y) { 33 for (y = 0; y < h; ++y) {
34 const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS; 34 const int y_0 = (y - RADIUS < 0) ? 0 : y - RADIUS;
35 const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1; 35 const int y_1 = (y + RADIUS + 1 >= h) ? h : y + RADIUS + 1;
36 for (x = 0; x < w; ++x) { 36 for (x = 0; x < w; ++x) {
37 const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS; 37 const int x_0 = (x - RADIUS < 0) ? 0 : x - RADIUS;
38 const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1; 38 const int x_1 = (x + RADIUS + 1 >= w) ? w : x + RADIUS + 1;
39 double best_sse = 255. * 255.; 39 double best_sse = 255. * 255.;
40 const double value = (double)ref[y * ref_stride + x]; 40 const double value = (double)ref[y * ref_stride + x];
(...skipping 23 matching lines...) Expand all
64 64
65 // Max value returned in case of exact similarity. 65 // Max value returned in case of exact similarity.
66 static const double kMinDistortion_dB = 99.; 66 static const double kMinDistortion_dB = 99.;
67 static float GetPSNR(const double v) { 67 static float GetPSNR(const double v) {
68 return (float)((v > 0.) ? -4.3429448 * log(v / (255 * 255.)) 68 return (float)((v > 0.) ? -4.3429448 * log(v / (255 * 255.))
69 : kMinDistortion_dB); 69 : kMinDistortion_dB);
70 } 70 }
71 71
72 int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref, 72 int WebPPictureDistortion(const WebPPicture* src, const WebPPicture* ref,
73 int type, float result[5]) { 73 int type, float result[5]) {
74 DistoStats stats[5]; 74 VP8DistoStats stats[5];
75 int w, h; 75 int w, h;
76 76
77 memset(stats, 0, sizeof(stats)); 77 memset(stats, 0, sizeof(stats));
78 78
79 VP8SSIMDspInit();
80
79 if (src == NULL || ref == NULL || 81 if (src == NULL || ref == NULL ||
80 src->width != ref->width || src->height != ref->height || 82 src->width != ref->width || src->height != ref->height ||
81 src->use_argb != ref->use_argb || result == NULL) { 83 src->use_argb != ref->use_argb || result == NULL) {
82 return 0; 84 return 0;
83 } 85 }
84 w = src->width; 86 w = src->width;
85 h = src->height; 87 h = src->height;
86 88
87 if (src->use_argb == 1) { 89 if (src->use_argb == 1) {
88 if (src->argb == NULL || ref->argb == NULL) { 90 if (src->argb == NULL || ref->argb == NULL) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 result[c] = GetPSNR(v); 168 result[c] = GetPSNR(v);
167 } 169 }
168 // Accumulate forward 170 // Accumulate forward
169 if (c < 4) VP8SSIMAddStats(&stats[c], &stats[4]); 171 if (c < 4) VP8SSIMAddStats(&stats[c], &stats[4]);
170 } 172 }
171 } 173 }
172 return 1; 174 return 1;
173 } 175 }
174 176
175 //------------------------------------------------------------------------------ 177 //------------------------------------------------------------------------------
OLDNEW
« no previous file with comments | « third_party/libwebp/enc/picture_csp.c ('k') | third_party/libwebp/enc/quant.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698