| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #include "vp9/common/vp9_common.h" | 10 #include "vp9/common/vp9_common.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 for (i = 0; i < 4; ++i, s+=p) | 25 for (i = 0; i < 4; ++i, s+=p) |
| 26 for (j = 0; j < 4; sum += s[j], ++j) {} | 26 for (j = 0; j < 4; sum += s[j], ++j) {} |
| 27 | 27 |
| 28 return (sum + 8) >> 4; | 28 return (sum + 8) >> 4; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // Integer projection onto row vectors. | 31 // Integer projection onto row vectors. |
| 32 void vp9_int_pro_row_c(int16_t *hbuf, uint8_t const *ref, | 32 void vp9_int_pro_row_c(int16_t *hbuf, uint8_t const *ref, |
| 33 const int ref_stride, const int height) { | 33 const int ref_stride, const int height) { |
| 34 int idx; | 34 int idx; |
| 35 const int norm_factor = MAX(8, height >> 1); |
| 35 for (idx = 0; idx < 16; ++idx) { | 36 for (idx = 0; idx < 16; ++idx) { |
| 36 int i; | 37 int i; |
| 37 hbuf[idx] = 0; | 38 hbuf[idx] = 0; |
| 38 for (i = 0; i < height; ++i) | 39 for (i = 0; i < height; ++i) |
| 39 hbuf[idx] += ref[i * ref_stride]; | 40 hbuf[idx] += ref[i * ref_stride]; |
| 41 hbuf[idx] /= norm_factor; |
| 40 ++ref; | 42 ++ref; |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 | 45 |
| 44 int16_t vp9_int_pro_col_c(uint8_t const *ref, const int width) { | 46 int16_t vp9_int_pro_col_c(uint8_t const *ref, const int width) { |
| 45 int idx; | 47 int idx; |
| 46 int16_t sum = 0; | 48 int16_t sum = 0; |
| 49 const int norm_factor = MAX(8, width >> 1); |
| 47 for (idx = 0; idx < width; ++idx) | 50 for (idx = 0; idx < width; ++idx) |
| 48 sum += ref[idx]; | 51 sum += ref[idx]; |
| 49 return sum; | 52 return sum / norm_factor; |
| 50 } | 53 } |
| 51 | 54 |
| 52 int vp9_vector_sad_c(int16_t const *ref, int16_t const *src, | 55 int vp9_vector_var_c(int16_t const *ref, int16_t const *src, |
| 53 const int width) { | 56 const int bwl) { |
| 54 int i; | 57 int i; |
| 55 int this_sad = 0; | 58 int width = 4 << bwl; |
| 56 for (i = 0; i < width; ++i) | 59 int sse = 0, mean = 0, var; |
| 57 this_sad += abs(ref[i] - src[i]); | 60 |
| 58 return this_sad; | 61 for (i = 0; i < width; ++i) { |
| 62 int diff = ref[i] - src[i]; |
| 63 mean += diff; |
| 64 sse += diff * diff; |
| 65 } |
| 66 |
| 67 var = sse - ((mean * mean) >> (bwl + 2)); |
| 68 return var; |
| 59 } | 69 } |
| 60 | 70 |
| 61 #if CONFIG_VP9_HIGHBITDEPTH | 71 #if CONFIG_VP9_HIGHBITDEPTH |
| 62 unsigned int vp9_highbd_avg_8x8_c(const uint8_t *s8, int p) { | 72 unsigned int vp9_highbd_avg_8x8_c(const uint8_t *s8, int p) { |
| 63 int i, j; | 73 int i, j; |
| 64 int sum = 0; | 74 int sum = 0; |
| 65 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); | 75 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); |
| 66 for (i = 0; i < 8; ++i, s+=p) | 76 for (i = 0; i < 8; ++i, s+=p) |
| 67 for (j = 0; j < 8; sum += s[j], ++j) {} | 77 for (j = 0; j < 8; sum += s[j], ++j) {} |
| 68 | 78 |
| 69 return (sum + 32) >> 6; | 79 return (sum + 32) >> 6; |
| 70 } | 80 } |
| 71 | 81 |
| 72 unsigned int vp9_highbd_avg_4x4_c(const uint8_t *s8, int p) { | 82 unsigned int vp9_highbd_avg_4x4_c(const uint8_t *s8, int p) { |
| 73 int i, j; | 83 int i, j; |
| 74 int sum = 0; | 84 int sum = 0; |
| 75 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); | 85 const uint16_t* s = CONVERT_TO_SHORTPTR(s8); |
| 76 for (i = 0; i < 4; ++i, s+=p) | 86 for (i = 0; i < 4; ++i, s+=p) |
| 77 for (j = 0; j < 4; sum += s[j], ++j) {} | 87 for (j = 0; j < 4; sum += s[j], ++j) {} |
| 78 | 88 |
| 79 return (sum + 8) >> 4; | 89 return (sum + 8) >> 4; |
| 80 } | 90 } |
| 81 #endif // CONFIG_VP9_HIGHBITDEPTH | 91 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 82 | 92 |
| 83 | 93 |
| OLD | NEW |