From 7702643e1bcc60a0efee1b351c9206ea45139cc5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 13 Mar 2023 12:02:30 +0100 Subject: [PATCH] pcm/Normalizer: remove Compressor_setHistory(), no resize possible This feature was never used. --- src/pcm/Normalizer.cxx | 35 +++++++---------------------------- src/pcm/Normalizer.hxx | 4 ---- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/pcm/Normalizer.cxx b/src/pcm/Normalizer.cxx index d9d9cccbb..542c85acb 100644 --- a/src/pcm/Normalizer.cxx +++ b/src/pcm/Normalizer.cxx @@ -4,10 +4,8 @@ #include "Normalizer.hxx" -#include #include #include -#include /*** Default configuration stuff ***/ #define TARGET 16384 /*!< Target level (on a scale of 0-32767) */ @@ -49,7 +47,13 @@ Compressor_new(unsigned int history) noexcept obj->bufsz = 0; obj->pos = 0; - Compressor_setHistory(obj, history); + if (!history) + history = BUCKETS; + + obj->bufsz = history; + obj->peaks = (int *)calloc(history, sizeof(*obj->peaks)); + obj->gain = (int *)calloc(history, sizeof(*obj->gain)); + obj->clipped = (int *)calloc(history, sizeof(*obj->clipped)); return obj; } @@ -66,31 +70,6 @@ Compressor_delete(struct Compressor *obj) noexcept free(obj); } -static int * -resizeArray(int *data, int newsz, int oldsz) noexcept -{ - data = (int *)realloc(data, newsz*sizeof(int)); - if (data == nullptr) - /* out of memory, not much we can do */ - abort(); - - if (newsz > oldsz) - memset(data + oldsz, 0, sizeof(int)*(newsz - oldsz)); - return data; -} - -void -Compressor_setHistory(struct Compressor *obj, unsigned int history) noexcept -{ - if (!history) - history = BUCKETS; - - obj->peaks = resizeArray(obj->peaks, history, obj->bufsz); - obj->gain = resizeArray(obj->gain, history, obj->bufsz); - obj->clipped = resizeArray(obj->clipped, history, obj->bufsz); - obj->bufsz = history; -} - struct CompressorConfig * Compressor_getConfig(struct Compressor *obj) noexcept { diff --git a/src/pcm/Normalizer.hxx b/src/pcm/Normalizer.hxx index 0a4f1aeb1..e5450665e 100644 --- a/src/pcm/Normalizer.hxx +++ b/src/pcm/Normalizer.hxx @@ -23,10 +23,6 @@ Compressor_new(unsigned int history) noexcept; void Compressor_delete(struct Compressor *) noexcept; -//! Set the history length -void -Compressor_setHistory(struct Compressor *, unsigned int history) noexcept; - //! Get the configuration for a compressor struct CompressorConfig * Compressor_getConfig(struct Compressor *) noexcept;