| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC 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 |
| 11 /* | 11 /* |
| 12 * This file contains the implementation of function | 12 * This file contains the implementation of function |
| 13 * WebRtcSpl_MaxAbsValueW16() | 13 * WebRtcSpl_MaxAbsValueW16() |
| 14 * | 14 * |
| 15 * The description header can be found in signal_processing_library.h. | 15 * The description header can be found in signal_processing_library.h. |
| 16 * | 16 * |
| 17 */ | 17 */ |
| 18 | 18 |
| 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 20 | 20 |
| 21 // Maximum absolute value of word16 vector. | 21 // Maximum absolute value of word16 vector. |
| 22 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, int length) { | 22 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length) { |
| 23 int32_t totMax = 0; | 23 int32_t totMax = 0; |
| 24 int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3; | 24 int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3; |
| 25 int i, loop_size; | 25 size_t i, loop_size; |
| 26 | 26 |
| 27 if (vector == NULL || length <= 0) { | 27 if (vector == NULL || length == 0) { |
| 28 return -1; | 28 return -1; |
| 29 } | 29 } |
| 30 #if defined(MIPS_DSP_R1) | 30 #if defined(MIPS_DSP_R1) |
| 31 const int32_t* tmpvec32 = (int32_t*)vector; | 31 const int32_t* tmpvec32 = (int32_t*)vector; |
| 32 loop_size = length >> 4; | 32 loop_size = length >> 4; |
| 33 | 33 |
| 34 for (i = 0; i < loop_size; i++) { | 34 for (i = 0; i < loop_size; i++) { |
| 35 __asm__ volatile ( | 35 __asm__ volatile ( |
| 36 "lw %[tmp32_0], 0(%[tmpvec32]) \n\t" | 36 "lw %[tmp32_0], 0(%[tmpvec32]) \n\t" |
| 37 "lw %[tmp32_1], 4(%[tmpvec32]) \n\t" | 37 "lw %[tmp32_1], 4(%[tmpvec32]) \n\t" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 "movn %[totMax], %[v16MaxMax], %[r] \n\t" | 215 "movn %[totMax], %[v16MaxMax], %[r] \n\t" |
| 216 : [totMax] "+r" (totMax), [r] "=&r" (r) | 216 : [totMax] "+r" (totMax), [r] "=&r" (r) |
| 217 : [v16MaxMax] "r" (v16MaxMax) | 217 : [v16MaxMax] "r" (v16MaxMax) |
| 218 ); | 218 ); |
| 219 #endif // #if defined(MIPS_DSP_R1) | 219 #endif // #if defined(MIPS_DSP_R1) |
| 220 return (int16_t)totMax; | 220 return (int16_t)totMax; |
| 221 } | 221 } |
| 222 | 222 |
| 223 #if defined(MIPS_DSP_R1_LE) | 223 #if defined(MIPS_DSP_R1_LE) |
| 224 // Maximum absolute value of word32 vector. Version for MIPS platform. | 224 // Maximum absolute value of word32 vector. Version for MIPS platform. |
| 225 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, int length) { | 225 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length) { |
| 226 // Use uint32_t for the local variables, to accommodate the return value | 226 // Use uint32_t for the local variables, to accommodate the return value |
| 227 // of abs(0x80000000), which is 0x80000000. | 227 // of abs(0x80000000), which is 0x80000000. |
| 228 | 228 |
| 229 uint32_t absolute = 0, maximum = 0; | 229 uint32_t absolute = 0, maximum = 0; |
| 230 int tmp1 = 0, max_value = 0x7fffffff; | 230 int tmp1 = 0, max_value = 0x7fffffff; |
| 231 | 231 |
| 232 if (vector == NULL || length <= 0) { | 232 if (vector == NULL || length == 0) { |
| 233 return -1; | 233 return -1; |
| 234 } | 234 } |
| 235 | 235 |
| 236 __asm__ volatile ( | 236 __asm__ volatile ( |
| 237 ".set push \n\t" | 237 ".set push \n\t" |
| 238 ".set noreorder \n\t" | 238 ".set noreorder \n\t" |
| 239 | 239 |
| 240 "1: \n\t" | 240 "1: \n\t" |
| 241 "lw %[absolute], 0(%[vector]) \n\t" | 241 "lw %[absolute], 0(%[vector]) \n\t" |
| 242 "absq_s.w %[absolute], %[absolute] \n\t" | 242 "absq_s.w %[absolute], %[absolute] \n\t" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 253 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [absolute] "+r" (absolute) | 253 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [absolute] "+r" (absolute) |
| 254 : [vector] "r" (vector), [length] "r" (length), [max_value] "r" (max_value) | 254 : [vector] "r" (vector), [length] "r" (length), [max_value] "r" (max_value) |
| 255 : "memory" | 255 : "memory" |
| 256 ); | 256 ); |
| 257 | 257 |
| 258 return (int32_t)maximum; | 258 return (int32_t)maximum; |
| 259 } | 259 } |
| 260 #endif // #if defined(MIPS_DSP_R1_LE) | 260 #endif // #if defined(MIPS_DSP_R1_LE) |
| 261 | 261 |
| 262 // Maximum value of word16 vector. Version for MIPS platform. | 262 // Maximum value of word16 vector. Version for MIPS platform. |
| 263 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, int length) { | 263 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length) { |
| 264 int16_t maximum = WEBRTC_SPL_WORD16_MIN; | 264 int16_t maximum = WEBRTC_SPL_WORD16_MIN; |
| 265 int tmp1; | 265 int tmp1; |
| 266 int16_t value; | 266 int16_t value; |
| 267 | 267 |
| 268 if (vector == NULL || length <= 0) { | 268 if (vector == NULL || length == 0) { |
| 269 return maximum; | 269 return maximum; |
| 270 } | 270 } |
| 271 | 271 |
| 272 __asm__ volatile ( | 272 __asm__ volatile ( |
| 273 ".set push \n\t" | 273 ".set push \n\t" |
| 274 ".set noreorder \n\t" | 274 ".set noreorder \n\t" |
| 275 | 275 |
| 276 "1: \n\t" | 276 "1: \n\t" |
| 277 "lh %[value], 0(%[vector]) \n\t" | 277 "lh %[value], 0(%[vector]) \n\t" |
| 278 "addiu %[length], %[length], -1 \n\t" | 278 "addiu %[length], %[length], -1 \n\t" |
| 279 "slt %[tmp1], %[maximum], %[value] \n\t" | 279 "slt %[tmp1], %[maximum], %[value] \n\t" |
| 280 "movn %[maximum], %[value], %[tmp1] \n\t" | 280 "movn %[maximum], %[value], %[tmp1] \n\t" |
| 281 "bgtz %[length], 1b \n\t" | 281 "bgtz %[length], 1b \n\t" |
| 282 " addiu %[vector], %[vector], 2 \n\t" | 282 " addiu %[vector], %[vector], 2 \n\t" |
| 283 ".set pop \n\t" | 283 ".set pop \n\t" |
| 284 | 284 |
| 285 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) | 285 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) |
| 286 : [vector] "r" (vector), [length] "r" (length) | 286 : [vector] "r" (vector), [length] "r" (length) |
| 287 : "memory" | 287 : "memory" |
| 288 ); | 288 ); |
| 289 | 289 |
| 290 return maximum; | 290 return maximum; |
| 291 } | 291 } |
| 292 | 292 |
| 293 // Maximum value of word32 vector. Version for MIPS platform. | 293 // Maximum value of word32 vector. Version for MIPS platform. |
| 294 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, int length) { | 294 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length) { |
| 295 int32_t maximum = WEBRTC_SPL_WORD32_MIN; | 295 int32_t maximum = WEBRTC_SPL_WORD32_MIN; |
| 296 int tmp1, value; | 296 int tmp1, value; |
| 297 | 297 |
| 298 if (vector == NULL || length <= 0) { | 298 if (vector == NULL || length == 0) { |
| 299 return maximum; | 299 return maximum; |
| 300 } | 300 } |
| 301 | 301 |
| 302 __asm__ volatile ( | 302 __asm__ volatile ( |
| 303 ".set push \n\t" | 303 ".set push \n\t" |
| 304 ".set noreorder \n\t" | 304 ".set noreorder \n\t" |
| 305 | 305 |
| 306 "1: \n\t" | 306 "1: \n\t" |
| 307 "lw %[value], 0(%[vector]) \n\t" | 307 "lw %[value], 0(%[vector]) \n\t" |
| 308 "addiu %[length], %[length], -1 \n\t" | 308 "addiu %[length], %[length], -1 \n\t" |
| 309 "slt %[tmp1], %[maximum], %[value] \n\t" | 309 "slt %[tmp1], %[maximum], %[value] \n\t" |
| 310 "movn %[maximum], %[value], %[tmp1] \n\t" | 310 "movn %[maximum], %[value], %[tmp1] \n\t" |
| 311 "bgtz %[length], 1b \n\t" | 311 "bgtz %[length], 1b \n\t" |
| 312 " addiu %[vector], %[vector], 4 \n\t" | 312 " addiu %[vector], %[vector], 4 \n\t" |
| 313 | 313 |
| 314 ".set pop \n\t" | 314 ".set pop \n\t" |
| 315 | 315 |
| 316 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) | 316 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) |
| 317 : [vector] "r" (vector), [length] "r" (length) | 317 : [vector] "r" (vector), [length] "r" (length) |
| 318 : "memory" | 318 : "memory" |
| 319 ); | 319 ); |
| 320 | 320 |
| 321 return maximum; | 321 return maximum; |
| 322 } | 322 } |
| 323 | 323 |
| 324 // Minimum value of word16 vector. Version for MIPS platform. | 324 // Minimum value of word16 vector. Version for MIPS platform. |
| 325 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, int length) { | 325 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length) { |
| 326 int16_t minimum = WEBRTC_SPL_WORD16_MAX; | 326 int16_t minimum = WEBRTC_SPL_WORD16_MAX; |
| 327 int tmp1; | 327 int tmp1; |
| 328 int16_t value; | 328 int16_t value; |
| 329 | 329 |
| 330 if (vector == NULL || length <= 0) { | 330 if (vector == NULL || length == 0) { |
| 331 return minimum; | 331 return minimum; |
| 332 } | 332 } |
| 333 | 333 |
| 334 __asm__ volatile ( | 334 __asm__ volatile ( |
| 335 ".set push \n\t" | 335 ".set push \n\t" |
| 336 ".set noreorder \n\t" | 336 ".set noreorder \n\t" |
| 337 | 337 |
| 338 "1: \n\t" | 338 "1: \n\t" |
| 339 "lh %[value], 0(%[vector]) \n\t" | 339 "lh %[value], 0(%[vector]) \n\t" |
| 340 "addiu %[length], %[length], -1 \n\t" | 340 "addiu %[length], %[length], -1 \n\t" |
| 341 "slt %[tmp1], %[value], %[minimum] \n\t" | 341 "slt %[tmp1], %[value], %[minimum] \n\t" |
| 342 "movn %[minimum], %[value], %[tmp1] \n\t" | 342 "movn %[minimum], %[value], %[tmp1] \n\t" |
| 343 "bgtz %[length], 1b \n\t" | 343 "bgtz %[length], 1b \n\t" |
| 344 " addiu %[vector], %[vector], 2 \n\t" | 344 " addiu %[vector], %[vector], 2 \n\t" |
| 345 | 345 |
| 346 ".set pop \n\t" | 346 ".set pop \n\t" |
| 347 | 347 |
| 348 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) | 348 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) |
| 349 : [vector] "r" (vector), [length] "r" (length) | 349 : [vector] "r" (vector), [length] "r" (length) |
| 350 : "memory" | 350 : "memory" |
| 351 ); | 351 ); |
| 352 | 352 |
| 353 return minimum; | 353 return minimum; |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Minimum value of word32 vector. Version for MIPS platform. | 356 // Minimum value of word32 vector. Version for MIPS platform. |
| 357 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, int length) { | 357 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length) { |
| 358 int32_t minimum = WEBRTC_SPL_WORD32_MAX; | 358 int32_t minimum = WEBRTC_SPL_WORD32_MAX; |
| 359 int tmp1, value; | 359 int tmp1, value; |
| 360 | 360 |
| 361 if (vector == NULL || length <= 0) { | 361 if (vector == NULL || length == 0) { |
| 362 return minimum; | 362 return minimum; |
| 363 } | 363 } |
| 364 | 364 |
| 365 __asm__ volatile ( | 365 __asm__ volatile ( |
| 366 ".set push \n\t" | 366 ".set push \n\t" |
| 367 ".set noreorder \n\t" | 367 ".set noreorder \n\t" |
| 368 | 368 |
| 369 "1: \n\t" | 369 "1: \n\t" |
| 370 "lw %[value], 0(%[vector]) \n\t" | 370 "lw %[value], 0(%[vector]) \n\t" |
| 371 "addiu %[length], %[length], -1 \n\t" | 371 "addiu %[length], %[length], -1 \n\t" |
| 372 "slt %[tmp1], %[value], %[minimum] \n\t" | 372 "slt %[tmp1], %[value], %[minimum] \n\t" |
| 373 "movn %[minimum], %[value], %[tmp1] \n\t" | 373 "movn %[minimum], %[value], %[tmp1] \n\t" |
| 374 "bgtz %[length], 1b \n\t" | 374 "bgtz %[length], 1b \n\t" |
| 375 " addiu %[vector], %[vector], 4 \n\t" | 375 " addiu %[vector], %[vector], 4 \n\t" |
| 376 | 376 |
| 377 ".set pop \n\t" | 377 ".set pop \n\t" |
| 378 | 378 |
| 379 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) | 379 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) |
| 380 : [vector] "r" (vector), [length] "r" (length) | 380 : [vector] "r" (vector), [length] "r" (length) |
| 381 : "memory" | 381 : "memory" |
| 382 ); | 382 ); |
| 383 | 383 |
| 384 return minimum; | 384 return minimum; |
| 385 } | 385 } |
| OLD | NEW |