mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-29 19:37:30 +01:00
Simplify mus_acm_codec_data into acm_codec_data
This commit is contained in:
parent
98aa30a38e
commit
05dc3df6e0
@ -822,20 +822,19 @@ void acm_reset(ACMStream *acm)
|
|||||||
* interface to vgmstream
|
* interface to vgmstream
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
||||||
mus_acm_codec_data *init_acm(int files) {
|
acm_codec_data *init_acm(STREAMFILE *streamFile) {
|
||||||
mus_acm_codec_data* data = NULL;
|
acm_codec_data* data = NULL;
|
||||||
|
ACMStream *acm_stream = NULL;
|
||||||
|
char filename[PATH_LIMIT];
|
||||||
|
|
||||||
if (files == 0)
|
data = calloc(1,sizeof(acm_codec_data));
|
||||||
goto fail;
|
|
||||||
|
|
||||||
data = calloc(1,sizeof(mus_acm_codec_data));
|
|
||||||
if (!data) goto fail;
|
if (!data) goto fail;
|
||||||
|
|
||||||
data->files = calloc(files,sizeof(ACMStream *));
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||||
if (!data->files) goto fail;
|
if (acm_open_decoder(&acm_stream,streamFile,filename) != ACM_OK)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
data->file_count = files;
|
data->file = acm_stream;
|
||||||
data->current_file = 0;
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
@ -844,8 +843,10 @@ fail:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int channelspacing) {
|
void decode_acm(acm_codec_data *data, sample * outbuf, int32_t samples_to_do, int channelspacing) {
|
||||||
|
ACMStream * acm = data->file;
|
||||||
int32_t samples_read = 0;
|
int32_t samples_read = 0;
|
||||||
|
|
||||||
while (samples_read < samples_to_do) {
|
while (samples_read < samples_to_do) {
|
||||||
int32_t bytes_read_just_now = acm_read(
|
int32_t bytes_read_just_now = acm_read(
|
||||||
acm,
|
acm,
|
||||||
@ -862,30 +863,18 @@ void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
void reset_acm(VGMSTREAM *vgmstream) {
|
void reset_acm(VGMSTREAM *vgmstream) {
|
||||||
mus_acm_codec_data *data = vgmstream->codec_data;
|
acm_codec_data *data = vgmstream->codec_data;
|
||||||
int i;
|
|
||||||
if (data) {
|
if (data && data->file) {
|
||||||
data->current_file = 0;
|
acm_reset(data->file);
|
||||||
for (i=0;i<data->file_count;i++) {
|
|
||||||
acm_reset(data->files[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_acm(mus_acm_codec_data *data) {
|
void free_acm(acm_codec_data *data) {
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->files) {
|
if (data->file) {
|
||||||
int i;
|
acm_close(data->file);
|
||||||
for (i = 0; i < data->file_count; i++) {
|
|
||||||
/* shouldn't be duplicates */
|
|
||||||
if (data->files[i]) {
|
|
||||||
acm_close(data->files[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
free(data->files);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,10 +102,10 @@ void decode_cbd2_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspac
|
|||||||
void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||||
|
|
||||||
/* acm_decoder */
|
/* acm_decoder */
|
||||||
mus_acm_codec_data *init_acm(int files);
|
acm_codec_data *init_acm();
|
||||||
void decode_acm(ACMStream * acm, sample * outbuf, int32_t samples_to_do, int channelspacing);
|
void decode_acm(acm_codec_data *data, sample * outbuf, int32_t samples_to_do, int channelspacing);
|
||||||
void reset_acm(VGMSTREAM *vgmstream);
|
void reset_acm(VGMSTREAM *vgmstream);
|
||||||
void free_acm(mus_acm_codec_data *data);
|
void free_acm(acm_codec_data *data);
|
||||||
|
|
||||||
/* nwa_decoder */
|
/* nwa_decoder */
|
||||||
void decode_nwa(NWAData *nwa, sample *outbuf, int32_t samples_to_do);
|
void decode_nwa(NWAData *nwa, sample *outbuf, int32_t samples_to_do);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
||||||
mus_acm_codec_data *data = NULL;
|
acm_codec_data *data = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
@ -17,23 +17,13 @@ VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
|||||||
|
|
||||||
|
|
||||||
/* init decoder */
|
/* init decoder */
|
||||||
data = init_acm(1);
|
|
||||||
if (!data) goto fail;
|
|
||||||
|
|
||||||
/* open and parse the file before creating the vgmstream */
|
|
||||||
{
|
{
|
||||||
ACMStream *acm_stream = NULL;
|
data = init_acm(streamFile);
|
||||||
char filename[PATH_LIMIT];
|
if (!data) goto fail;
|
||||||
|
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
channel_count = data->file->info.channels;
|
||||||
if (acm_open_decoder(&acm_stream,streamFile,filename) != ACM_OK)
|
sample_rate = data->file->info.rate;
|
||||||
goto fail;
|
num_samples = data->file->total_values / data->file->info.channels;
|
||||||
|
|
||||||
data->files[0] = acm_stream;
|
|
||||||
|
|
||||||
channel_count = acm_stream->info.channels;
|
|
||||||
sample_rate = acm_stream->info.rate;
|
|
||||||
num_samples = acm_stream->total_values / acm_stream->info.channels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1791,16 +1791,11 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
|
|||||||
vgmstream->channels);
|
vgmstream->channels);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case coding_ACM: { //single ACM
|
case coding_ACM:
|
||||||
mus_acm_codec_data *data = vgmstream->codec_data;
|
decode_acm(vgmstream->codec_data,
|
||||||
ACMStream *acm;
|
|
||||||
|
|
||||||
acm = data->files[data->current_file];
|
|
||||||
decode_acm(acm,
|
|
||||||
buffer+samples_written*vgmstream->channels,
|
buffer+samples_written*vgmstream->channels,
|
||||||
samples_to_do, vgmstream->channels);
|
samples_to_do, vgmstream->channels);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case coding_NWA0:
|
case coding_NWA0:
|
||||||
case coding_NWA1:
|
case coding_NWA1:
|
||||||
case coding_NWA2:
|
case coding_NWA2:
|
||||||
|
@ -1041,20 +1041,10 @@ typedef struct {
|
|||||||
} atrac9_codec_data;
|
} atrac9_codec_data;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* with one file this is also used for just ACM */
|
/* libacm interface */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int file_count;
|
ACMStream *file;
|
||||||
int current_file;
|
} acm_codec_data;
|
||||||
/* the index we return to upon loop completion */
|
|
||||||
int loop_start_file;
|
|
||||||
/* one after the index of the last file, typically
|
|
||||||
* will be equal to file_count */
|
|
||||||
int loop_end_file;
|
|
||||||
/* Upon exit from a loop, which file to play. */
|
|
||||||
/* -1 if there is no such file */
|
|
||||||
/*int end_file;*/
|
|
||||||
ACMStream **files;
|
|
||||||
} mus_acm_codec_data;
|
|
||||||
|
|
||||||
#define AIX_BUFFER_SIZE 0x1000
|
#define AIX_BUFFER_SIZE 0x1000
|
||||||
/* AIXery */
|
/* AIXery */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user