diff options
author | Chris Robinson <[email protected]> | 2017-01-16 09:37:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-01-16 09:37:55 -0800 |
commit | e9009968fbfe3f89b308f6f2880e3bbafbb27884 (patch) | |
tree | 3c86677269412a217d320dbcfdb3a9e1e12ce365 /Alc | |
parent | f1f93a593a62b1a06f900d809628b5678eab4d8b (diff) |
More ALsizei, with the B-Format decoder
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ambdec.c | 21 | ||||
-rw-r--r-- | Alc/ambdec.h | 2 | ||||
-rw-r--r-- | Alc/bformatdec.c | 26 | ||||
-rw-r--r-- | Alc/bformatdec.h | 8 | ||||
-rw-r--r-- | Alc/panning.c | 4 |
5 files changed, 35 insertions, 26 deletions
diff --git a/Alc/ambdec.c b/Alc/ambdec.c index 255011d5..719b509c 100644 --- a/Alc/ambdec.c +++ b/Alc/ambdec.c @@ -90,6 +90,15 @@ static char *my_strtok_r(char *str, const char *delim, char **saveptr) return str; } +static char *read_int(ALint *num, const char *line, int base) +{ + char *end; + *num = strtol(line, &end, base); + if(end && *end != '\0') + end = lstrip(end); + return end; +} + static char *read_uint(ALuint *num, const char *line, int base) { char *end; @@ -131,7 +140,7 @@ char *read_clipped_line(FILE *f, char **buffer, size_t *maxlen) static int load_ambdec_speakers(AmbDecConf *conf, FILE *f, char **buffer, size_t *maxlen, char **saveptr) { - ALuint cur = 0; + ALsizei cur = 0; while(cur < conf->NumSpeakers) { const char *cmd = my_strtok_r(NULL, " \t", saveptr); @@ -184,10 +193,10 @@ static int load_ambdec_speakers(AmbDecConf *conf, FILE *f, char **buffer, size_t return 1; } -static int load_ambdec_matrix(ALfloat *gains, ALfloat (*matrix)[MAX_AMBI_COEFFS], ALuint maxrow, FILE *f, char **buffer, size_t *maxlen, char **saveptr) +static int load_ambdec_matrix(ALfloat *gains, ALfloat (*matrix)[MAX_AMBI_COEFFS], ALsizei maxrow, FILE *f, char **buffer, size_t *maxlen, char **saveptr) { int gotgains = 0; - ALuint cur = 0; + ALsizei cur = 0; while(cur < maxrow) { const char *cmd = my_strtok_r(NULL, " \t", saveptr); @@ -269,7 +278,7 @@ static int load_ambdec_matrix(ALfloat *gains, ALfloat (*matrix)[MAX_AMBI_COEFFS] void ambdec_init(AmbDecConf *conf) { - ALuint i; + ALsizei i; memset(conf, 0, sizeof(*conf)); AL_STRING_INIT(conf->Description); @@ -282,7 +291,7 @@ void ambdec_init(AmbDecConf *conf) void ambdec_deinit(AmbDecConf *conf) { - ALuint i; + ALsizei i; al_string_deinit(&conf->Description); for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) @@ -370,7 +379,7 @@ int ambdec_load(AmbDecConf *conf, const char *fname) else if(strcmp(dec, "speakers") == 0) { line = my_strtok_r(NULL, "", &saveptr); - line = read_uint(&conf->NumSpeakers, line, 10); + line = read_int(&conf->NumSpeakers, line, 10); if(line && *line != '\0') { ERR("Extra junk after speakers: %s\n", line); diff --git a/Alc/ambdec.h b/Alc/ambdec.h index 8a3befc1..0bb84072 100644 --- a/Alc/ambdec.h +++ b/Alc/ambdec.h @@ -17,7 +17,7 @@ typedef struct AmbDecConf { ALuint ChanMask; ALuint FreqBands; /* Must be 1 or 2 */ - ALuint NumSpeakers; + ALsizei NumSpeakers; enum AmbDecScaleType CoeffScale; ALfloat XOverFreq; diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c index c18376b5..fa7d2e19 100644 --- a/Alc/bformatdec.c +++ b/Alc/bformatdec.c @@ -246,7 +246,7 @@ typedef struct BFormatDec { struct { alignas(16) ALfloat Buffer[MAX_DELAY_LENGTH]; - ALuint Length; /* Valid range is [0...MAX_DELAY_LENGTH). */ + ALsizei Length; /* Valid range is [0...MAX_DELAY_LENGTH). */ } Delay[MAX_OUTPUT_CHANNELS]; struct { @@ -255,7 +255,7 @@ typedef struct BFormatDec { ALfloat Gains[4][MAX_OUTPUT_CHANNELS][FB_Max]; } UpSampler; - ALuint NumChannels; + ALsizei NumChannels; ALboolean DualBand; ALboolean Periphonic; } BFormatDec; @@ -297,7 +297,7 @@ int bformatdec_getOrder(const struct BFormatDec *dec) return 0; } -void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags) +void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags) { static const ALuint map2DTo3D[MAX_AMBI2D_COEFFS] = { 0, 1, 3, 4, 8, 9, 15 @@ -305,7 +305,7 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, const ALfloat *coeff_scale = UnitScale; ALfloat distgain[MAX_OUTPUT_CHANNELS]; ALfloat maxdist, ratio; - ALuint i; + ALsizei i; al_free(dec->Samples); dec->Samples = NULL; @@ -375,7 +375,7 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, dec->Delay[chan].Length = (ALuint)clampf(delay, 0.0f, (ALfloat)(MAX_DELAY_LENGTH-1)); distgain[i] = conf->Speakers[i].Distance / maxdist; - TRACE("Channel %u \"%s\" distance compensation: %u samples, %f gain\n", chan, + TRACE("Channel %u \"%s\" distance compensation: %d samples, %f gain\n", chan, al_string_get_cstr(conf->Speakers[i].Name), dec->Delay[chan].Length, distgain[i] ); } @@ -492,9 +492,9 @@ void bformatdec_reset(BFormatDec *dec, const AmbDecConf *conf, ALuint chancount, } -void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo) +void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo) { - ALuint chan, i; + ALsizei chan, i; if(dec->DualBand) { @@ -519,7 +519,7 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU if(dec->Delay[chan].Length > 0) { - const ALuint base = dec->Delay[chan].Length; + const ALsizei base = dec->Delay[chan].Length; if(SamplesToDo >= base) { for(i = 0;i < base;i++) @@ -556,7 +556,7 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU if(dec->Delay[chan].Length > 0) { - const ALuint base = dec->Delay[chan].Length; + const ALsizei base = dec->Delay[chan].Length; if(SamplesToDo >= base) { for(i = 0;i < base;i++) @@ -583,9 +583,9 @@ void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BU } -void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint InChannels, ALuint SamplesToDo) +void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo) { - ALuint i, j; + ALsizei i, j; /* This up-sampler is very simplistic. It essentially decodes the first- * order content to a square channel array (or cube if height is desired), @@ -652,9 +652,9 @@ void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device) ambiup->Gains, device->Dry.NumChannels); } -void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo) +void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo) { - ALuint i, j; + ALsizei i, j; for(i = 0;i < 4;i++) { diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index 2fd38ac5..3f240e54 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -14,13 +14,13 @@ enum BFormatDecFlags { struct BFormatDec *bformatdec_alloc(); void bformatdec_free(struct BFormatDec *dec); int bformatdec_getOrder(const struct BFormatDec *dec); -void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALuint chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags); +void bformatdec_reset(struct BFormatDec *dec, const struct AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALuint chanmap[MAX_OUTPUT_CHANNELS], int flags); /* Decodes the ambisonic input to the given output channels. */ -void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo); +void bformatdec_process(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo); /* Up-samples a first-order input to the decoder's configuration. */ -void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint InChannels, ALuint SamplesToDo); +void bformatdec_upSample(struct BFormatDec *dec, ALfloat (*restrict OutBuffer)[BUFFERSIZE], const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei InChannels, ALsizei SamplesToDo); /* Stand-alone first-order upsampler. Kept here because it shares some stuff @@ -30,7 +30,7 @@ struct AmbiUpsampler *ambiup_alloc(); void ambiup_free(struct AmbiUpsampler *ambiup); void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device); -void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALuint OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALuint SamplesToDo); +void ambiup_process(struct AmbiUpsampler *ambiup, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALsizei OutChannels, const ALfloat (*restrict InSamples)[BUFFERSIZE], ALsizei SamplesToDo); /* Band splitter. Splits a signal into two phase-matching frequency bands. */ diff --git a/Alc/panning.c b/Alc/panning.c index 06c0d9cc..e1ad6d0b 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -379,7 +379,7 @@ static void SetChannelMap(const enum Channel *devchans, ChannelConfig *ambicoeff static bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALuint speakermap[MAX_OUTPUT_CHANNELS]) { - ALuint i; + ALsizei i; for(i = 0;i < conf->NumSpeakers;i++) { @@ -659,7 +659,7 @@ static void InitCustomPanning(ALCdevice *device, const AmbDecConf *conf, const A else if(conf->CoeffScale == ADS_FuMa) coeff_scale = FuMa2N3DScale; - for(i = 0;i < (ALsizei)conf->NumSpeakers;i++) + for(i = 0;i < conf->NumSpeakers;i++) { ALsizei chan = speakermap[i]; ALfloat gain; |