adding 8-bit pcm with sign bit (and interleave) support

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@377 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2008-07-30 20:58:50 +00:00
parent aca1aad654
commit dbc3512276
4 changed files with 26 additions and 0 deletions

View File

@ -29,6 +29,7 @@ void decode_pcm16LE_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channels
void decode_pcm16BE(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_pcm8(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_pcm8_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_pcm8_sb_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
void decode_psx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);

View File

@ -37,6 +37,17 @@ void decode_pcm8_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspac
}
}
void decode_pcm8_sb_int(VGMSTREAMCHANNEL * stream, sample * 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) {
int16_t v = (uint8_t)read_8bit(stream->offset+i*channelspacing,stream->streamfile);
if (v&0x80) v = 0-(v&0x7f);
outbuf[sample_count] = v*0x100;
}
}
void decode_pcm16LE_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
int i;
int32_t sample_count;

View File

@ -405,6 +405,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
case coding_PCM16BE:
case coding_PCM8:
case coding_PCM8_int:
case coding_PCM8_SB_int:
#ifdef VGM_USE_VORBIS
case coding_ogg_vorbis:
#endif
@ -478,6 +479,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
return 2;
case coding_PCM8:
case coding_PCM8_int:
case coding_PCM8_SB_int:
case coding_SDX2:
case coding_SDX2_int:
return 1;
@ -591,6 +593,13 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
samples_to_do);
}
break;
case coding_PCM8_SB_int:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_pcm8_sb_int(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,vgmstream->samples_into_block,
samples_to_do);
}
break;
case coding_NDS_IMA:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_nds_ima(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
@ -912,6 +921,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case coding_PCM8_int:
snprintf(temp,TEMPSIZE,"8-bit PCM with 1 byte interleave");
break;
case coding_PCM8_SB_int:
snprintf(temp,TEMPSIZE,"8-bit PCM with sign bit, 1 byte interleave");
break;
case coding_NGC_DSP:
snprintf(temp,TEMPSIZE,"Gamecube \"DSP\" 4-bit ADPCM");
break;

View File

@ -34,6 +34,8 @@ typedef enum {
coding_PCM8, /* 8-bit PCM */
coding_PCM8_int, /* 8-Bit PCM with sample-level interleave handled
by the decoder */
coding_PCM8_SB_int, /* 8-bit PCM, sign bit (others are 2's complement),
sample-level interleave */
/* 4-bit ADPCM */
coding_NDS_IMA, /* IMA ADPCM w/ NDS layout */