| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // Use of this source code is governed by a BSD-style license |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // that can be found in the COPYING file in the root of the source |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // tree. An additional intellectual property rights grant can be found |
| 6 // in the file PATENTS. All contributing project authors may |
| 7 // be found in the AUTHORS file in the root of the source tree. |
| 6 // ----------------------------------------------------------------------------- | 8 // ----------------------------------------------------------------------------- |
| 7 // | 9 // |
| 8 // Speed-critical encoding functions. | 10 // Speed-critical encoding functions. |
| 9 // | 11 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 12 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 13 |
| 12 #include <stdlib.h> // for abs() | 14 #include <stdlib.h> // for abs() |
| 13 #include "./dsp.h" | 15 #include "./dsp.h" |
| 14 #include "../enc/vp8enci.h" | 16 #include "../enc/vp8enci.h" |
| 15 | 17 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 int tmp[16]; | 137 int tmp[16]; |
| 136 for (i = 0; i < 4; ++i, src += BPS, ref += BPS) { | 138 for (i = 0; i < 4; ++i, src += BPS, ref += BPS) { |
| 137 const int d0 = src[0] - ref[0]; // 9bit dynamic range ([-255,255]) | 139 const int d0 = src[0] - ref[0]; // 9bit dynamic range ([-255,255]) |
| 138 const int d1 = src[1] - ref[1]; | 140 const int d1 = src[1] - ref[1]; |
| 139 const int d2 = src[2] - ref[2]; | 141 const int d2 = src[2] - ref[2]; |
| 140 const int d3 = src[3] - ref[3]; | 142 const int d3 = src[3] - ref[3]; |
| 141 const int a0 = (d0 + d3); // 10b [-510,510] | 143 const int a0 = (d0 + d3); // 10b [-510,510] |
| 142 const int a1 = (d1 + d2); | 144 const int a1 = (d1 + d2); |
| 143 const int a2 = (d1 - d2); | 145 const int a2 = (d1 - d2); |
| 144 const int a3 = (d0 - d3); | 146 const int a3 = (d0 - d3); |
| 145 tmp[0 + i * 4] = (a0 + a1) << 3; // 14b [-8160,8160] | 147 tmp[0 + i * 4] = (a0 + a1) * 8; // 14b [-8160,8160] |
| 146 tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542] | 148 tmp[1 + i * 4] = (a2 * 2217 + a3 * 5352 + 1812) >> 9; // [-7536,7542] |
| 147 tmp[2 + i * 4] = (a0 - a1) << 3; | 149 tmp[2 + i * 4] = (a0 - a1) * 8; |
| 148 tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9; | 150 tmp[3 + i * 4] = (a3 * 2217 - a2 * 5352 + 937) >> 9; |
| 149 } | 151 } |
| 150 for (i = 0; i < 4; ++i) { | 152 for (i = 0; i < 4; ++i) { |
| 151 const int a0 = (tmp[0 + i] + tmp[12 + i]); // 15b | 153 const int a0 = (tmp[0 + i] + tmp[12 + i]); // 15b |
| 152 const int a1 = (tmp[4 + i] + tmp[ 8 + i]); | 154 const int a1 = (tmp[4 + i] + tmp[ 8 + i]); |
| 153 const int a2 = (tmp[4 + i] - tmp[ 8 + i]); | 155 const int a2 = (tmp[4 + i] - tmp[ 8 + i]); |
| 154 const int a3 = (tmp[0 + i] - tmp[12 + i]); | 156 const int a3 = (tmp[0 + i] - tmp[12 + i]); |
| 155 out[0 + i] = (a0 + a1 + 7) >> 4; // 12b | 157 out[0 + i] = (a0 + a1 + 7) >> 4; // 12b |
| 156 out[4 + i] = ((a2 * 2217 + a3 * 5352 + 12000) >> 16) + (a3 != 0); | 158 out[4 + i] = ((a2 * 2217 + a3 * 5352 + 12000) >> 16) + (a3 != 0); |
| 157 out[8 + i] = (a0 - a1 + 7) >> 4; | 159 out[8 + i] = (a0 - a1 + 7) >> 4; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 180 const int a3 = dc - tmp[3 + i * 4]; | 182 const int a3 = dc - tmp[3 + i * 4]; |
| 181 out[ 0] = (a0 + a1) >> 3; | 183 out[ 0] = (a0 + a1) >> 3; |
| 182 out[16] = (a3 + a2) >> 3; | 184 out[16] = (a3 + a2) >> 3; |
| 183 out[32] = (a0 - a1) >> 3; | 185 out[32] = (a0 - a1) >> 3; |
| 184 out[48] = (a3 - a2) >> 3; | 186 out[48] = (a3 - a2) >> 3; |
| 185 out += 64; | 187 out += 64; |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 189 static void FTransformWHT(const int16_t* in, int16_t* out) { | 191 static void FTransformWHT(const int16_t* in, int16_t* out) { |
| 190 int tmp[16]; | 192 // input is 12b signed |
| 193 int16_t tmp[16]; |
| 191 int i; | 194 int i; |
| 192 for (i = 0; i < 4; ++i, in += 64) { | 195 for (i = 0; i < 4; ++i, in += 64) { |
| 193 const int a0 = (in[0 * 16] + in[2 * 16]) << 2; | 196 const int a0 = (in[0 * 16] + in[2 * 16]); // 13b |
| 194 const int a1 = (in[1 * 16] + in[3 * 16]) << 2; | 197 const int a1 = (in[1 * 16] + in[3 * 16]); |
| 195 const int a2 = (in[1 * 16] - in[3 * 16]) << 2; | 198 const int a2 = (in[1 * 16] - in[3 * 16]); |
| 196 const int a3 = (in[0 * 16] - in[2 * 16]) << 2; | 199 const int a3 = (in[0 * 16] - in[2 * 16]); |
| 197 tmp[0 + i * 4] = (a0 + a1) + (a0 != 0); | 200 tmp[0 + i * 4] = a0 + a1; // 14b |
| 198 tmp[1 + i * 4] = a3 + a2; | 201 tmp[1 + i * 4] = a3 + a2; |
| 199 tmp[2 + i * 4] = a3 - a2; | 202 tmp[2 + i * 4] = a3 - a2; |
| 200 tmp[3 + i * 4] = a0 - a1; | 203 tmp[3 + i * 4] = a0 - a1; |
| 201 } | 204 } |
| 202 for (i = 0; i < 4; ++i) { | 205 for (i = 0; i < 4; ++i) { |
| 203 const int a0 = (tmp[0 + i] + tmp[8 + i]); | 206 const int a0 = (tmp[0 + i] + tmp[8 + i]); // 15b |
| 204 const int a1 = (tmp[4 + i] + tmp[12+ i]); | 207 const int a1 = (tmp[4 + i] + tmp[12+ i]); |
| 205 const int a2 = (tmp[4 + i] - tmp[12+ i]); | 208 const int a2 = (tmp[4 + i] - tmp[12+ i]); |
| 206 const int a3 = (tmp[0 + i] - tmp[8 + i]); | 209 const int a3 = (tmp[0 + i] - tmp[8 + i]); |
| 207 const int b0 = a0 + a1; | 210 const int b0 = a0 + a1; // 16b |
| 208 const int b1 = a3 + a2; | 211 const int b1 = a3 + a2; |
| 209 const int b2 = a3 - a2; | 212 const int b2 = a3 - a2; |
| 210 const int b3 = a0 - a1; | 213 const int b3 = a0 - a1; |
| 211 out[ 0 + i] = (b0 + (b0 > 0) + 3) >> 3; | 214 out[ 0 + i] = b0 >> 1; // 15b |
| 212 out[ 4 + i] = (b1 + (b1 > 0) + 3) >> 3; | 215 out[ 4 + i] = b1 >> 1; |
| 213 out[ 8 + i] = (b2 + (b2 > 0) + 3) >> 3; | 216 out[ 8 + i] = b2 >> 1; |
| 214 out[12 + i] = (b3 + (b3 > 0) + 3) >> 3; | 217 out[12 + i] = b3 >> 1; |
| 215 } | 218 } |
| 216 } | 219 } |
| 217 | 220 |
| 218 #undef MUL | 221 #undef MUL |
| 219 #undef STORE | 222 #undef STORE |
| 220 | 223 |
| 221 //------------------------------------------------------------------------------ | 224 //------------------------------------------------------------------------------ |
| 222 // Intra predictions | 225 // Intra predictions |
| 223 | 226 |
| 224 #define DST(x, y) dst[(x) + (y) * BPS] | 227 #define DST(x, y) dst[(x) + (y) * BPS] |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 if (VP8GetCPUInfo(kNEON)) { | 722 if (VP8GetCPUInfo(kNEON)) { |
| 720 VP8EncDspInitNEON(); | 723 VP8EncDspInitNEON(); |
| 721 } | 724 } |
| 722 #endif | 725 #endif |
| 723 } | 726 } |
| 724 } | 727 } |
| 725 | 728 |
| 726 #if defined(__cplusplus) || defined(c_plusplus) | 729 #if defined(__cplusplus) || defined(c_plusplus) |
| 727 } // extern "C" | 730 } // extern "C" |
| 728 #endif | 731 #endif |
| OLD | NEW |