Skip to content

Commit 1f0c76c

Browse files
authored
fix some prefast warnings (#467)
1 parent 1cbebb0 commit 1f0c76c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

cmake/ext_ortlib.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ else()
99
message(STATUS "CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}")
1010

1111
# default to 1.11.1 if not specified
12-
set(ONNXRUNTIME_VER "1.11.1" CACHE STRING "ONNX Runtime version")
12+
set(ONNXRUNTIME_VER "1.12.1" CACHE STRING "ONNX Runtime version")
1313

1414
if(APPLE)
1515
set(ONNXRUNTIME_URL "v${ONNXRUNTIME_VER}/onnxruntime-osx-universal2-${ONNXRUNTIME_VER}.tgz")

operators/audio/audio_decoder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ struct KernelAudioDecoder : public BaseKernel {
170170
if (downsample_rate_ != 0 &&
171171
downsample_rate_ != orig_sample_rate) {
172172
// A lowpass filter on buf audio data to remove high frequency noise
173-
ButterworthLowpass filter(1.0f * orig_sample_rate, 0.5f * downsample_rate_);
173+
ButterworthLowpass filter(1.0 * orig_sample_rate, 0.5 * downsample_rate_);
174174
std::vector<float> filtered_buf = filter.Process(buf);
175175
// downsample the audio data
176176
KaiserWindowInterpolation::Process(filtered_buf, buf,

operators/audio/sampling.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ class ButterworthLowpass {
7878

7979
b[POLE_DATA_SIZE - 1] = 0.0;
8080

81-
for (auto i = 0; i <= num_pole; ++i) {
81+
for (size_t i = 0; i <= num_pole; ++i) {
8282
a[i] = a[i + 2];
8383
b[i] = -b[i + 2];
8484
}
8585

86-
for (auto i = 0; i <= num_pole; ++i) {
86+
for (size_t i = 0; i <= num_pole; ++i) {
8787
sa += a[i];
8888
sb += b[i];
8989
}
@@ -166,7 +166,7 @@ class KaiserWindowInterpolation {
166166
int outputSize = static_cast<int>(std::ceil(static_cast<float>(input.size()) * factor));
167167
output.resize(outputSize);
168168

169-
for (int i = 0; i < outputSize; i++) {
169+
for (size_t i = 0; i < outputSize; i++) {
170170
float index = i / factor; // Fractional index for interpolation
171171

172172
// Calculate the integer and fractional parts of the index
@@ -175,20 +175,20 @@ class KaiserWindowInterpolation {
175175

176176
// Calculate the range of input samples for interpolation
177177
int range = static_cast<int>(std::ceil(kBeta / (2.0 * factor)));
178-
int startSample = std::max(0, integerPart - range);
179-
int endSample = std::min(static_cast<int>(input.size()) - 1, integerPart + range);
178+
size_t startSample = std::max(0, integerPart - range);
179+
size_t endSample = std::min(static_cast<int>(input.size()) - 1, integerPart + range);
180180

181181
// Calculate the Kaiser window weights for the input samples
182182
std::vector<double> weights = KaiserWin(static_cast<size_t>(endSample - startSample + 1));
183-
for (int j = startSample; j <= endSample; j++) {
184-
double distance = std::abs(j - index);
183+
for (size_t j = startSample; j <= endSample; j++) {
184+
double distance = std::abs(static_cast<double>(j) - index);
185185
double sincValue = (distance < 1e-6f) ? 1.0f : std::sin(M_PI * distance) / (M_PI * distance);
186186
weights[j - startSample] *= sincValue;
187187
}
188188

189189
// Perform the interpolation
190190
double interpolatedValue = 0.0f;
191-
for (int j = startSample; j <= endSample; j++) {
191+
for (size_t j = startSample; j <= endSample; j++) {
192192
interpolatedValue += input[j] * weights[j - startSample];
193193
}
194194

0 commit comments

Comments
 (0)