summaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-03-31 17:07:38 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-03-31 17:07:38 +0200
commitec75b9e317baf249d67295300bc5308b7c33f4ac (patch)
tree6f43693530b463fc913f7c7153a3f54a43ebd04b /src/utils.c
parenta1eb6cf861d3c1cbd4e6c016be3cbd2a1e3d797d (diff)
downloadODR-AudioEnc-ec75b9e317baf249d67295300bc5308b7c33f4ac.tar.gz
ODR-AudioEnc-ec75b9e317baf249d67295300bc5308b7c33f4ac.tar.bz2
ODR-AudioEnc-ec75b9e317baf249d67295300bc5308b7c33f4ac.zip
Fix GStreamer input, rework ICY-Text write
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/src/utils.c b/src/utils.c
deleted file mode 100644
index 928304e..0000000
--- a/src/utils.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "utils.h"
-#include <unistd.h>
-#include <stdint.h>
-#include <math.h>
-
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#define MAX(a,b) (((a)>(b))?(a):(b))
-
-/* Taken from sox */
-const char* level(int channel, int peak)
-{
- static char const * const text[][2] = {
- /* White: 2dB steps */
- {"", ""}, {"-", "-"}, {"=", "="}, {"-=", "=-"},
- {"==", "=="}, {"-==", "==-"}, {"===", "==="}, {"-===", "===-"},
- {"====", "===="}, {"-====", "====-"}, {"=====", "====="},
- {"-=====", "=====-"}, {"======", "======"},
- /* Red: 1dB steps */
- {"!=====", "=====!"},
- };
- int const red = 1, white = NUMOF(text) - red;
-
- double linear = ((double)peak) / INT16_MAX;
-
- int vu_dB = linear ? floor(2 * white + red + linear_to_dB(linear)) : 0;
-
- int index = vu_dB < 2 * white ?
- MAX(vu_dB / 2, 0) :
- MIN(vu_dB - white, red + white - 1);
-
- return text[index][channel];
-}
-
-size_t strlen_utf8(const char *s) {
- size_t result = 0;
-
- // ignore continuation bytes - only count single/leading bytes
- while (*s)
- if ((*s++ & 0xC0) != 0x80)
- result++;
-
- return result;
-}