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