2008-07-20 07:41:41 +02:00
|
|
|
#include "meta.h"
|
2018-03-16 15:42:01 +01:00
|
|
|
#include "../coding/coding.h"
|
2008-07-20 07:41:41 +02:00
|
|
|
#include "../coding/acm_decoder.h"
|
|
|
|
|
2018-03-16 15:42:01 +01:00
|
|
|
/* ACM - InterPlay infinity engine games [Planescape: Torment (PC), Baldur's Gate (PC)] */
|
2008-07-20 07:41:41 +02:00
|
|
|
VGMSTREAM * init_vgmstream_acm(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-03-16 13:03:39 +01:00
|
|
|
int loop_flag = 0, channel_count, sample_rate, num_samples;
|
2018-03-16 18:02:17 +01:00
|
|
|
acm_codec_data *data = NULL;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "acm"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x97280301) /* header id */
|
|
|
|
goto fail;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
/* init decoder */
|
|
|
|
{
|
2018-03-16 18:02:17 +01:00
|
|
|
data = init_acm(streamFile);
|
|
|
|
if (!data) goto fail;
|
2018-03-16 13:03:39 +01:00
|
|
|
|
2018-03-16 18:02:17 +01:00
|
|
|
channel_count = data->file->info.channels;
|
|
|
|
sample_rate = data->file->info.rate;
|
|
|
|
num_samples = data->file->total_values / data->file->info.channels;
|
2008-07-20 07:41:41 +02:00
|
|
|
}
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2008-07-20 07:41:41 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = num_samples;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
2018-03-16 13:03:39 +01:00
|
|
|
vgmstream->meta_type = meta_ACM;
|
|
|
|
vgmstream->coding_type = coding_ACM;
|
|
|
|
vgmstream->layout_type = layout_none;
|
2008-07-20 07:41:41 +02:00
|
|
|
|
|
|
|
vgmstream->codec_data = data;
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-03-16 15:42:01 +01:00
|
|
|
free_acm(data);
|
2018-03-16 13:03:39 +01:00
|
|
|
close_vgmstream(vgmstream);
|
2008-07-20 07:41:41 +02:00
|
|
|
return NULL;
|
|
|
|
}
|