From 8ee5f1b89dfabc35e797d21daed9faa3441b22b2 Mon Sep 17 00:00:00 2001 From: halleyscometsw Date: Sun, 23 Nov 2008 12:21:36 +0000 Subject: [PATCH] 8-bit unsigned pcm, for RIFF git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@486 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/coding/coding.h | 1 + src/coding/pcm_decoder.c | 10 ++++++++++ src/meta/riff.c | 6 +++--- src/vgmstream.c | 12 ++++++++++++ src/vgmstream.h | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/coding/coding.h b/src/coding/coding.h index cfe904d1..89df2a47 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -30,6 +30,7 @@ void decode_pcm16BE(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspaci 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_pcm8_unsigned_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 06d4912b..c1e64ee8 100644 --- a/src/coding/pcm_decoder.c +++ b/src/coding/pcm_decoder.c @@ -48,6 +48,16 @@ void decode_pcm8_sb_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channels } } +void decode_pcm8_unsigned_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); + outbuf[sample_count] = v*0x100 - 0x8000; + } +} + 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/meta/riff.c b/src/meta/riff.c index 4f89bf18..fa4275df 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -149,7 +149,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { interleave = 2; break; case 8: - coding_type = coding_PCM8; + coding_type = coding_PCM8_U_int; interleave = 1; break; default: @@ -211,7 +211,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { case coding_PCM16LE: sample_count = data_size/2/channel_count; break; - case coding_PCM8: + case coding_PCM8_U_int: sample_count = data_size/channel_count; break; } @@ -226,7 +226,7 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { vgmstream->sample_rate = sample_rate; vgmstream->coding_type = coding_type; - if (channel_count > 1) + if (channel_count > 1 && coding_type != coding_PCM8_U_int) vgmstream->layout_type = layout_interleave; else vgmstream->layout_type = layout_none; diff --git a/src/vgmstream.c b/src/vgmstream.c index 56fa7b1b..bdd9f1d5 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -540,6 +540,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) { case coding_PCM8: case coding_PCM8_int: case coding_PCM8_SB_int: + case coding_PCM8_U_int: #ifdef VGM_USE_VORBIS case coding_ogg_vorbis: #endif @@ -625,6 +626,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) { case coding_PCM8: case coding_PCM8_int: case coding_PCM8_SB_int: + case coding_PCM8_U_int: case coding_SDX2: case coding_SDX2_int: case coding_NWA0: @@ -756,6 +758,13 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to samples_to_do); } break; + case coding_PCM8_U_int: + for (chan=0;chanchannels;chan++) { + decode_pcm8_unsigned_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, @@ -1121,6 +1130,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case coding_PCM8: snprintf(temp,TEMPSIZE,"8-bit PCM"); break; + case coding_PCM8_U_int: + snprintf(temp,TEMPSIZE,"8-bit unsigned PCM with 1 byte interleave"); + break; case coding_PCM8_int: snprintf(temp,TEMPSIZE,"8-bit PCM with 1 byte interleave"); break; diff --git a/src/vgmstream.h b/src/vgmstream.h index c6d46349..1770aa28 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -37,6 +37,8 @@ typedef enum { by the decoder */ coding_PCM8_SB_int, /* 8-bit PCM, sign bit (others are 2's complement), sample-level interleave */ + coding_PCM8_U_int, /* 8-bit PCM, unsigned (0x80 = 0), sample-level + interleave */ /* 4-bit ADPCM */ coding_NDS_IMA, /* IMA ADPCM w/ NDS layout */