1
0

template.c: extract BITS_PER_BYTE

This commit is contained in:
Intel A80486DX2-66 2024-07-13 22:35:33 +03:00
parent 32665b0168
commit 391467806e
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -35,9 +35,9 @@ typedef long double bb_fp_return_t;
#define CHANNELS `channels` #define CHANNELS `channels`
#define RUNNING_LENGTH `running_length` #define RUNNING_LENGTH `running_length`
#if BIT_DEPTH <= 8 #define BITS_PER_BYTE 8
# define ACTUAL_BIT_DEPTH 8 #if BIT_DEPTH <= BITS_PER_BYTE
# define ACTUAL_BIT_DEPTH BITS_PER_BYTE
# define SAMPLE_TYPE uint8_t # define SAMPLE_TYPE uint8_t
#elif BIT_DEPTH <= 16 #elif BIT_DEPTH <= 16
# define ACTUAL_BIT_DEPTH 16 # define ACTUAL_BIT_DEPTH 16
@ -244,10 +244,10 @@ main(void)
* in the file format structure * in the file format structure
*/, */,
sample_rate = SAMPLE_RATE, 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 uint16_t fmt_type = 1, // format type is PCM
channels = CHANNELS, channels = CHANNELS,
block_align = (ACTUAL_BIT_DEPTH * CHANNELS) / 8, block_align = (ACTUAL_BIT_DEPTH * CHANNELS) / BITS_PER_BYTE,
bit_depth = ACTUAL_BIT_DEPTH; bit_depth = ACTUAL_BIT_DEPTH;
// 3. write headers // 3. write headers
@ -341,8 +341,8 @@ main(void)
((uintmax_t) bytebeat_res & BIT_DEPTH_LIMITER); ((uintmax_t) bytebeat_res & BIT_DEPTH_LIMITER);
#endif #endif
// 4. if bit depth is less than 8, stretch it // 4. if bit depth is less than BITS_PER_BYTE, stretch it
#if BIT_DEPTH < 8 #if BIT_DEPTH < BITS_PER_BYTE
sample_res = (SAMPLE_TYPE) sample_res = (SAMPLE_TYPE)
((long double) sample_res * bit_depth_stretch); ((long double) sample_res * bit_depth_stretch);
#endif #endif