cleanup: fix minor compiler warnings

This commit is contained in:
bnnm 2024-08-07 23:39:57 +02:00
parent 122de356c1
commit cfcca4e662
5 changed files with 28 additions and 28 deletions

View File

@ -50,9 +50,9 @@ atrac9_codec_data* init_atrac9(atrac9_config* cfg) {
/* must hold at least one superframe and its samples */
data->data_buffer_size = data->info.superframeSize;
/* extra leeway as Atrac9Decode seems to overread ~2 bytes (doesn't affect decoding though) */
data->data_buffer = calloc(sizeof(uint8_t), data->data_buffer_size + 0x10);
/* while ATRAC9 uses float internally, Sony's API only return PCM16 */
data->sample_buffer = calloc(sizeof(sample_t), data->info.channels * data->info.frameSamples * data->info.framesInSuperframe);
data->data_buffer = calloc(data->data_buffer_size + 0x10, sizeof(uint8_t));
/* while ATRAC9 uses float internally, Sony's API only returns PCM16 */
data->sample_buffer = calloc(data->info.channels * data->info.frameSamples * data->info.framesInSuperframe, sizeof(sample_t));
data->samples_to_discard = cfg->encoder_delay;
@ -221,7 +221,7 @@ void free_atrac9(atrac9_codec_data* data) {
}
static int atrac9_parse_config(uint32_t atrac9_config, int *out_sample_rate, int *out_channels, size_t *out_frame_size, size_t *out_samples_per_frame) {
static int atrac9_parse_config(uint32_t config_data, int* p_sample_rate, int* p_channels, size_t* p_frame_size, size_t* p_samples_per_frame) {
static const int sample_rate_table[16] = {
11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000,
44100, 48000, 64000, 88200, 96000,128000,176400,192000
@ -235,13 +235,13 @@ static int atrac9_parse_config(uint32_t atrac9_config, int *out_sample_rate, int
};
int superframe_size, frames_per_superframe, samples_per_frame, samples_per_superframe;
uint32_t sync = (atrac9_config >> 24) & 0xff; /* 8b */
uint8_t sample_rate_index = (atrac9_config >> 20) & 0x0f; /* 4b */
uint8_t channels_index = (atrac9_config >> 17) & 0x07; /* 3b */
/* uint8_t validation bit = (atrac9_config >> 16) & 0x01; */ /* 1b */
size_t frame_size = (atrac9_config >> 5) & 0x7FF; /* 11b */
size_t superframe_index = (atrac9_config >> 3) & 0x3; /* 2b */
/* uint8_t unused = (atrac9_config >> 0) & 0x7);*/ /* 3b */
uint32_t sync = (config_data >> 24) & 0xff; /* 8b */
uint8_t sample_rate_index = (config_data >> 20) & 0x0f; /* 4b */
uint8_t channels_index = (config_data >> 17) & 0x07; /* 3b */
/* uint8_t validation bit = (config_data >> 16) & 0x01; */ /* 1b */
size_t frame_size = (config_data >> 5) & 0x7FF; /* 11b */
size_t superframe_index = (config_data >> 3) & 0x3; /* 2b */
/* uint8_t unused = (config_data >> 0) & 0x7);*/ /* 3b */
superframe_size = ((frame_size+1) << superframe_index);
frames_per_superframe = (1 << superframe_index);
@ -250,14 +250,14 @@ static int atrac9_parse_config(uint32_t atrac9_config, int *out_sample_rate, int
if (sync != 0xFE)
goto fail;
if (out_sample_rate)
*out_sample_rate = sample_rate_table[sample_rate_index];
if (out_channels)
*out_channels = channel_table[channels_index];
if (out_frame_size)
*out_frame_size = superframe_size;
if (out_samples_per_frame)
*out_samples_per_frame = samples_per_superframe;
if (p_sample_rate)
*p_sample_rate = sample_rate_table[sample_rate_index];
if (p_channels)
*p_channels = channel_table[channels_index];
if (p_frame_size)
*p_frame_size = superframe_size;
if (p_samples_per_frame)
*p_samples_per_frame = samples_per_superframe;
return 1;
fail:
@ -268,9 +268,9 @@ size_t atrac9_bytes_to_samples(size_t bytes, atrac9_codec_data* data) {
return bytes / data->info.superframeSize * (data->info.frameSamples * data->info.framesInSuperframe);
}
size_t atrac9_bytes_to_samples_cfg(size_t bytes, uint32_t atrac9_config) {
size_t atrac9_bytes_to_samples_cfg(size_t bytes, uint32_t config_data) {
size_t frame_size, samples_per_frame;
if (!atrac9_parse_config(atrac9_config, NULL, NULL, &frame_size, &samples_per_frame))
if (!atrac9_parse_config(config_data, NULL, NULL, &frame_size, &samples_per_frame))
return 0;
return bytes / frame_size * samples_per_frame;
}

View File

@ -67,7 +67,7 @@ celt_codec_data* init_celt_fsb(int channels, celt_lib_t version) {
goto fail;
}
data->sample_buffer = calloc(sizeof(sample), data->channel_mode * FSB_CELT_SAMPLES_PER_FRAME);
data->sample_buffer = calloc(data->channel_mode * FSB_CELT_SAMPLES_PER_FRAME, sizeof(sample_t));
if (!data->sample_buffer) goto fail;
/* there is ~128 samples of encoder delay, but FMOD DLLs don't discard it? */

View File

@ -592,7 +592,7 @@ void reset_atrac9(atrac9_codec_data* data);
void seek_atrac9(VGMSTREAM* vgmstream, int32_t num_sample);
void free_atrac9(atrac9_codec_data* data);
size_t atrac9_bytes_to_samples(size_t bytes, atrac9_codec_data* data);
size_t atrac9_bytes_to_samples_cfg(size_t bytes, uint32_t atrac9_config);
size_t atrac9_bytes_to_samples_cfg(size_t bytes, uint32_t config_data);
#endif
@ -767,4 +767,4 @@ int mpc_get_samples(STREAMFILE* sf, off_t offset, int32_t* p_samples, int32_t* p
/* helper to pass a wrapped, clamped, fake extension-ed, SF to another meta */
STREAMFILE* setup_subfile_streamfile(STREAMFILE* sf, offv_t subfile_offset, size_t subfile_size, const char* extension);
#endif /*_CODING_H*/
#endif

View File

@ -23,7 +23,7 @@ mpeg_codec_data* init_mpeg(STREAMFILE* sf, off_t start_offset, coding_t* coding_
if (!data) goto fail;
data->buffer_size = MPEG_DATA_BUFFER_SIZE;
data->buffer = calloc(sizeof(uint8_t), data->buffer_size);
data->buffer = calloc(data->buffer_size, sizeof(uint8_t));
if (!data->buffer) goto fail;
data->m = init_mpg123_handle();
@ -176,7 +176,7 @@ mpeg_codec_data* init_mpeg_custom(STREAMFILE* sf, off_t start_offset, coding_t*
/* one per stream as sometimes mpg123 can't read the whole buffer in one pass */
data->streams[i].buffer_size = data->default_buffer_size;
data->streams[i].buffer = calloc(sizeof(uint8_t), data->streams[i].buffer_size);
data->streams[i].buffer = calloc(data->streams[i].buffer_size, sizeof(uint8_t));
if (!data->streams[i].buffer) goto fail;
data->streams[i].channels_per_frame = data->channels_per_frame;

View File

@ -23,11 +23,11 @@ vorbis_custom_codec_data* init_vorbis_custom(STREAMFILE* sf, off_t start_offset,
int ok;
/* init stuff */
data = calloc(1,sizeof(vorbis_custom_codec_data));
data = calloc(1, sizeof(vorbis_custom_codec_data));
if (!data) goto fail;
data->buffer_size = VORBIS_DEFAULT_BUFFER_SIZE;
data->buffer = calloc(sizeof(uint8_t), data->buffer_size);
data->buffer = calloc(data->buffer_size, sizeof(uint8_t));
if (!data->buffer) goto fail;
/* keep around to decode too */