Added PCM (for brstm, at least)

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@14 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2008-02-05 01:28:52 +00:00
parent 0bc44fcc42
commit eb6087ab53
7 changed files with 75 additions and 5 deletions

View File

@ -1,4 +1,4 @@
#include "gcdsp.h"
#include "gcdsp_decoder.h"
#include "../util.h"
void decode_gcdsp(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {

View File

@ -1,6 +1,7 @@
#include "interleave.h"
#include "adx.h"
#include "gcdsp.h"
#include "gcdsp_decoder.h"
#include "pcm_decoder.h"
void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
int samples_written=0;
@ -17,6 +18,15 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
frame_size=8;
samples_per_frame=14;
break;
case coding_PCM16LE:
case coding_PCM16BE:
frame_size=2;
samples_per_frame=1;
break;
case coding_PCM8:
frame_size=1;
samples_per_frame=1;
break;
}
samples_this_block = vgmstream->interleave_block_size / frame_size * samples_per_frame;
@ -91,7 +101,7 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
}
if ((vgmstream->samples_into_block%samples_per_frame)+samples_to_do>samples_per_frame) samples_to_do=samples_per_frame-(vgmstream->samples_into_block%samples_per_frame);
if (samples_per_frame>1 && (vgmstream->samples_into_block%samples_per_frame)+samples_to_do>samples_per_frame) samples_to_do=samples_per_frame-(vgmstream->samples_into_block%samples_per_frame);
if (samples_written+samples_to_do > sample_count)
samples_to_do=sample_count-samples_written;
@ -112,6 +122,27 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
samples_to_do);
}
break;
case coding_PCM16LE:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_pcm16LE(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,vgmstream->samples_into_block,
samples_to_do);
}
break;
case coding_PCM16BE:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_pcm16BE(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,vgmstream->samples_into_block,
samples_to_do);
}
break;
case coding_PCM8:
for (chan=0;chan<vgmstream->channels;chan++) {
decode_pcm8(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
vgmstream->channels,vgmstream->samples_into_block,
samples_to_do);
}
break;
}
samples_written += samples_to_do;

View File

@ -1,6 +1,6 @@
#include "nolayout.h"
#include "adx.h"
#include "gcdsp.h"
#include "gcdsp_decoder.h"
void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
int samples_written=0;

29
src/fmt/pcm_decoder.c Normal file
View File

@ -0,0 +1,29 @@
#include "adx.h"
#include "../util.h"
void decode_pcm16LE(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) {
outbuf[sample_count]=read_16bitLE(stream->offset+i*2,stream->streamfile);
}
}
void decode_pcm16BE(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) {
outbuf[sample_count]=read_16bitBE(stream->offset+i*2,stream->streamfile);
}
}
void decode_pcm8(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) {
outbuf[sample_count]=read_8bit(stream->offset+i,stream->streamfile);
}
}

10
src/fmt/pcm_decoder.h Normal file
View File

@ -0,0 +1,10 @@
#include "../vgmstream.h"
#ifndef _DECODE_PCM_H
#define _DECODE_PCM_H
void decode_pcm16LE(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
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);
#endif

View File

@ -1,6 +1,6 @@
CFLAGS=-lm -O3
test: test.c ../src/streamfile.c ../src/vgmstream.c ../src/util.c ../src/fmt/adx_header.c ../src/fmt/adx_decoder.c ../src/fmt/gcdsp_decoder.c ../src/fmt/brstm.c ../src/fmt/interleave.c ../src/fmt/nolayout.c
test: test.c ../src/streamfile.c ../src/vgmstream.c ../src/util.c ../src/fmt/adx_header.c ../src/fmt/adx_decoder.c ../src/fmt/gcdsp_decoder.c ../src/fmt/brstm.c ../src/fmt/interleave.c ../src/fmt/nolayout.c ../src/fmt/pcm_decoder.c
clean:
rm test