| OLD | NEW |
| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 static unsigned int block_variance(VP9_COMP *cpi, MACROBLOCK *x, | 111 static unsigned int block_variance(VP9_COMP *cpi, MACROBLOCK *x, |
| 112 BLOCK_SIZE bs) { | 112 BLOCK_SIZE bs) { |
| 113 MACROBLOCKD *xd = &x->e_mbd; | 113 MACROBLOCKD *xd = &x->e_mbd; |
| 114 unsigned int var, sse; | 114 unsigned int var, sse; |
| 115 int right_overflow = (xd->mb_to_right_edge < 0) ? | 115 int right_overflow = (xd->mb_to_right_edge < 0) ? |
| 116 ((-xd->mb_to_right_edge) >> 3) : 0; | 116 ((-xd->mb_to_right_edge) >> 3) : 0; |
| 117 int bottom_overflow = (xd->mb_to_bottom_edge < 0) ? | 117 int bottom_overflow = (xd->mb_to_bottom_edge < 0) ? |
| 118 ((-xd->mb_to_bottom_edge) >> 3) : 0; | 118 ((-xd->mb_to_bottom_edge) >> 3) : 0; |
| 119 | 119 |
| 120 if (right_overflow || bottom_overflow) { | 120 if (right_overflow || bottom_overflow) { |
| 121 int bw = (1 << (mi_width_log2(bs) + 3)) - right_overflow; | 121 const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow; |
| 122 int bh = (1 << (mi_height_log2(bs) + 3)) - bottom_overflow; | 122 const int bh = 8 * num_8x8_blocks_high_lookup[bs] - bottom_overflow; |
| 123 int avg; | 123 int avg; |
| 124 variance(x->plane[0].src.buf, x->plane[0].src.stride, | 124 variance(x->plane[0].src.buf, x->plane[0].src.stride, |
| 125 vp9_64_zeros, 0, bw, bh, &sse, &avg); | 125 vp9_64_zeros, 0, bw, bh, &sse, &avg); |
| 126 var = sse - (((int64_t)avg * avg) / (bw * bh)); | 126 var = sse - (((int64_t)avg * avg) / (bw * bh)); |
| 127 return (256 * var) / (bw * bh); | 127 return (256 * var) / (bw * bh); |
| 128 } else { | 128 } else { |
| 129 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, | 129 var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, |
| 130 x->plane[0].src.stride, | 130 x->plane[0].src.stride, |
| 131 vp9_64_zeros, 0, &sse); | 131 vp9_64_zeros, 0, &sse); |
| 132 return (256 * var) >> num_pels_log2_lookup[bs]; | 132 return (256 * var) >> num_pels_log2_lookup[bs]; |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { | 136 int vp9_block_energy(VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) { |
| 137 double energy; | 137 double energy; |
| 138 unsigned int var = block_variance(cpi, x, bs); | 138 unsigned int var = block_variance(cpi, x, bs); |
| 139 | 139 |
| 140 vp9_clear_system_state(); // __asm emms; | 140 vp9_clear_system_state(); // __asm emms; |
| 141 | 141 |
| 142 // if (var <= 1000) | 142 // if (var <= 1000) |
| 143 // return 0; | 143 // return 0; |
| 144 | 144 |
| 145 energy = 0.9*(logf(var + 1) - 10.0); | 145 energy = 0.9*(logf(var + 1) - 10.0); |
| 146 return clamp(round(energy), ENERGY_MIN, ENERGY_MAX); | 146 return clamp(round(energy), ENERGY_MIN, ENERGY_MAX); |
| 147 } | 147 } |
| OLD | NEW |