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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_aq_variance.c

Issue 668403002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dthread.c ('k') | source/libvpx/vp9/encoder/vp9_avg.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) 2013 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 10
(...skipping 16 matching lines...) Expand all
27 27
28 static double q_ratio[MAX_SEGMENTS] = { 1, 1, 1, 1, 1, 1, 1, 1 }; 28 static double q_ratio[MAX_SEGMENTS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
29 static double rdmult_ratio[MAX_SEGMENTS] = { 1, 1, 1, 1, 1, 1, 1, 1 }; 29 static double rdmult_ratio[MAX_SEGMENTS] = { 1, 1, 1, 1, 1, 1, 1, 1 };
30 static int segment_id[MAX_SEGMENTS] = { 5, 3, 1, 0, 2, 4, 6, 7 }; 30 static int segment_id[MAX_SEGMENTS] = { 5, 3, 1, 0, 2, 4, 6, 7 };
31 31
32 #define Q_RATIO(i) q_ratio[(i) - ENERGY_MIN] 32 #define Q_RATIO(i) q_ratio[(i) - ENERGY_MIN]
33 #define RDMULT_RATIO(i) rdmult_ratio[(i) - ENERGY_MIN] 33 #define RDMULT_RATIO(i) rdmult_ratio[(i) - ENERGY_MIN]
34 #define SEGMENT_ID(i) segment_id[(i) - ENERGY_MIN] 34 #define SEGMENT_ID(i) segment_id[(i) - ENERGY_MIN]
35 35
36 DECLARE_ALIGNED(16, static const uint8_t, vp9_64_zeros[64]) = {0}; 36 DECLARE_ALIGNED(16, static const uint8_t, vp9_64_zeros[64]) = {0};
37 #if CONFIG_VP9_HIGHBITDEPTH
38 DECLARE_ALIGNED(16, static const uint16_t, vp9_highbd_64_zeros[64]) = {0};
39 #endif
37 40
38 unsigned int vp9_vaq_segment_id(int energy) { 41 unsigned int vp9_vaq_segment_id(int energy) {
39 ENERGY_IN_BOUNDS(energy); 42 ENERGY_IN_BOUNDS(energy);
40 43
41 return SEGMENT_ID(energy); 44 return SEGMENT_ID(energy);
42 } 45 }
43 46
44 double vp9_vaq_rdmult_ratio(int energy) { 47 double vp9_vaq_rdmult_ratio(int energy) {
45 ENERGY_IN_BOUNDS(energy); 48 ENERGY_IN_BOUNDS(energy);
46 49
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 unsigned int var, sse; 122 unsigned int var, sse;
120 int right_overflow = (xd->mb_to_right_edge < 0) ? 123 int right_overflow = (xd->mb_to_right_edge < 0) ?
121 ((-xd->mb_to_right_edge) >> 3) : 0; 124 ((-xd->mb_to_right_edge) >> 3) : 0;
122 int bottom_overflow = (xd->mb_to_bottom_edge < 0) ? 125 int bottom_overflow = (xd->mb_to_bottom_edge < 0) ?
123 ((-xd->mb_to_bottom_edge) >> 3) : 0; 126 ((-xd->mb_to_bottom_edge) >> 3) : 0;
124 127
125 if (right_overflow || bottom_overflow) { 128 if (right_overflow || bottom_overflow) {
126 const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow; 129 const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow;
127 const int bh = 8 * num_8x8_blocks_high_lookup[bs] - bottom_overflow; 130 const int bh = 8 * num_8x8_blocks_high_lookup[bs] - bottom_overflow;
128 int avg; 131 int avg;
132 #if CONFIG_VP9_HIGHBITDEPTH
133 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
134 highbd_variance(x->plane[0].src.buf, x->plane[0].src.stride,
135 CONVERT_TO_BYTEPTR(vp9_highbd_64_zeros), 0, bw, bh,
136 &sse, &avg);
137 sse >>= 2 * (xd->bd - 8);
138 avg >>= (xd->bd - 8);
139 } else {
140 variance(x->plane[0].src.buf, x->plane[0].src.stride,
141 vp9_64_zeros, 0, bw, bh, &sse, &avg);
142 }
143 #else
129 variance(x->plane[0].src.buf, x->plane[0].src.stride, 144 variance(x->plane[0].src.buf, x->plane[0].src.stride,
130 vp9_64_zeros, 0, bw, bh, &sse, &avg); 145 vp9_64_zeros, 0, bw, bh, &sse, &avg);
146 #endif // CONFIG_VP9_HIGHBITDEPTH
131 var = sse - (((int64_t)avg * avg) / (bw * bh)); 147 var = sse - (((int64_t)avg * avg) / (bw * bh));
132 return (256 * var) / (bw * bh); 148 return (256 * var) / (bw * bh);
133 } else { 149 } else {
150 #if CONFIG_VP9_HIGHBITDEPTH
151 if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
152 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
153 x->plane[0].src.stride,
154 CONVERT_TO_BYTEPTR(vp9_highbd_64_zeros),
155 0, &sse);
156 } else {
157 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
158 x->plane[0].src.stride,
159 vp9_64_zeros, 0, &sse);
160 }
161 #else
134 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, 162 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
135 x->plane[0].src.stride, 163 x->plane[0].src.stride,
136 vp9_64_zeros, 0, &sse); 164 vp9_64_zeros, 0, &sse);
165 #endif // CONFIG_VP9_HIGHBITDEPTH
137 return (256 * var) >> num_pels_log2_lookup[bs]; 166 return (256 * var) >> num_pels_log2_lookup[bs];
138 } 167 }
139 } 168 }
140 169
141 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { 170 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
142 double energy; 171 double energy;
143 unsigned int var = block_variance(cpi, x, bs); 172 unsigned int var = block_variance(cpi, x, bs);
144 173
145 vp9_clear_system_state(); 174 vp9_clear_system_state();
146 175
147 energy = 0.9 * (log(var + 1.0) - 10.0); 176 energy = 0.9 * (log(var + 1.0) - 10.0);
148 return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX); 177 return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX);
149 } 178 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_dthread.c ('k') | source/libvpx/vp9/encoder/vp9_avg.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698