From dbc351227669587a1773a7259374dd39dced11ed Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Wed, 30 Jul 2008 20:58:50 +0000 Subject: [PATCH] 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 --- src/coding/coding.h | 1 + src/coding/pcm_decoder.c | 11 +++++++++++ src/vgmstream.c | 12 ++++++++++++ src/vgmstream.h | 2 ++ 4 files changed, 26 insertions(+) diff --git a/src/coding/coding.h b/src/coding/coding.h index b5f1a958..8b6bdce9 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -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); diff --git a/src/coding/pcm_decoder.c b/src/coding/pcm_decoder.c index f9a414de..06d4912b 100644 --- a/src/coding/pcm_decoder.c +++ b/src/coding/pcm_decoder.c @@ -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; ioffset+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; diff --git a/src/vgmstream.c b/src/vgmstream.c index 012dfebc..f6dcc3df 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -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;chanchannels;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;chanchannels;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; diff --git a/src/vgmstream.h b/src/vgmstream.h index b25b0691..e73ae7bc 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -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 */