From eaf7b06b1e64baed20ab6da7170e7f7b7fa90f77 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sat, 13 Jul 2024 22:35:33 +0300 Subject: [PATCH] template.c: extract `BITS_PER_BYTE` --- src/template.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/template.c b/src/template.c index ba1d3f2..b97d6c1 100644 --- a/src/template.c +++ b/src/template.c @@ -36,9 +36,9 @@ typedef long double bb_fp_return_t; #define CHANNELS `channels` #define RUNNING_LENGTH `running_length` -#if BIT_DEPTH <= 8 -# define ACTUAL_BIT_DEPTH 8 - +#define BITS_PER_BYTE 8 +#if BIT_DEPTH <= BITS_PER_BYTE +# define ACTUAL_BIT_DEPTH BITS_PER_BYTE # define SAMPLE_TYPE uint8_t #elif BIT_DEPTH <= 16 # define ACTUAL_BIT_DEPTH 16 @@ -258,10 +258,10 @@ main(void) * in the file format structure */, sample_rate = SAMPLE_RATE, - byte_rate = (SAMPLE_RATE * ACTUAL_BIT_DEPTH * CHANNELS) / 8; + byte_rate = (SAMPLE_RATE * ACTUAL_BIT_DEPTH * CHANNELS) / BITS_PER_BYTE; uint16_t fmt_type = 1, // format type is PCM channels = CHANNELS, - block_align = (ACTUAL_BIT_DEPTH * CHANNELS) / 8, + block_align = (ACTUAL_BIT_DEPTH * CHANNELS) / BITS_PER_BYTE, bit_depth = ACTUAL_BIT_DEPTH; #if !STDOUT_OUTPUT @@ -357,8 +357,8 @@ main(void) ((uintmax_t) bytebeat_res & BIT_DEPTH_LIMITER); #endif - // 4. if bit depth is less than 8, stretch it -#if BIT_DEPTH < 8 + // 4. if bit depth is less than BITS_PER_BYTE, stretch it +#if BIT_DEPTH < BITS_PER_BYTE sample_res = (SAMPLE_TYPE) ((long double) sample_res * bit_depth_stretch); #endif