mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +01:00
Change some sample to sample_t
This commit is contained in:
parent
5bdc575f29
commit
111c4dd97c
@ -313,7 +313,7 @@ static void apply_config(VGMSTREAM * vgmstream, cli_config *cfg) {
|
||||
}
|
||||
}
|
||||
|
||||
void apply_fade(sample * buf, VGMSTREAM * vgmstream, int to_get, int i, int len_samples, int fade_samples, int channels) {
|
||||
void apply_fade(sample_t * buf, VGMSTREAM * vgmstream, int to_get, int i, int len_samples, int fade_samples, int channels) {
|
||||
int is_fade_on = vgmstream->loop_flag;
|
||||
|
||||
if (is_fade_on && fade_samples > 0) {
|
||||
@ -324,7 +324,7 @@ void apply_fade(sample * buf, VGMSTREAM * vgmstream, int to_get, int i, int len_
|
||||
if (samples_into_fade > 0) {
|
||||
double fadedness = (double)(fade_samples - samples_into_fade) / fade_samples;
|
||||
for (k = 0; k < channels; k++) {
|
||||
buf[j*channels + k] = (sample)buf[j*channels + k] * fadedness;
|
||||
buf[j*channels + k] = (sample_t)buf[j*channels + k] * fadedness;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,7 +339,7 @@ int main(int argc, char ** argv) {
|
||||
FILE * outfile = NULL;
|
||||
char outfilename_temp[PATH_LIMIT];
|
||||
|
||||
sample * buf = NULL;
|
||||
sample_t * buf = NULL;
|
||||
int channels;
|
||||
int32_t len_samples;
|
||||
int32_t fade_samples;
|
||||
@ -459,7 +459,7 @@ int main(int argc, char ** argv) {
|
||||
/* last init */
|
||||
channels = vgmstream->channels;
|
||||
|
||||
buf = malloc(BUFFER_SAMPLES * sizeof(sample) * channels);
|
||||
buf = malloc(BUFFER_SAMPLES * sizeof(sample_t) * channels);
|
||||
if (!buf) {
|
||||
fprintf(stderr,"failed allocating output buffer\n");
|
||||
goto fail;
|
||||
@ -488,10 +488,10 @@ int main(int argc, char ** argv) {
|
||||
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
||||
if (cfg.only_stereo != -1) {
|
||||
for (j = 0; j < to_get; j++) {
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample), 2, outfile);
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
||||
}
|
||||
} else {
|
||||
fwrite(buf, sizeof(sample) * channels, to_get, outfile);
|
||||
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -509,10 +509,10 @@ int main(int argc, char ** argv) {
|
||||
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
||||
if (cfg.only_stereo != -1) {
|
||||
for (j = 0; j < to_get; j++) {
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample), 2, outfile);
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
||||
}
|
||||
} else {
|
||||
fwrite(buf, sizeof(sample) * channels, to_get, outfile);
|
||||
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,13 +522,13 @@ int main(int argc, char ** argv) {
|
||||
|
||||
/* try again with (for testing reset_vgmstream, simulates a seek to 0) */
|
||||
if (cfg.test_reset) {
|
||||
char outfilename_temp[PATH_LIMIT];
|
||||
strcpy(outfilename_temp, cfg.outfilename);
|
||||
strcat(outfilename_temp, ".reset.wav");
|
||||
char outfilename_reset[PATH_LIMIT];
|
||||
strcpy(outfilename_reset, cfg.outfilename);
|
||||
strcat(outfilename_reset, ".reset.wav");
|
||||
|
||||
outfile = fopen(outfilename_temp,"wb");
|
||||
outfile = fopen(outfilename_reset,"wb");
|
||||
if (!outfile) {
|
||||
fprintf(stderr,"failed to open %s for output\n",outfilename_temp);
|
||||
fprintf(stderr,"failed to open %s for output\n",outfilename_reset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -564,10 +564,10 @@ int main(int argc, char ** argv) {
|
||||
swap_samples_le(buf, channels * to_get); /* write PC endian */
|
||||
if (cfg.only_stereo != -1) {
|
||||
for (j = 0; j < to_get; j++) {
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample), 2, outfile);
|
||||
fwrite(buf + j*channels + (cfg.only_stereo*2), sizeof(sample_t), 2, outfile);
|
||||
}
|
||||
} else {
|
||||
fwrite(buf, sizeof(sample) * channels, to_get, outfile);
|
||||
fwrite(buf, sizeof(sample_t) * channels, to_get, outfile);
|
||||
}
|
||||
}
|
||||
fclose(outfile);
|
||||
@ -615,7 +615,7 @@ static void make_smpl_chunk(uint8_t * buf, int32_t loop_start, int32_t loop_end)
|
||||
static size_t make_wav_header(uint8_t * buf, size_t buf_size, int32_t sample_count, int32_t sample_rate, int channels, int smpl_chunk, int32_t loop_start, int32_t loop_end) {
|
||||
size_t data_size, header_size;
|
||||
|
||||
data_size = sample_count*channels*sizeof(sample);
|
||||
data_size = sample_count * channels * sizeof(sample_t);
|
||||
header_size = 0x2c;
|
||||
if (smpl_chunk && loop_end)
|
||||
header_size += 0x3c+ 0x08;
|
||||
@ -633,9 +633,9 @@ static size_t make_wav_header(uint8_t * buf, size_t buf_size, int32_t sample_cou
|
||||
put_16bitLE(buf+0x14, 1); /* compression code 1=PCM */
|
||||
put_16bitLE(buf+0x16, channels); /* channel count */
|
||||
put_32bitLE(buf+0x18, sample_rate); /* sample rate */
|
||||
put_32bitLE(buf+0x1c, sample_rate*channels*sizeof(sample)); /* bytes per second */
|
||||
put_16bitLE(buf+0x20, (int16_t)(channels*sizeof(sample))); /* block align */
|
||||
put_16bitLE(buf+0x22, sizeof(sample)*8); /* significant bits per sample */
|
||||
put_32bitLE(buf+0x1c, sample_rate*channels*sizeof(sample_t)); /* bytes per second */
|
||||
put_16bitLE(buf+0x20, (int16_t)(channels*sizeof(sample_t))); /* block align */
|
||||
put_16bitLE(buf+0x22, sizeof(sample_t)*8); /* significant bits per sample */
|
||||
|
||||
if (smpl_chunk && loop_end) {
|
||||
make_smpl_chunk(buf+0x24, loop_start, loop_end);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "../vgmstream.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
void render_vgmstream_aix(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_aix(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written=0;
|
||||
aix_codec_data *data = vgmstream->codec_data;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
/* Decodes samples for blocked streams.
|
||||
* Data is divided into headered blocks with a bunch of data. The layout calls external helper functions
|
||||
* when a block is decoded, and those must parse the new block and move offsets accordingly. */
|
||||
void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_blocked(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written = 0;
|
||||
int frame_size, samples_per_frame, samples_this_block;
|
||||
|
||||
@ -41,14 +41,14 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM *
|
||||
if (samples_this_block < 0) {
|
||||
/* probably block bug or EOF, next calcs would give wrong values/segfaults/infinite loop */
|
||||
VGM_LOG("layout_blocked: wrong block samples at 0x%x\n", (uint32_t)vgmstream->current_block_offset);
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample));
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample_t));
|
||||
break;
|
||||
}
|
||||
|
||||
if (vgmstream->current_block_offset < 0 || vgmstream->current_block_offset == 0xFFFFFFFF) {
|
||||
/* probably block bug or EOF, block functions won't be able to read anything useful/infinite loop */
|
||||
VGM_LOG("layout_blocked: wrong block offset found\n");
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample));
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample_t));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
/* Decodes samples for flat streams.
|
||||
* Data forms a single stream, and the decoder may internally skip chunks and move offsets as needed. */
|
||||
void render_vgmstream_flat(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_flat(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written = 0;
|
||||
int samples_per_frame, samples_this_block;
|
||||
|
||||
@ -26,7 +26,7 @@ void render_vgmstream_flat(sample * buffer, int32_t sample_count, VGMSTREAM * vg
|
||||
|
||||
if (samples_to_do == 0) {
|
||||
VGM_LOG("layout_flat: wrong samples_to_do found\n");
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample));
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample_t));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Data has interleaved chunks per channel, and once one is decoded the layout moves offsets,
|
||||
* skipping other chunks (essentially a simplified variety of blocked layout).
|
||||
* Incompatible with decoders that move offsets. */
|
||||
void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_interleave(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written = 0;
|
||||
int frame_size, samples_per_frame, samples_this_block;
|
||||
int has_interleave_last = vgmstream->interleave_last_block_size && vgmstream->channels > 1;
|
||||
@ -49,7 +49,7 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
|
||||
|
||||
if (samples_to_do == 0) { /* happens when interleave is not set */
|
||||
VGM_LOG("layout_interleave: wrong samples_to_do found\n");
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample));
|
||||
memset(buffer + samples_written*vgmstream->channels, 0, (sample_count - samples_written) * vgmstream->channels * sizeof(sample_t));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
* Similar to interleave layout, but decodec samples are mixed from complete vgmstreams, each
|
||||
* with custom codecs and different number of channels, creating a single super-vgmstream.
|
||||
* Usually combined with custom streamfiles to handle data interleaved in weird ways. */
|
||||
void render_vgmstream_layered(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_layered(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written = 0;
|
||||
layered_layout_data *data = vgmstream->layout_data;
|
||||
sample interleave_buf[LAYER_BUF_SIZE*LAYER_MAX_CHANNELS];
|
||||
sample_t interleave_buf[LAYER_BUF_SIZE*LAYER_MAX_CHANNELS];
|
||||
|
||||
|
||||
while (samples_written < sample_count) {
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "../vgmstream.h"
|
||||
|
||||
/* blocked layouts */
|
||||
void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_blocked(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void block_update(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
void block_update_ast(off_t block_ofset, VGMSTREAM * vgmstream);
|
||||
@ -48,19 +48,19 @@ void block_update_xa_aiff(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
void block_update_vs_square(off_t block_offset, VGMSTREAM * vgmstream);
|
||||
|
||||
/* other layouts */
|
||||
void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_interleave(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
|
||||
void render_vgmstream_flat(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_flat(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
|
||||
void render_vgmstream_aix(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_aix(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
|
||||
void render_vgmstream_segmented(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_segmented(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
segmented_layout_data* init_layout_segmented(int segment_count);
|
||||
int setup_layout_segmented(segmented_layout_data* data);
|
||||
void free_layout_segmented(segmented_layout_data *data);
|
||||
void reset_layout_segmented(segmented_layout_data *data);
|
||||
|
||||
void render_vgmstream_layered(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
void render_vgmstream_layered(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
layered_layout_data* init_layout_layered(int layer_count);
|
||||
int setup_layout_layered(layered_layout_data* data);
|
||||
void free_layout_layered(layered_layout_data *data);
|
||||
|
@ -5,7 +5,7 @@
|
||||
/* Decodes samples for segmented streams.
|
||||
* Chains together sequential vgmstreams, for data divided into separate sections or files
|
||||
* (like one part for intro and other for loop segments, which may even use different codecs). */
|
||||
void render_vgmstream_segmented(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
void render_vgmstream_segmented(sample_t * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written = 0, loop_samples_skip = 0;
|
||||
segmented_layout_data *data = vgmstream->layout_data;
|
||||
|
||||
|
@ -1080,7 +1080,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
||||
/* swap channels if set, to create custom channel mappings */
|
||||
if (vgmstream->channel_mappings_on) {
|
||||
int ch_from,ch_to,s;
|
||||
sample temp;
|
||||
sample_t temp;
|
||||
for (s = 0; s < sample_count; s++) {
|
||||
for (ch_from = 0; ch_from < vgmstream->channels; ch_from++) {
|
||||
if (ch_from > 32)
|
||||
@ -1492,7 +1492,7 @@ int get_vgmstream_shortframe_size(VGMSTREAM * vgmstream) {
|
||||
|
||||
/* Decode samples into the buffer. Assume that we have written samples_written into the
|
||||
* buffer already, and we have samples_to_do consecutive samples ahead of us. */
|
||||
void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to_do, sample * buffer) {
|
||||
void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to_do, sample_t * buffer) {
|
||||
int ch;
|
||||
|
||||
switch (vgmstream->coding_type) {
|
||||
|
@ -1066,21 +1066,21 @@ typedef struct {
|
||||
|
||||
#ifdef VGM_USE_G7221
|
||||
typedef struct {
|
||||
sample buffer[640];
|
||||
sample_t buffer[640];
|
||||
g7221_handle *handle;
|
||||
} g7221_codec_data;
|
||||
#endif
|
||||
|
||||
#ifdef VGM_USE_G719
|
||||
typedef struct {
|
||||
sample buffer[960];
|
||||
sample_t buffer[960];
|
||||
void *handle;
|
||||
} g719_codec_data;
|
||||
#endif
|
||||
|
||||
#ifdef VGM_USE_MAIATRAC3PLUS
|
||||
typedef struct {
|
||||
sample *buffer;
|
||||
sample_t *buffer;
|
||||
int channels;
|
||||
int samples_discard;
|
||||
void *handle;
|
||||
@ -1112,7 +1112,7 @@ typedef struct {
|
||||
#define AIX_BUFFER_SIZE 0x1000
|
||||
/* AIXery */
|
||||
typedef struct {
|
||||
sample buffer[AIX_BUFFER_SIZE];
|
||||
sample_t buffer[AIX_BUFFER_SIZE];
|
||||
int segment_count;
|
||||
int stream_count;
|
||||
int current_segment;
|
||||
@ -1340,7 +1340,7 @@ int get_vgmstream_shortframe_size(VGMSTREAM * vgmstream);
|
||||
|
||||
/* Decode samples into the buffer. Assume that we have written samples_written into the
|
||||
* buffer already, and we have samples_to_do consecutive samples ahead of us. */
|
||||
void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to_do, sample * buffer);
|
||||
void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to_do, sample_t * buffer);
|
||||
|
||||
/* Calculate number of consecutive samples to do (taking into account stopping for loop start and end) */
|
||||
int vgmstream_samples_to_do(int samples_this_block, int samples_per_frame, VGMSTREAM * vgmstream);
|
||||
|
Loading…
x
Reference in New Issue
Block a user