mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 09:40:51 +01:00
Add PCM24 codec [Legend of Mana (PC)]
This commit is contained in:
parent
58b6b16e3a
commit
c859482dcd
@ -92,6 +92,7 @@ void decode_ulaw(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing,
|
|||||||
void decode_ulaw_int(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
void decode_ulaw_int(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||||
void decode_alaw(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
void decode_alaw(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||||
void decode_pcmfloat(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int big_endian);
|
void decode_pcmfloat(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int big_endian);
|
||||||
|
void decode_pcm24le(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||||
int32_t pcm_bytes_to_samples(size_t bytes, int channels, int bits_per_sample);
|
int32_t pcm_bytes_to_samples(size_t bytes, int channels, int bits_per_sample);
|
||||||
int32_t pcm16_bytes_to_samples(size_t bytes, int channels);
|
int32_t pcm16_bytes_to_samples(size_t bytes, int channels);
|
||||||
int32_t pcm8_bytes_to_samples(size_t bytes, int channels);
|
int32_t pcm8_bytes_to_samples(size_t bytes, int channels);
|
||||||
|
@ -216,6 +216,17 @@ void decode_pcmfloat(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelsp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void decode_pcm24le(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||||
|
int i;
|
||||||
|
int32_t sample_count;
|
||||||
|
|
||||||
|
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
|
||||||
|
off_t offset = stream->offset + i * 0x03;
|
||||||
|
int v = read_u8(offset+0x00, stream->streamfile) | (read_s16le(offset + 0x01, stream->streamfile) << 8);
|
||||||
|
outbuf[sample_count] = (v >> 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int32_t pcm_bytes_to_samples(size_t bytes, int channels, int bits_per_sample) {
|
int32_t pcm_bytes_to_samples(size_t bytes, int channels, int bits_per_sample) {
|
||||||
if (channels <= 0 || bits_per_sample <= 0) return 0;
|
if (channels <= 0 || bits_per_sample <= 0) return 0;
|
||||||
return ((int64_t)bytes * 8) / channels / bits_per_sample;
|
return ((int64_t)bytes * 8) / channels / bits_per_sample;
|
||||||
|
10
src/decode.c
10
src/decode.c
@ -368,6 +368,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM* vgmstream) {
|
|||||||
case coding_ULAW_int:
|
case coding_ULAW_int:
|
||||||
case coding_ALAW:
|
case coding_ALAW:
|
||||||
case coding_PCMFLOAT:
|
case coding_PCMFLOAT:
|
||||||
|
case coding_PCM24LE:
|
||||||
return 1;
|
return 1;
|
||||||
#ifdef VGM_USE_VORBIS
|
#ifdef VGM_USE_VORBIS
|
||||||
case coding_OGG_VORBIS:
|
case coding_OGG_VORBIS:
|
||||||
@ -592,6 +593,8 @@ int get_vgmstream_frame_size(VGMSTREAM* vgmstream) {
|
|||||||
return 0x01;
|
return 0x01;
|
||||||
case coding_PCMFLOAT:
|
case coding_PCMFLOAT:
|
||||||
return 0x04;
|
return 0x04;
|
||||||
|
case coding_PCM24LE:
|
||||||
|
return 0x03;
|
||||||
|
|
||||||
case coding_SDX2:
|
case coding_SDX2:
|
||||||
case coding_SDX2_int:
|
case coding_SDX2_int:
|
||||||
@ -886,6 +889,13 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case coding_PCM24LE:
|
||||||
|
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||||
|
decode_pcm24le(&vgmstream->ch[ch], buffer+ch,
|
||||||
|
vgmstream->channels, vgmstream->samples_into_block, samples_to_do);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case coding_NDS_IMA:
|
case coding_NDS_IMA:
|
||||||
for (ch = 0; ch < vgmstream->channels; ch++) {
|
for (ch = 0; ch < vgmstream->channels; ch++) {
|
||||||
decode_nds_ima(&vgmstream->ch[ch], buffer+ch,
|
decode_nds_ima(&vgmstream->ch[ch], buffer+ch,
|
||||||
|
@ -716,6 +716,7 @@ static const coding_info coding_info_list[] = {
|
|||||||
{coding_ULAW_int, "8-bit u-Law with 1 byte interleave (block)"},
|
{coding_ULAW_int, "8-bit u-Law with 1 byte interleave (block)"},
|
||||||
{coding_ALAW, "8-bit a-Law"},
|
{coding_ALAW, "8-bit a-Law"},
|
||||||
{coding_PCMFLOAT, "32-bit float PCM"},
|
{coding_PCMFLOAT, "32-bit float PCM"},
|
||||||
|
{coding_PCM24LE, "24-bit Little Endian PCM"},
|
||||||
|
|
||||||
{coding_CRI_ADX, "CRI ADX 4-bit ADPCM"},
|
{coding_CRI_ADX, "CRI ADX 4-bit ADPCM"},
|
||||||
{coding_CRI_ADX_fixed, "CRI ADX 4-bit ADPCM (fixed coefficients)"},
|
{coding_CRI_ADX_fixed, "CRI ADX 4-bit ADPCM (fixed coefficients)"},
|
||||||
|
@ -67,7 +67,8 @@ typedef enum {
|
|||||||
coding_ULAW_int, /* 8-bit u-Law (non-linear PCM) with sample-level interleave (for blocks) */
|
coding_ULAW_int, /* 8-bit u-Law (non-linear PCM) with sample-level interleave (for blocks) */
|
||||||
coding_ALAW, /* 8-bit a-Law (non-linear PCM) */
|
coding_ALAW, /* 8-bit a-Law (non-linear PCM) */
|
||||||
|
|
||||||
coding_PCMFLOAT, /* 32 bit float PCM */
|
coding_PCMFLOAT, /* 32-bit float PCM */
|
||||||
|
coding_PCM24LE, /* 24-bit PCM */
|
||||||
|
|
||||||
/* ADPCM */
|
/* ADPCM */
|
||||||
coding_CRI_ADX, /* CRI ADX */
|
coding_CRI_ADX, /* CRI ADX */
|
||||||
|
Loading…
Reference in New Issue
Block a user