diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-12-22 17:45:26 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-12-22 17:45:26 +0100 |
commit | 7caf4423145b5b2629502f8d227dc348bd232887 (patch) | |
tree | d65211c57149b4dfea0366b69dfc69ee6b7df41e | |
parent | ab2442bd9f1139b2abe8e26a593785703b78d58c (diff) | |
download | fdk-aac-7caf4423145b5b2629502f8d227dc348bd232887.tar.gz fdk-aac-7caf4423145b5b2629502f8d227dc348bd232887.tar.bz2 fdk-aac-7caf4423145b5b2629502f8d227dc348bd232887.zip |
Fix level indication in mono
-rw-r--r-- | src/dabplus-enc.cpp | 33 | ||||
-rw-r--r-- | src/utils.c | 7 | ||||
-rw-r--r-- | src/utils.h | 2 |
3 files changed, 25 insertions, 17 deletions
diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index b474914..0862690 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -832,24 +832,35 @@ int main(int argc, char *argv[]) } } - if (out_args.numOutBytes + row*10 == outbuf_size) { - if (show_level) { + if (show_level) { + if (channels == 1) { + fprintf(stderr, "\rIn: [%-6s] %1s %1s %1s", + level(1, MAX(peak_right, peak_left)), + status & STATUS_PAD_INSERTED ? "P" : " ", + status & STATUS_UNDERRUN ? "U" : " ", + status & STATUS_OVERRUN ? "O" : " "); + } + else if (channels == 2) { fprintf(stderr, "\rIn: [%6s|%-6s] %1s %1s %1s", - level(0, &peak_left), - level(1, &peak_right), + level(0, peak_left), + level(1, peak_right), status & STATUS_PAD_INSERTED ? "P" : " ", status & STATUS_UNDERRUN ? "U" : " ", status & STATUS_OVERRUN ? "O" : " "); } - else { - if (status & STATUS_OVERRUN) { - fprintf(stderr, "O"); - } - if (status & STATUS_UNDERRUN) { - fprintf(stderr, "U"); - } + peak_right = 0; + peak_left = 0; + } + else { + if (status & STATUS_OVERRUN) { + fprintf(stderr, "O"); } + + if (status & STATUS_UNDERRUN) { + fprintf(stderr, "U"); + } + } status = 0; diff --git a/src/utils.c b/src/utils.c index a9aefbe..0168a23 100644 --- a/src/utils.c +++ b/src/utils.c @@ -4,7 +4,7 @@ #include <math.h> /* Taken from sox */ -const char* level(int channel, int* peak) +const char* level(int channel, int peak) { static char const * const text[][2] = { /* White: 2dB steps */ @@ -17,7 +17,7 @@ const char* level(int channel, int* peak) }; int const red = 1, white = NUMOF(text) - red; - double linear = (double)(*peak) / INT16_MAX; + double linear = ((double)peak) / INT16_MAX; int vu_dB = linear ? floor(2 * white + red + linear_to_dB(linear)) : 0; @@ -25,9 +25,6 @@ const char* level(int channel, int* peak) MAX(vu_dB / 2, 0) : MIN(vu_dB - white, red + white - 1); - *peak = 0; - return text[index][channel]; - } diff --git a/src/utils.h b/src/utils.h index 7cd9a96..c75935f 100644 --- a/src/utils.h +++ b/src/utils.h @@ -14,7 +14,7 @@ /* Calculate the little string containing a bargraph * 'VU-meter' from the peak value measured */ -const char* level(int channel, int* peak); +const char* level(int channel, int peak); /* This defines the on-wire representation of a ZMQ message header. * |