2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-03-01 20:03:26 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This file contains the implementation of functions
|
2012-09-08 00:09:26 +00:00
|
|
|
* WebRtcSpl_MaxAbsValueW16C()
|
|
|
|
|
* WebRtcSpl_MaxAbsValueW32C()
|
|
|
|
|
* WebRtcSpl_MaxValueW16C()
|
|
|
|
|
* WebRtcSpl_MaxValueW32C()
|
|
|
|
|
* WebRtcSpl_MinValueW16C()
|
|
|
|
|
* WebRtcSpl_MinValueW32C()
|
2012-04-11 17:40:40 +00:00
|
|
|
* WebRtcSpl_MaxAbsIndexW16()
|
|
|
|
|
* WebRtcSpl_MaxIndexW16()
|
|
|
|
|
* WebRtcSpl_MaxIndexW32()
|
|
|
|
|
* WebRtcSpl_MinIndexW16()
|
2011-07-07 08:21:25 +00:00
|
|
|
* WebRtcSpl_MinIndexW32()
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2023-08-29 14:21:54 +02:00
|
|
|
#include <limits.h>
|
2025-01-09 02:11:09 -08:00
|
|
|
#include <stdlib.h>
|
2012-03-01 20:03:26 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "common_audio/signal_processing/include/signal_processing_library.h"
|
2025-01-09 02:11:09 -08:00
|
|
|
#include "rtc_base/checks.h"
|
2015-08-28 17:31:03 -07:00
|
|
|
|
2012-04-11 17:40:40 +00:00
|
|
|
// TODO(bjorn/kma): Consolidate function pairs (e.g. combine
|
2012-09-08 00:09:26 +00:00
|
|
|
// WebRtcSpl_MaxAbsValueW16C and WebRtcSpl_MaxAbsIndexW16 into a single one.)
|
|
|
|
|
// TODO(kma): Move the next six functions into min_max_operations_c.c.
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Maximum absolute value of word16 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int16_t WebRtcSpl_MaxAbsValueW16C(const int16_t* vector, size_t length) {
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
int absolute = 0, maximum = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-03-01 20:03:26 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
absolute = abs((int)vector[i]);
|
|
|
|
|
|
|
|
|
|
if (absolute > maximum) {
|
|
|
|
|
maximum = absolute;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-03-01 20:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Guard the case for abs(-32768).
|
|
|
|
|
if (maximum > WEBRTC_SPL_WORD16_MAX) {
|
|
|
|
|
maximum = WEBRTC_SPL_WORD16_MAX;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (int16_t)maximum;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Maximum absolute value of word32 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int32_t WebRtcSpl_MaxAbsValueW32C(const int32_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
// Use uint32_t for the local variables, to accommodate the return value
|
|
|
|
|
// of abs(0x80000000), which is 0x80000000.
|
2012-04-02 03:55:20 +00:00
|
|
|
|
2012-04-11 17:40:40 +00:00
|
|
|
uint32_t absolute = 0, maximum = 0;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0;
|
2012-04-02 03:55:20 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
2023-08-29 14:21:54 +02:00
|
|
|
absolute =
|
|
|
|
|
(vector[i] != INT_MIN) ? abs((int)vector[i]) : INT_MAX + (uint32_t)1;
|
2012-04-11 17:40:40 +00:00
|
|
|
if (absolute > maximum) {
|
|
|
|
|
maximum = absolute;
|
2012-04-02 07:12:08 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
maximum = WEBRTC_SPL_MIN(maximum, WEBRTC_SPL_WORD32_MAX);
|
|
|
|
|
|
|
|
|
|
return (int32_t)maximum;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Maximum value of word16 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int16_t WebRtcSpl_MaxValueW16C(const int16_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
int16_t maximum = WEBRTC_SPL_WORD16_MIN;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] > maximum)
|
|
|
|
|
maximum = vector[i];
|
|
|
|
|
}
|
|
|
|
|
return maximum;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Maximum value of word32 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int32_t WebRtcSpl_MaxValueW32C(const int32_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
int32_t maximum = WEBRTC_SPL_WORD32_MIN;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] > maximum)
|
|
|
|
|
maximum = vector[i];
|
|
|
|
|
}
|
|
|
|
|
return maximum;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Minimum value of word16 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int16_t WebRtcSpl_MinValueW16C(const int16_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
int16_t minimum = WEBRTC_SPL_WORD16_MAX;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] < minimum)
|
|
|
|
|
minimum = vector[i];
|
|
|
|
|
}
|
|
|
|
|
return minimum;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 00:09:26 +00:00
|
|
|
// Minimum value of word32 vector. C version for generic platforms.
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
int32_t WebRtcSpl_MinValueW32C(const int32_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
int32_t minimum = WEBRTC_SPL_WORD32_MAX;
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] < minimum)
|
|
|
|
|
minimum = vector[i];
|
|
|
|
|
}
|
|
|
|
|
return minimum;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
// Index of maximum absolute value in a word16 vector.
|
2015-08-28 17:31:03 -07:00
|
|
|
size_t WebRtcSpl_MaxAbsIndexW16(const int16_t* vector, size_t length) {
|
2012-04-11 17:40:40 +00:00
|
|
|
// Use type int for local variables, to accomodate the value of abs(-32768).
|
|
|
|
|
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0, index = 0;
|
|
|
|
|
int absolute = 0, maximum = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
absolute = abs((int)vector[i]);
|
|
|
|
|
|
|
|
|
|
if (absolute > maximum) {
|
|
|
|
|
maximum = absolute;
|
|
|
|
|
index = i;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 17:31:03 -07:00
|
|
|
return index;
|
2012-04-02 07:12:08 +00:00
|
|
|
}
|
2012-04-02 03:55:20 +00:00
|
|
|
|
2021-01-20 16:26:43 +01:00
|
|
|
int16_t WebRtcSpl_MaxAbsElementW16(const int16_t* vector, size_t length) {
|
|
|
|
|
int16_t min_val, max_val;
|
|
|
|
|
WebRtcSpl_MinMaxW16(vector, length, &min_val, &max_val);
|
|
|
|
|
if (min_val == max_val || min_val < -max_val) {
|
|
|
|
|
return min_val;
|
|
|
|
|
}
|
|
|
|
|
return max_val;
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-11 17:40:40 +00:00
|
|
|
// Index of maximum value in a word16 vector.
|
2015-08-28 17:31:03 -07:00
|
|
|
size_t WebRtcSpl_MaxIndexW16(const int16_t* vector, size_t length) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0, index = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
int16_t maximum = WEBRTC_SPL_WORD16_MIN;
|
|
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] > maximum) {
|
|
|
|
|
maximum = vector[i];
|
|
|
|
|
index = i;
|
2012-04-02 07:12:08 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 17:31:03 -07:00
|
|
|
return index;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-11 17:40:40 +00:00
|
|
|
// Index of maximum value in a word32 vector.
|
2015-08-28 17:31:03 -07:00
|
|
|
size_t WebRtcSpl_MaxIndexW32(const int32_t* vector, size_t length) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0, index = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
int32_t maximum = WEBRTC_SPL_WORD32_MIN;
|
|
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] > maximum) {
|
|
|
|
|
maximum = vector[i];
|
|
|
|
|
index = i;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 17:31:03 -07:00
|
|
|
return index;
|
2012-04-02 07:12:08 +00:00
|
|
|
}
|
2012-04-02 03:55:20 +00:00
|
|
|
|
2012-04-11 17:40:40 +00:00
|
|
|
// Index of minimum value in a word16 vector.
|
2015-08-28 17:31:03 -07:00
|
|
|
size_t WebRtcSpl_MinIndexW16(const int16_t* vector, size_t length) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0, index = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
int16_t minimum = WEBRTC_SPL_WORD16_MAX;
|
|
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] < minimum) {
|
|
|
|
|
minimum = vector[i];
|
|
|
|
|
index = i;
|
2012-04-02 07:12:08 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 17:31:03 -07:00
|
|
|
return index;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Index of minimum value in a word32 vector.
|
2015-08-28 17:31:03 -07:00
|
|
|
size_t WebRtcSpl_MinIndexW32(const int32_t* vector, size_t length) {
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t i = 0, index = 0;
|
2012-04-11 17:40:40 +00:00
|
|
|
int32_t minimum = WEBRTC_SPL_WORD32_MAX;
|
|
|
|
|
|
2016-08-26 04:33:34 -07:00
|
|
|
RTC_DCHECK_GT(length, 0);
|
2012-04-11 17:40:40 +00:00
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] < minimum) {
|
|
|
|
|
minimum = vector[i];
|
|
|
|
|
index = i;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2012-04-11 17:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-28 17:31:03 -07:00
|
|
|
return index;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2021-01-20 16:26:43 +01:00
|
|
|
|
|
|
|
|
// Finds both the minimum and maximum elements in an array of 16-bit integers.
|
2025-01-09 02:11:09 -08:00
|
|
|
void WebRtcSpl_MinMaxW16(const int16_t* vector,
|
|
|
|
|
size_t length,
|
|
|
|
|
int16_t* min_val,
|
|
|
|
|
int16_t* max_val) {
|
2021-01-20 16:26:43 +01:00
|
|
|
#if defined(WEBRTC_HAS_NEON)
|
|
|
|
|
return WebRtcSpl_MinMaxW16Neon(vector, length, min_val, max_val);
|
|
|
|
|
#else
|
|
|
|
|
int16_t minimum = WEBRTC_SPL_WORD16_MAX;
|
|
|
|
|
int16_t maximum = WEBRTC_SPL_WORD16_MIN;
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
|
|
|
|
|
RTC_DCHECK_GT(length, 0);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
|
if (vector[i] < minimum)
|
|
|
|
|
minimum = vector[i];
|
|
|
|
|
if (vector[i] > maximum)
|
|
|
|
|
maximum = vector[i];
|
|
|
|
|
}
|
|
|
|
|
*min_val = minimum;
|
|
|
|
|
*max_val = maximum;
|
|
|
|
|
#endif
|
|
|
|
|
}
|