aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniil Cherednik <dan.cherednik@gmail.com>2022-02-22 00:47:51 +0300
committerDaniil Cherednik <dan.cherednik@gmail.com>2022-02-22 01:28:18 +0300
commit718aea2242da052183f08e9ad58c2a9a1843d8a6 (patch)
tree595c18cd5de19ceaa30655c8c3dd55a908af3696 /src
parentb232396d25bd2eaef3fcaa536dd506a3b5da2c99 (diff)
downloadatracdenc-718aea2242da052183f08e9ad58c2a9a1843d8a6.tar.gz
Fix CodeQL (Multiplication result converted to larger type) warning
Diffstat (limited to 'src')
-rw-r--r--src/transient_detector.cpp6
-rw-r--r--src/transient_detector.h14
2 files changed, 10 insertions, 10 deletions
diff --git a/src/transient_detector.cpp b/src/transient_detector.cpp
index 692c3a7..8e4c072 100644
--- a/src/transient_detector.cpp
+++ b/src/transient_detector.cpp
@@ -67,14 +67,14 @@ void TTransientDetector::HPFilter(const TFloat* in, TFloat* out) {
bool TTransientDetector::Detect(const TFloat* buf) {
- const uint32_t nBlocksToAnalize = NShortBlocks + 1;
+ const uint16_t nBlocksToAnalize = NShortBlocks + 1;
TFloat* rmsPerShortBlock = reinterpret_cast<TFloat*>(alloca(sizeof(TFloat) * nBlocksToAnalize));
std::vector<TFloat> filtered(BlockSz);
HPFilter(buf, filtered.data());
bool trans = false;
rmsPerShortBlock[0] = LastEnergy;
- for (uint32_t i = 1; i < nBlocksToAnalize; ++i) {
- rmsPerShortBlock[i] = 19.0 * log10(calculateRMS(&filtered[(i - 1) * ShortSz], ShortSz));
+ for (uint16_t i = 1; i < nBlocksToAnalize; ++i) {
+ rmsPerShortBlock[i] = 19.0 * log10(calculateRMS(&filtered[(size_t)(i - 1) * ShortSz], ShortSz));
if (rmsPerShortBlock[i] - rmsPerShortBlock[i - 1] > 16) {
trans = true;
LastTransientPos = i;
diff --git a/src/transient_detector.h b/src/transient_detector.h
index 0bd0ca0..0f94cc6 100644
--- a/src/transient_detector.h
+++ b/src/transient_detector.h
@@ -26,17 +26,17 @@
namespace NAtracDEnc {
class TTransientDetector {
- const uint32_t ShortSz;
- const uint32_t BlockSz;
- const uint32_t NShortBlocks;
- static const uint32_t PrevBufSz = 20;
- static const uint32_t FIRLen = 21;
+ const uint16_t ShortSz;
+ const uint16_t BlockSz;
+ const uint16_t NShortBlocks;
+ static const uint16_t PrevBufSz = 20;
+ static const uint16_t FIRLen = 21;
void HPFilter(const TFloat* in, TFloat* out);
std::vector<TFloat> HPFBuffer;
TFloat LastEnergy = 0.0;
- uint32_t LastTransientPos = 0;
+ uint16_t LastTransientPos = 0;
public:
- TTransientDetector(uint32_t shortSz, uint32_t blockSz)
+ TTransientDetector(uint16_t shortSz, uint16_t blockSz)
: ShortSz(shortSz)
, BlockSz(blockSz)
, NShortBlocks(blockSz/shortSz)