| 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_rtcd.h" | 10 #include "./vp9_rtcd.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 unsigned int vp9_avg_4x4_c(const uint8_t *s, int p) { | 23 unsigned int vp9_avg_4x4_c(const uint8_t *s, int p) { |
| 24 int i, j; | 24 int i, j; |
| 25 int sum = 0; | 25 int sum = 0; |
| 26 for (i = 0; i < 4; ++i, s+=p) | 26 for (i = 0; i < 4; ++i, s+=p) |
| 27 for (j = 0; j < 4; sum += s[j], ++j) {} | 27 for (j = 0; j < 4; sum += s[j], ++j) {} |
| 28 | 28 |
| 29 return (sum + 8) >> 4; | 29 return (sum + 8) >> 4; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // src_diff: first pass, 9 bit, dynamic range [-255, 255] |
| 33 // second pass, 12 bit, dynamic range [-2040, 2040] |
| 32 static void hadamard_col8(const int16_t *src_diff, int src_stride, | 34 static void hadamard_col8(const int16_t *src_diff, int src_stride, |
| 33 int16_t *coeff) { | 35 int16_t *coeff) { |
| 34 int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride]; | 36 int16_t b0 = src_diff[0 * src_stride] + src_diff[1 * src_stride]; |
| 35 int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride]; | 37 int16_t b1 = src_diff[0 * src_stride] - src_diff[1 * src_stride]; |
| 36 int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride]; | 38 int16_t b2 = src_diff[2 * src_stride] + src_diff[3 * src_stride]; |
| 37 int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride]; | 39 int16_t b3 = src_diff[2 * src_stride] - src_diff[3 * src_stride]; |
| 38 int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride]; | 40 int16_t b4 = src_diff[4 * src_stride] + src_diff[5 * src_stride]; |
| 39 int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride]; | 41 int16_t b5 = src_diff[4 * src_stride] - src_diff[5 * src_stride]; |
| 40 int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride]; | 42 int16_t b6 = src_diff[6 * src_stride] + src_diff[7 * src_stride]; |
| 41 int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride]; | 43 int16_t b7 = src_diff[6 * src_stride] - src_diff[7 * src_stride]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 58 coeff[1] = c2 - c6; | 60 coeff[1] = c2 - c6; |
| 59 coeff[5] = c3 - c7; | 61 coeff[5] = c3 - c7; |
| 60 } | 62 } |
| 61 | 63 |
| 62 void vp9_hadamard_8x8_c(int16_t const *src_diff, int src_stride, | 64 void vp9_hadamard_8x8_c(int16_t const *src_diff, int src_stride, |
| 63 int16_t *coeff) { | 65 int16_t *coeff) { |
| 64 int idx; | 66 int idx; |
| 65 int16_t buffer[64]; | 67 int16_t buffer[64]; |
| 66 int16_t *tmp_buf = &buffer[0]; | 68 int16_t *tmp_buf = &buffer[0]; |
| 67 for (idx = 0; idx < 8; ++idx) { | 69 for (idx = 0; idx < 8; ++idx) { |
| 68 hadamard_col8(src_diff, src_stride, tmp_buf); | 70 hadamard_col8(src_diff, src_stride, tmp_buf); // src_diff: 9 bit |
| 71 // dynamic range [-255, 255] |
| 69 tmp_buf += 8; | 72 tmp_buf += 8; |
| 70 ++src_diff; | 73 ++src_diff; |
| 71 } | 74 } |
| 72 | 75 |
| 73 tmp_buf = &buffer[0]; | 76 tmp_buf = &buffer[0]; |
| 74 for (idx = 0; idx < 8; ++idx) { | 77 for (idx = 0; idx < 8; ++idx) { |
| 75 hadamard_col8(tmp_buf, 8, coeff); | 78 hadamard_col8(tmp_buf, 8, coeff); // tmp_buf: 12 bit |
| 76 coeff += 8; | 79 // dynamic range [-2040, 2040] |
| 80 coeff += 8; // coeff: 15 bit |
| 81 // dynamic range [-16320, 16320] |
| 77 ++tmp_buf; | 82 ++tmp_buf; |
| 78 } | 83 } |
| 79 } | 84 } |
| 80 | 85 |
| 81 // In place 16x16 2D Hadamard transform | 86 // In place 16x16 2D Hadamard transform |
| 82 void vp9_hadamard_16x16_c(int16_t const *src_diff, int src_stride, | 87 void vp9_hadamard_16x16_c(int16_t const *src_diff, int src_stride, |
| 83 int16_t *coeff) { | 88 int16_t *coeff) { |
| 84 int idx; | 89 int idx; |
| 85 for (idx = 0; idx < 4; ++idx) { | 90 for (idx = 0; idx < 4; ++idx) { |
| 91 // src_diff: 9 bit, dynamic range [-255, 255] |
| 86 int16_t const *src_ptr = src_diff + (idx >> 1) * 8 * src_stride | 92 int16_t const *src_ptr = src_diff + (idx >> 1) * 8 * src_stride |
| 87 + (idx & 0x01) * 8; | 93 + (idx & 0x01) * 8; |
| 88 vp9_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64); | 94 vp9_hadamard_8x8_c(src_ptr, src_stride, coeff + idx * 64); |
| 89 } | 95 } |
| 90 | 96 |
| 97 // coeff: 15 bit, dynamic range [-16320, 16320] |
| 91 for (idx = 0; idx < 64; ++idx) { | 98 for (idx = 0; idx < 64; ++idx) { |
| 92 int16_t a0 = coeff[0]; | 99 int16_t a0 = coeff[0]; |
| 93 int16_t a1 = coeff[64]; | 100 int16_t a1 = coeff[64]; |
| 94 int16_t a2 = coeff[128]; | 101 int16_t a2 = coeff[128]; |
| 95 int16_t a3 = coeff[192]; | 102 int16_t a3 = coeff[192]; |
| 96 | 103 |
| 97 int16_t b0 = a0 + a1; | 104 int16_t b0 = (a0 + a1) >> 1; // (a0 + a1): 16 bit, [-32640, 32640] |
| 98 int16_t b1 = a0 - a1; | 105 int16_t b1 = (a0 - a1) >> 1; // b0-b3: 15 bit, dynamic range |
| 99 int16_t b2 = a2 + a3; | 106 int16_t b2 = (a2 + a3) >> 1; // [-16320, 16320] |
| 100 int16_t b3 = a2 - a3; | 107 int16_t b3 = (a2 - a3) >> 1; |
| 101 | 108 |
| 102 coeff[0] = (b0 + b2) >> 1; | 109 coeff[0] = b0 + b2; // 16 bit, [-32640, 32640] |
| 103 coeff[64] = (b1 + b3) >> 1; | 110 coeff[64] = b1 + b3; |
| 104 coeff[128] = (b0 - b2) >> 1; | 111 coeff[128] = b0 - b2; |
| 105 coeff[192] = (b1 - b3) >> 1; | 112 coeff[192] = b1 - b3; |
| 106 | 113 |
| 107 ++coeff; | 114 ++coeff; |
| 108 } | 115 } |
| 109 } | 116 } |
| 110 | 117 |
| 118 // coeff: 16 bits, dynamic range [-32640, 32640]. |
| 119 // length: value range {16, 64, 256, 1024}. |
| 111 int16_t vp9_satd_c(const int16_t *coeff, int length) { | 120 int16_t vp9_satd_c(const int16_t *coeff, int length) { |
| 112 int i; | 121 int i; |
| 113 int satd = 0; | 122 int satd = 0; |
| 114 for (i = 0; i < length; ++i) | 123 for (i = 0; i < length; ++i) |
| 115 satd += abs(coeff[i]); | 124 satd += abs(coeff[i]); |
| 116 | 125 |
| 126 // satd: 26 bits, dynamic range [-32640 * 1024, 32640 * 1024] |
| 117 return (int16_t)satd; | 127 return (int16_t)satd; |
| 118 } | 128 } |
| 119 | 129 |
| 120 // Integer projection onto row vectors. | 130 // Integer projection onto row vectors. |
| 121 void vp9_int_pro_row_c(int16_t *hbuf, uint8_t const *ref, | 131 // height: value range {16, 32, 64}. |
| 132 void vp9_int_pro_row_c(int16_t hbuf[16], uint8_t const *ref, |
| 122 const int ref_stride, const int height) { | 133 const int ref_stride, const int height) { |
| 123 int idx; | 134 int idx; |
| 124 const int norm_factor = MAX(8, height >> 1); | 135 const int norm_factor = height >> 1; |
| 125 for (idx = 0; idx < 16; ++idx) { | 136 for (idx = 0; idx < 16; ++idx) { |
| 126 int i; | 137 int i; |
| 127 hbuf[idx] = 0; | 138 hbuf[idx] = 0; |
| 139 // hbuf[idx]: 14 bit, dynamic range [0, 16320]. |
| 128 for (i = 0; i < height; ++i) | 140 for (i = 0; i < height; ++i) |
| 129 hbuf[idx] += ref[i * ref_stride]; | 141 hbuf[idx] += ref[i * ref_stride]; |
| 142 // hbuf[idx]: 9 bit, dynamic range [0, 510]. |
| 130 hbuf[idx] /= norm_factor; | 143 hbuf[idx] /= norm_factor; |
| 131 ++ref; | 144 ++ref; |
| 132 } | 145 } |
| 133 } | 146 } |
| 134 | 147 |
| 148 // width: value range {16, 32, 64}. |
| 135 int16_t vp9_int_pro_col_c(uint8_t const *ref, const int width) { | 149 int16_t vp9_int_pro_col_c(uint8_t const *ref, const int width) { |
| 136 int idx; | 150 int idx; |
| 137 int16_t sum = 0; | 151 int16_t sum = 0; |
| 152 // sum: 14 bit, dynamic range [0, 16320] |
| 138 for (idx = 0; idx < width; ++idx) | 153 for (idx = 0; idx < width; ++idx) |
| 139 sum += ref[idx]; | 154 sum += ref[idx]; |
| 140 return sum; | 155 return sum; |
| 141 } | 156 } |
| 142 | 157 |
| 143 int vp9_vector_var_c(int16_t const *ref, int16_t const *src, | 158 int vp9_vector_var_c(int16_t const *ref, int16_t const *src, |
| 144 const int bwl) { | 159 const int bwl) { |
| 145 int i; | 160 int i; |
| 146 int width = 4 << bwl; | 161 int width = 4 << bwl; |
| 147 int sse = 0, mean = 0, var; | 162 int sse = 0, mean = 0, var; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 for (j = 0; j < 8; ++j) { | 217 for (j = 0; j < 8; ++j) { |
| 203 int diff = abs(s[j]-d[j]); | 218 int diff = abs(s[j]-d[j]); |
| 204 *min = diff < *min ? diff : *min; | 219 *min = diff < *min ? diff : *min; |
| 205 *max = diff > *max ? diff : *max; | 220 *max = diff > *max ? diff : *max; |
| 206 } | 221 } |
| 207 } | 222 } |
| 208 } | 223 } |
| 209 #endif // CONFIG_VP9_HIGHBITDEPTH | 224 #endif // CONFIG_VP9_HIGHBITDEPTH |
| 210 | 225 |
| 211 | 226 |
| OLD | NEW |