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

Side by Side Diff: source/libvpx/vpx_dsp/psnrhvs.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/prob.h ('k') | source/libvpx/vpx_dsp/quantize.h » ('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: Gregory Maxwell, at the Daala 10 * This code was originally written by: Gregory Maxwell, at the Daala
11 * project. 11 * project.
12 */ 12 */
13 #include <stdio.h> 13 #include <stdio.h>
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <math.h> 15 #include <math.h>
16 16
17 #include "./vpx_config.h" 17 #include "./vpx_config.h"
18 #include "./vp9_rtcd.h"
19 #include "./vpx_dsp_rtcd.h" 18 #include "./vpx_dsp_rtcd.h"
20 #include "vp9/encoder/vp9_ssim.h" 19 #include "vpx_dsp/ssim.h"
20 #include "vpx_ports/system_state.h"
21 21
22 #if !defined(M_PI) 22 #if !defined(M_PI)
23 # define M_PI (3.141592653589793238462643) 23 # define M_PI (3.141592653589793238462643)
24 #endif 24 #endif
25 #include <string.h> 25 #include <string.h>
26 26
27 void od_bin_fdct8x8(tran_low_t *y, int ystride, const int16_t *x, int xstride) { 27 static void od_bin_fdct8x8(tran_low_t *y, int ystride, const int16_t *x,
28 int xstride) {
28 (void) xstride; 29 (void) xstride;
29 vpx_fdct8x8(x, y, ystride); 30 vpx_fdct8x8(x, y, ystride);
30 } 31 }
31 32
32 /* Normalized inverse quantization matrix for 8x8 DCT at the point of 33 /* Normalized inverse quantization matrix for 8x8 DCT at the point of
33 * transparency. This is not the JPEG based matrix from the paper, 34 * transparency. This is not the JPEG based matrix from the paper,
34 this one gives a slightly higher MOS agreement.*/ 35 this one gives a slightly higher MOS agreement.*/
35 float csf_y[8][8] = {{1.6193873005, 2.2901594831, 2.08509755623, 1.48366094411, 36 static const float csf_y[8][8] = {
36 1.00227514334, 0.678296995242, 0.466224900598, 0.3265091542}, {2.2901594831, 37 {1.6193873005, 2.2901594831, 2.08509755623, 1.48366094411, 1.00227514334,
37 1.94321815382, 2.04793073064, 1.68731108984, 1.2305666963, 0.868920337363, 38 0.678296995242, 0.466224900598, 0.3265091542},
38 0.61280991668, 0.436405793551}, {2.08509755623, 2.04793073064, 39 {2.2901594831, 1.94321815382, 2.04793073064, 1.68731108984, 1.2305666963,
39 1.34329019223, 1.09205635862, 0.875748795257, 0.670882927016, 40 0.868920337363, 0.61280991668, 0.436405793551},
40 0.501731932449, 0.372504254596}, {1.48366094411, 1.68731108984, 41 {2.08509755623, 2.04793073064, 1.34329019223, 1.09205635862, 0.875748795257,
41 1.09205635862, 0.772819797575, 0.605636379554, 0.48309405692, 42 0.670882927016, 0.501731932449, 0.372504254596},
42 0.380429446972, 0.295774038565}, {1.00227514334, 1.2305666963, 43 {1.48366094411, 1.68731108984, 1.09205635862, 0.772819797575,
43 0.875748795257, 0.605636379554, 0.448996256676, 0.352889268808, 44 0.605636379554, 0.48309405692, 0.380429446972, 0.295774038565},
44 0.283006984131, 0.226951348204}, {0.678296995242, 0.868920337363, 45 {1.00227514334, 1.2305666963, 0.875748795257, 0.605636379554,
45 0.670882927016, 0.48309405692, 0.352889268808, 0.27032073436, 46 0.448996256676, 0.352889268808, 0.283006984131, 0.226951348204},
46 0.215017739696, 0.17408067321}, {0.466224900598, 0.61280991668, 47 {0.678296995242, 0.868920337363, 0.670882927016, 0.48309405692,
47 0.501731932449, 0.380429446972, 0.283006984131, 0.215017739696, 48 0.352889268808, 0.27032073436, 0.215017739696, 0.17408067321},
48 0.168869545842, 0.136153931001}, {0.3265091542, 0.436405793551, 49 {0.466224900598, 0.61280991668, 0.501731932449, 0.380429446972,
49 0.372504254596, 0.295774038565, 0.226951348204, 0.17408067321, 50 0.283006984131, 0.215017739696, 0.168869545842, 0.136153931001},
50 0.136153931001, 0.109083846276}}; 51 {0.3265091542, 0.436405793551, 0.372504254596, 0.295774038565,
51 float csf_cb420[8][8] = { 52 0.226951348204, 0.17408067321, 0.136153931001, 0.109083846276}};
53 static const float csf_cb420[8][8] = {
52 {1.91113096927, 2.46074210438, 1.18284184739, 1.14982565193, 1.05017074788, 54 {1.91113096927, 2.46074210438, 1.18284184739, 1.14982565193, 1.05017074788,
53 0.898018824055, 0.74725392039, 0.615105596242}, {2.46074210438, 55 0.898018824055, 0.74725392039, 0.615105596242},
54 1.58529308355, 1.21363250036, 1.38190029285, 1.33100189972, 56 {2.46074210438, 1.58529308355, 1.21363250036, 1.38190029285, 1.33100189972,
55 1.17428548929, 0.996404342439, 0.830890433625}, {1.18284184739, 57 1.17428548929, 0.996404342439, 0.830890433625},
56 1.21363250036, 0.978712413627, 1.02624506078, 1.03145147362, 58 {1.18284184739, 1.21363250036, 0.978712413627, 1.02624506078, 1.03145147362,
57 0.960060382087, 0.849823426169, 0.731221236837}, {1.14982565193, 59 0.960060382087, 0.849823426169, 0.731221236837},
58 1.38190029285, 1.02624506078, 0.861317501629, 0.801821139099, 60 {1.14982565193, 1.38190029285, 1.02624506078, 0.861317501629,
59 0.751437590932, 0.685398513368, 0.608694761374}, {1.05017074788, 61 0.801821139099, 0.751437590932, 0.685398513368, 0.608694761374},
60 1.33100189972, 1.03145147362, 0.801821139099, 0.676555426187, 62 {1.05017074788, 1.33100189972, 1.03145147362, 0.801821139099,
61 0.605503172737, 0.55002013668, 0.495804539034}, {0.898018824055, 63 0.676555426187, 0.605503172737, 0.55002013668, 0.495804539034},
62 1.17428548929, 0.960060382087, 0.751437590932, 0.605503172737, 64 {0.898018824055, 1.17428548929, 0.960060382087, 0.751437590932,
63 0.514674450957, 0.454353482512, 0.407050308965}, {0.74725392039, 65 0.605503172737, 0.514674450957, 0.454353482512, 0.407050308965},
64 0.996404342439, 0.849823426169, 0.685398513368, 0.55002013668, 66 {0.74725392039, 0.996404342439, 0.849823426169, 0.685398513368,
65 0.454353482512, 0.389234902883, 0.342353999733}, {0.615105596242, 67 0.55002013668, 0.454353482512, 0.389234902883, 0.342353999733},
66 0.830890433625, 0.731221236837, 0.608694761374, 0.495804539034, 68 {0.615105596242, 0.830890433625, 0.731221236837, 0.608694761374,
67 0.407050308965, 0.342353999733, 0.295530605237}}; 69 0.495804539034, 0.407050308965, 0.342353999733, 0.295530605237}};
68 float csf_cr420[8][8] = { 70 static const float csf_cr420[8][8] = {
69 {2.03871978502, 2.62502345193, 1.26180942886, 1.11019789803, 1.01397751469, 71 {2.03871978502, 2.62502345193, 1.26180942886, 1.11019789803, 1.01397751469,
70 0.867069376285, 0.721500455585, 0.593906509971}, {2.62502345193, 72 0.867069376285, 0.721500455585, 0.593906509971},
71 1.69112867013, 1.17180569821, 1.3342742857, 1.28513006198, 73 {2.62502345193, 1.69112867013, 1.17180569821, 1.3342742857, 1.28513006198,
72 1.13381474809, 0.962064122248, 0.802254508198}, {1.26180942886, 74 1.13381474809, 0.962064122248, 0.802254508198},
73 1.17180569821, 0.944981930573, 0.990876405848, 0.995903384143, 75 {1.26180942886, 1.17180569821, 0.944981930573, 0.990876405848,
74 0.926972725286, 0.820534991409, 0.706020324706}, {1.11019789803, 76 0.995903384143, 0.926972725286, 0.820534991409, 0.706020324706},
75 1.3342742857, 0.990876405848, 0.831632933426, 0.77418706195, 77 {1.11019789803, 1.3342742857, 0.990876405848, 0.831632933426, 0.77418706195,
76 0.725539939514, 0.661776842059, 0.587716619023}, {1.01397751469, 78 0.725539939514, 0.661776842059, 0.587716619023},
77 1.28513006198, 0.995903384143, 0.77418706195, 0.653238524286, 79 {1.01397751469, 1.28513006198, 0.995903384143, 0.77418706195,
78 0.584635025748, 0.531064164893, 0.478717061273}, {0.867069376285, 80 0.653238524286, 0.584635025748, 0.531064164893, 0.478717061273},
79 1.13381474809, 0.926972725286, 0.725539939514, 0.584635025748, 81 {0.867069376285, 1.13381474809, 0.926972725286, 0.725539939514,
80 0.496936637883, 0.438694579826, 0.393021669543}, {0.721500455585, 82 0.584635025748, 0.496936637883, 0.438694579826, 0.393021669543},
81 0.962064122248, 0.820534991409, 0.661776842059, 0.531064164893, 83 {0.721500455585, 0.962064122248, 0.820534991409, 0.661776842059,
82 0.438694579826, 0.375820256136, 0.330555063063}, {0.593906509971, 84 0.531064164893, 0.438694579826, 0.375820256136, 0.330555063063},
83 0.802254508198, 0.706020324706, 0.587716619023, 0.478717061273, 85 {0.593906509971, 0.802254508198, 0.706020324706, 0.587716619023,
84 0.393021669543, 0.330555063063, 0.285345396658}}; 86 0.478717061273, 0.393021669543, 0.330555063063, 0.285345396658}};
85 87
86 static double convert_score_db(double _score, double _weight) { 88 static double convert_score_db(double _score, double _weight) {
87 return 10 * (log10(255 * 255) - log10(_weight * _score)); 89 return 10 * (log10(255 * 255) - log10(_weight * _score));
88 } 90 }
89 91
90 static double calc_psnrhvs(const unsigned char *_src, int _systride, 92 static double calc_psnrhvs(const unsigned char *_src, int _systride,
91 const unsigned char *_dst, int _dystride, 93 const unsigned char *_dst, int _dystride,
92 double _par, int _w, int _h, int _step, 94 double _par, int _w, int _h, int _step,
93 float _csf[8][8]) { 95 const float _csf[8][8]) {
94 float ret; 96 float ret;
95 int16_t dct_s[8 * 8], dct_d[8 * 8]; 97 int16_t dct_s[8 * 8], dct_d[8 * 8];
96 tran_low_t dct_s_coef[8 * 8], dct_d_coef[8 * 8]; 98 tran_low_t dct_s_coef[8 * 8], dct_d_coef[8 * 8];
97 float mask[8][8]; 99 float mask[8][8];
98 int pixels; 100 int pixels;
99 int x; 101 int x;
100 int y; 102 int y;
101 (void) _par; 103 (void) _par;
102 ret = pixels = 0; 104 ret = pixels = 0;
103 /*In the PSNR-HVS-M paper[1] the authors describe the construction of 105 /*In the PSNR-HVS-M paper[1] the authors describe the construction of
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 err = err < s_mask / mask[i][j] ? 0 : err - s_mask / mask[i][j]; 196 err = err < s_mask / mask[i][j] ? 0 : err - s_mask / mask[i][j];
195 ret += (err * _csf[i][j]) * (err * _csf[i][j]); 197 ret += (err * _csf[i][j]) * (err * _csf[i][j]);
196 pixels++; 198 pixels++;
197 } 199 }
198 } 200 }
199 } 201 }
200 } 202 }
201 ret /= pixels; 203 ret /= pixels;
202 return ret; 204 return ret;
203 } 205 }
204 double vp9_psnrhvs(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, 206 double vpx_psnrhvs(const YV12_BUFFER_CONFIG *source,
205 double *y_psnrhvs, double *u_psnrhvs, double *v_psnrhvs) { 207 const YV12_BUFFER_CONFIG *dest, double *y_psnrhvs,
208 double *u_psnrhvs, double *v_psnrhvs) {
206 double psnrhvs; 209 double psnrhvs;
207 double par = 1.0; 210 const double par = 1.0;
208 int step = 7; 211 const int step = 7;
209 vp9_clear_system_state(); 212 vpx_clear_system_state();
210 *y_psnrhvs = calc_psnrhvs(source->y_buffer, source->y_stride, dest->y_buffer, 213 *y_psnrhvs = calc_psnrhvs(source->y_buffer, source->y_stride, dest->y_buffer,
211 dest->y_stride, par, source->y_crop_width, 214 dest->y_stride, par, source->y_crop_width,
212 source->y_crop_height, step, csf_y); 215 source->y_crop_height, step, csf_y);
213 216
214 *u_psnrhvs = calc_psnrhvs(source->u_buffer, source->uv_stride, dest->u_buffer, 217 *u_psnrhvs = calc_psnrhvs(source->u_buffer, source->uv_stride, dest->u_buffer,
215 dest->uv_stride, par, source->uv_crop_width, 218 dest->uv_stride, par, source->uv_crop_width,
216 source->uv_crop_height, step, csf_cb420); 219 source->uv_crop_height, step, csf_cb420);
217 220
218 *v_psnrhvs = calc_psnrhvs(source->v_buffer, source->uv_stride, dest->v_buffer, 221 *v_psnrhvs = calc_psnrhvs(source->v_buffer, source->uv_stride, dest->v_buffer,
219 dest->uv_stride, par, source->uv_crop_width, 222 dest->uv_stride, par, source->uv_crop_width,
220 source->uv_crop_height, step, csf_cr420); 223 source->uv_crop_height, step, csf_cr420);
221 psnrhvs = (*y_psnrhvs) * .8 + .1 * ((*u_psnrhvs) + (*v_psnrhvs)); 224 psnrhvs = (*y_psnrhvs) * .8 + .1 * ((*u_psnrhvs) + (*v_psnrhvs));
222 225
223 return convert_score_db(psnrhvs, 1.0); 226 return convert_score_db(psnrhvs, 1.0);
224 } 227 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_dsp/prob.h ('k') | source/libvpx/vpx_dsp/quantize.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698