feature: Add High-Resolution LC3 plus mode

Duplicate interfaces for HR mode

spec: Remove intermediate quantized table

fix: legacy lc3_frame_bytes() and lc3_resolve_bitrate()

Cosmetic: rename fast_xxx math function to lc3_xxx
This commit is contained in:
Antoine Soulier
2023-12-21 15:42:08 -08:00
parent 149cb6537e
commit daa580235e
46 changed files with 4518 additions and 1149 deletions

View File

@@ -43,10 +43,10 @@ struct lc3bin_header {
* Read LC3 binary header
*/
int lc3bin_read_header(FILE *fp,
int *frame_us, int *srate_hz, int *nchannels, int *nsamples)
int *frame_us, int *srate_hz, bool *hrmode, int *nchannels, int *nsamples)
{
struct lc3bin_header hdr;
uint16_t hrmode = 0;
uint16_t hdr_hrmode = 0;
if (fread(&hdr, sizeof(hdr), 1, fp) != 1
|| hdr.file_id != LC3_FILE_ID
@@ -55,15 +55,16 @@ int lc3bin_read_header(FILE *fp,
int num_extended_params = (hdr.header_size - sizeof(hdr)) / sizeof(uint16_t);
if (num_extended_params >= 1 &&
fread(&hrmode, sizeof(hrmode), 1, fp) != 1)
fread(&hdr_hrmode, sizeof(hdr_hrmode), 1, fp) != 1)
return -1;
*nchannels = hdr.channels;
*frame_us = hdr.frame_10us * 10;
*srate_hz = hdr.srate_100hz * 100;
*nsamples = hdr.nsamples_low | (hdr.nsamples_high << 16);
*hrmode = hdr_hrmode != 0;
if (hdr.epmode || hrmode)
if (hdr.epmode)
return -1;
fseek(fp, hdr.header_size, SEEK_SET);
@@ -91,11 +92,15 @@ int lc3bin_read_data(FILE *fp, int nchannels, void *buffer)
* Write LC3 binary header
*/
void lc3bin_write_header(FILE *fp,
int frame_us, int srate_hz, int bitrate, int nchannels, int nsamples)
int frame_us, int srate_hz, bool hrmode,
int bitrate, int nchannels, int nsamples)
{
uint16_t hdr_hrmode = (hrmode != 0);
struct lc3bin_header hdr = {
.file_id = LC3_FILE_ID,
.header_size = sizeof(struct lc3bin_header),
.header_size = sizeof(struct lc3bin_header) +
(hrmode ? sizeof(hdr_hrmode) : 0),
.srate_100hz = srate_hz / 100,
.bitrate_100bps = bitrate / 100,
.channels = nchannels,
@@ -105,6 +110,9 @@ void lc3bin_write_header(FILE *fp,
};
fwrite(&hdr, sizeof(hdr), 1, fp);
if (hrmode)
fwrite(&hdr_hrmode, sizeof(hdr_hrmode), 1, fp);
}
/**