mirror of
https://github.com/google/liblc3.git
synced 2026-04-27 17:34:50 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user