Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: webrtc/common_audio/signal_processing/min_max_operations_mips.c

Issue 2274083002: Replace calls to assert() with RTC_DCHECK_*() in .c code (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 19 #include "webrtc/base/checks.h"
20
21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 20 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
22 21
23 // Maximum absolute value of word16 vector. 22 // Maximum absolute value of word16 vector.
24 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length) { 23 int16_t WebRtcSpl_MaxAbsValueW16_mips(const int16_t* vector, size_t length) {
25 int32_t totMax = 0; 24 int32_t totMax = 0;
26 int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3; 25 int32_t tmp32_0, tmp32_1, tmp32_2, tmp32_3;
27 size_t i, loop_size; 26 size_t i, loop_size;
28 27
29 assert(length > 0); 28 RTC_DCHECK_GT(length, 0);
30 29
31 #if defined(MIPS_DSP_R1) 30 #if defined(MIPS_DSP_R1)
32 const int32_t* tmpvec32 = (int32_t*)vector; 31 const int32_t* tmpvec32 = (int32_t*)vector;
33 loop_size = length >> 4; 32 loop_size = length >> 4;
34 33
35 for (i = 0; i < loop_size; i++) { 34 for (i = 0; i < loop_size; i++) {
36 __asm__ volatile ( 35 __asm__ volatile (
37 "lw %[tmp32_0], 0(%[tmpvec32]) \n\t" 36 "lw %[tmp32_0], 0(%[tmpvec32]) \n\t"
38 "lw %[tmp32_1], 4(%[tmpvec32]) \n\t" 37 "lw %[tmp32_1], 4(%[tmpvec32]) \n\t"
39 "lw %[tmp32_2], 8(%[tmpvec32]) \n\t" 38 "lw %[tmp32_2], 8(%[tmpvec32]) \n\t"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 222
224 #if defined(MIPS_DSP_R1_LE) 223 #if defined(MIPS_DSP_R1_LE)
225 // Maximum absolute value of word32 vector. Version for MIPS platform. 224 // Maximum absolute value of word32 vector. Version for MIPS platform.
226 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length) { 225 int32_t WebRtcSpl_MaxAbsValueW32_mips(const int32_t* vector, size_t length) {
227 // 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
228 // of abs(0x80000000), which is 0x80000000. 227 // of abs(0x80000000), which is 0x80000000.
229 228
230 uint32_t absolute = 0, maximum = 0; 229 uint32_t absolute = 0, maximum = 0;
231 int tmp1 = 0, max_value = 0x7fffffff; 230 int tmp1 = 0, max_value = 0x7fffffff;
232 231
233 assert(length > 0); 232 RTC_DCHECK_GT(length, 0);
234 233
235 __asm__ volatile ( 234 __asm__ volatile (
236 ".set push \n\t" 235 ".set push \n\t"
237 ".set noreorder \n\t" 236 ".set noreorder \n\t"
238 237
239 "1: \n\t" 238 "1: \n\t"
240 "lw %[absolute], 0(%[vector]) \n\t" 239 "lw %[absolute], 0(%[vector]) \n\t"
241 "absq_s.w %[absolute], %[absolute] \n\t" 240 "absq_s.w %[absolute], %[absolute] \n\t"
242 "addiu %[length], %[length], -1 \n\t" 241 "addiu %[length], %[length], -1 \n\t"
243 "slt %[tmp1], %[maximum], %[absolute] \n\t" 242 "slt %[tmp1], %[maximum], %[absolute] \n\t"
(...skipping 13 matching lines...) Expand all
257 return (int32_t)maximum; 256 return (int32_t)maximum;
258 } 257 }
259 #endif // #if defined(MIPS_DSP_R1_LE) 258 #endif // #if defined(MIPS_DSP_R1_LE)
260 259
261 // Maximum value of word16 vector. Version for MIPS platform. 260 // Maximum value of word16 vector. Version for MIPS platform.
262 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length) { 261 int16_t WebRtcSpl_MaxValueW16_mips(const int16_t* vector, size_t length) {
263 int16_t maximum = WEBRTC_SPL_WORD16_MIN; 262 int16_t maximum = WEBRTC_SPL_WORD16_MIN;
264 int tmp1; 263 int tmp1;
265 int16_t value; 264 int16_t value;
266 265
267 assert(length > 0); 266 RTC_DCHECK_GT(length, 0);
268 267
269 __asm__ volatile ( 268 __asm__ volatile (
270 ".set push \n\t" 269 ".set push \n\t"
271 ".set noreorder \n\t" 270 ".set noreorder \n\t"
272 271
273 "1: \n\t" 272 "1: \n\t"
274 "lh %[value], 0(%[vector]) \n\t" 273 "lh %[value], 0(%[vector]) \n\t"
275 "addiu %[length], %[length], -1 \n\t" 274 "addiu %[length], %[length], -1 \n\t"
276 "slt %[tmp1], %[maximum], %[value] \n\t" 275 "slt %[tmp1], %[maximum], %[value] \n\t"
277 "movn %[maximum], %[value], %[tmp1] \n\t" 276 "movn %[maximum], %[value], %[tmp1] \n\t"
278 "bgtz %[length], 1b \n\t" 277 "bgtz %[length], 1b \n\t"
279 " addiu %[vector], %[vector], 2 \n\t" 278 " addiu %[vector], %[vector], 2 \n\t"
280 ".set pop \n\t" 279 ".set pop \n\t"
281 280
282 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) 281 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value)
283 : [vector] "r" (vector), [length] "r" (length) 282 : [vector] "r" (vector), [length] "r" (length)
284 : "memory" 283 : "memory"
285 ); 284 );
286 285
287 return maximum; 286 return maximum;
288 } 287 }
289 288
290 // Maximum value of word32 vector. Version for MIPS platform. 289 // Maximum value of word32 vector. Version for MIPS platform.
291 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length) { 290 int32_t WebRtcSpl_MaxValueW32_mips(const int32_t* vector, size_t length) {
292 int32_t maximum = WEBRTC_SPL_WORD32_MIN; 291 int32_t maximum = WEBRTC_SPL_WORD32_MIN;
293 int tmp1, value; 292 int tmp1, value;
294 293
295 assert(length > 0); 294 RTC_DCHECK_GT(length, 0);
296 295
297 __asm__ volatile ( 296 __asm__ volatile (
298 ".set push \n\t" 297 ".set push \n\t"
299 ".set noreorder \n\t" 298 ".set noreorder \n\t"
300 299
301 "1: \n\t" 300 "1: \n\t"
302 "lw %[value], 0(%[vector]) \n\t" 301 "lw %[value], 0(%[vector]) \n\t"
303 "addiu %[length], %[length], -1 \n\t" 302 "addiu %[length], %[length], -1 \n\t"
304 "slt %[tmp1], %[maximum], %[value] \n\t" 303 "slt %[tmp1], %[maximum], %[value] \n\t"
305 "movn %[maximum], %[value], %[tmp1] \n\t" 304 "movn %[maximum], %[value], %[tmp1] \n\t"
306 "bgtz %[length], 1b \n\t" 305 "bgtz %[length], 1b \n\t"
307 " addiu %[vector], %[vector], 4 \n\t" 306 " addiu %[vector], %[vector], 4 \n\t"
308 307
309 ".set pop \n\t" 308 ".set pop \n\t"
310 309
311 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value) 310 : [tmp1] "=&r" (tmp1), [maximum] "+r" (maximum), [value] "=&r" (value)
312 : [vector] "r" (vector), [length] "r" (length) 311 : [vector] "r" (vector), [length] "r" (length)
313 : "memory" 312 : "memory"
314 ); 313 );
315 314
316 return maximum; 315 return maximum;
317 } 316 }
318 317
319 // Minimum value of word16 vector. Version for MIPS platform. 318 // Minimum value of word16 vector. Version for MIPS platform.
320 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length) { 319 int16_t WebRtcSpl_MinValueW16_mips(const int16_t* vector, size_t length) {
321 int16_t minimum = WEBRTC_SPL_WORD16_MAX; 320 int16_t minimum = WEBRTC_SPL_WORD16_MAX;
322 int tmp1; 321 int tmp1;
323 int16_t value; 322 int16_t value;
324 323
325 assert(length > 0); 324 RTC_DCHECK_GT(length, 0);
326 325
327 __asm__ volatile ( 326 __asm__ volatile (
328 ".set push \n\t" 327 ".set push \n\t"
329 ".set noreorder \n\t" 328 ".set noreorder \n\t"
330 329
331 "1: \n\t" 330 "1: \n\t"
332 "lh %[value], 0(%[vector]) \n\t" 331 "lh %[value], 0(%[vector]) \n\t"
333 "addiu %[length], %[length], -1 \n\t" 332 "addiu %[length], %[length], -1 \n\t"
334 "slt %[tmp1], %[value], %[minimum] \n\t" 333 "slt %[tmp1], %[value], %[minimum] \n\t"
335 "movn %[minimum], %[value], %[tmp1] \n\t" 334 "movn %[minimum], %[value], %[tmp1] \n\t"
336 "bgtz %[length], 1b \n\t" 335 "bgtz %[length], 1b \n\t"
337 " addiu %[vector], %[vector], 2 \n\t" 336 " addiu %[vector], %[vector], 2 \n\t"
338 337
339 ".set pop \n\t" 338 ".set pop \n\t"
340 339
341 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) 340 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value)
342 : [vector] "r" (vector), [length] "r" (length) 341 : [vector] "r" (vector), [length] "r" (length)
343 : "memory" 342 : "memory"
344 ); 343 );
345 344
346 return minimum; 345 return minimum;
347 } 346 }
348 347
349 // Minimum value of word32 vector. Version for MIPS platform. 348 // Minimum value of word32 vector. Version for MIPS platform.
350 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length) { 349 int32_t WebRtcSpl_MinValueW32_mips(const int32_t* vector, size_t length) {
351 int32_t minimum = WEBRTC_SPL_WORD32_MAX; 350 int32_t minimum = WEBRTC_SPL_WORD32_MAX;
352 int tmp1, value; 351 int tmp1, value;
353 352
354 assert(length > 0); 353 RTC_DCHECK_GT(length, 0);
355 354
356 __asm__ volatile ( 355 __asm__ volatile (
357 ".set push \n\t" 356 ".set push \n\t"
358 ".set noreorder \n\t" 357 ".set noreorder \n\t"
359 358
360 "1: \n\t" 359 "1: \n\t"
361 "lw %[value], 0(%[vector]) \n\t" 360 "lw %[value], 0(%[vector]) \n\t"
362 "addiu %[length], %[length], -1 \n\t" 361 "addiu %[length], %[length], -1 \n\t"
363 "slt %[tmp1], %[value], %[minimum] \n\t" 362 "slt %[tmp1], %[value], %[minimum] \n\t"
364 "movn %[minimum], %[value], %[tmp1] \n\t" 363 "movn %[minimum], %[value], %[tmp1] \n\t"
365 "bgtz %[length], 1b \n\t" 364 "bgtz %[length], 1b \n\t"
366 " addiu %[vector], %[vector], 4 \n\t" 365 " addiu %[vector], %[vector], 4 \n\t"
367 366
368 ".set pop \n\t" 367 ".set pop \n\t"
369 368
370 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value) 369 : [tmp1] "=&r" (tmp1), [minimum] "+r" (minimum), [value] "=&r" (value)
371 : [vector] "r" (vector), [length] "r" (length) 370 : [vector] "r" (vector), [length] "r" (length)
372 : "memory" 371 : "memory"
373 ); 372 );
374 373
375 return minimum; 374 return minimum;
376 } 375 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698