From 7f2e6b1aac6740168c7fac5b1054ed234e420159 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Wed, 29 May 2019 16:18:51 +0100 Subject: [PATCH] Add support for S32_LE, S32_BE, S24_LE and S24_BE wqhen generating frames of dithered silence --- common.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/common.c b/common.c index b097ddab..0f72f6f9 100644 --- a/common.c +++ b/common.c @@ -1442,6 +1442,30 @@ int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_forma *(int32_t *)op = hyper_sample; result = 4; break; + case SPS_FORMAT_S32_LE: + hyper_sample >>= (64 - 32); + byt = (uint8_t)hyper_sample; + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 8); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 16); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 24); + *op++ = byt; + result = 4; + break; + case SPS_FORMAT_S32_BE: + hyper_sample >>= (64 - 32); + byt = (uint8_t)(hyper_sample >> 24); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 16); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 8); + *op++ = byt; + byt = (uint8_t)hyper_sample; + *op++ = byt; + result = 4; + break; case SPS_FORMAT_S24_3LE: hyper_sample >>= (64 - 24); byt = (uint8_t)hyper_sample; @@ -1467,6 +1491,28 @@ int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_forma *(int32_t *)op = hyper_sample; result = 4; break; + case SPS_FORMAT_S24_LE: + hyper_sample >>= (64 - 24); + byt = (uint8_t)hyper_sample; + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 8); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 16); + *op++ = byt; + *op++ = 0; + result = 4; + break; + case SPS_FORMAT_S24_BE: + hyper_sample >>= (64 - 24); + *op++ = 0; + byt = (uint8_t)(hyper_sample >> 16); + *op++ = byt; + byt = (uint8_t)(hyper_sample >> 8); + *op++ = byt; + byt = (uint8_t)hyper_sample; + *op++ = byt; + result = 4; + break; case SPS_FORMAT_S16_LE: hyper_sample >>= (64 - 16); byt = (uint8_t)hyper_sample; @@ -1501,7 +1547,7 @@ int64_t generate_zero_frames(char *outp, size_t number_of_frames, enum sps_forma break; default: result = 0; // stop a compiler warning - die("Unexpected SPS_FORMAT_UNKNOWN while outputting samples"); + die("Unexpected SPS_FORMAT_* with index %d while outputting silence",format); } p += result; previous_random_number = r;