2008-05-06 05:35:37 +02:00
|
|
|
#include "coding.h"
|
2008-02-05 02:28:52 +01:00
|
|
|
#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) {
|
2008-02-05 08:38:00 +01:00
|
|
|
outbuf[sample_count]=read_8bit(stream->offset+i,stream->streamfile)*0x100;
|
2008-02-05 02:28:52 +01:00
|
|
|
}
|
|
|
|
}
|
2008-07-14 21:21:45 +02:00
|
|
|
|
2008-07-14 22:42:49 +02:00
|
|
|
void decode_pcm8_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
2008-07-14 21:21:45 +02:00
|
|
|
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*channelspacing,stream->streamfile)*0x100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-30 22:58:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-23 13:21:36 +01:00
|
|
|
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; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
|
|
|
|
int16_t v = (uint8_t)read_8bit(stream->offset+i*channelspacing,stream->streamfile);
|
|
|
|
outbuf[sample_count] = v*0x100 - 0x8000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-14 22:42:49 +02:00
|
|
|
void decode_pcm16LE_int(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
2008-07-14 21:21:45 +02:00
|
|
|
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*channelspacing,stream->streamfile);
|
|
|
|
}
|
|
|
|
}
|