tools & cpp: Add support of asymetric frame sizes of a stereo stream

This commit is contained in:
Antoine Soulier
2024-01-10 14:44:49 -08:00
parent 71ffd784d5
commit 4d014e33e7
7 changed files with 166 additions and 97 deletions

View File

@@ -80,12 +80,11 @@ int lc3bin_read_data(FILE *fp, int nchannels, void *buffer)
uint16_t nbytes;
if (fread(&nbytes, sizeof(nbytes), 1, fp) < 1
|| nbytes > nchannels * LC3_MAX_FRAME_BYTES
|| nbytes % nchannels
|| nbytes > nchannels * LC3_HR_MAX_FRAME_BYTES
|| fread(buffer, nbytes, 1, fp) < 1)
return -1;
return nbytes / nchannels;
return nbytes;
}
/**
@@ -118,11 +117,10 @@ void lc3bin_write_header(FILE *fp,
/**
* Write LC3 block of data
*/
void lc3bin_write_data(FILE *fp,
const void *data, int nchannels, int frame_bytes)
void lc3bin_write_data(FILE *fp, const void *data, int nbytes)
{
uint16_t nbytes = nchannels * frame_bytes;
fwrite(&nbytes, sizeof(nbytes), 1, fp);
uint16_t hdr_nbytes = nbytes;
fwrite(&hdr_nbytes, sizeof(hdr_nbytes), 1, fp);
fwrite(data, 1, nbytes, fp);
}