mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
no layout (straight stream) type added
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@13 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
8e80ba4680
commit
0bc44fcc42
@ -2,17 +2,21 @@
|
||||
#include "../util.h"
|
||||
|
||||
void decode_adx(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||
int i=first_sample;
|
||||
int i;
|
||||
int32_t sample_count;
|
||||
|
||||
int32_t scale = read_16bitBE(stream->offset,stream->streamfile) + 1;
|
||||
int framesin = first_sample/32;
|
||||
|
||||
int32_t scale = read_16bitBE(stream->offset+framesin*18,stream->streamfile) + 1;
|
||||
int32_t hist1 = stream->adpcm_history1_32;
|
||||
int32_t hist2 = stream->adpcm_history2_32;
|
||||
int coef1 = stream->adpcm_coef[0];
|
||||
int coef2 = stream->adpcm_coef[1];
|
||||
|
||||
first_sample = first_sample%32;
|
||||
|
||||
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
|
||||
int sample_byte = read_8bit(stream->offset+2+i/2,stream->streamfile);
|
||||
int sample_byte = read_8bit(stream->offset+framesin*18+2+i/2,stream->streamfile);
|
||||
|
||||
outbuf[sample_count] = clamp16(
|
||||
(i&1?
|
||||
|
@ -73,12 +73,14 @@ VGMSTREAM * init_vgmstream_adx(const char * const filename) {
|
||||
vgmstream->loop_end_sample = loop_end_sample;
|
||||
|
||||
vgmstream->coding_type = coding_CRI_ADX;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
if (channel_count==1)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->meta_type = header_type;
|
||||
|
||||
vgmstream->interleave_block_size=18;
|
||||
|
||||
|
||||
close_streamfile(infile); infile=NULL;
|
||||
|
||||
/* calculate filter coefficients */
|
||||
|
@ -71,7 +71,10 @@ VGMSTREAM * init_vgmstream_brstm(const char * const filename) {
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_type;
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
if (channel_count==1)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->meta_type = meta_RSTM;
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitBE(head_offset+0x38,infile);
|
||||
|
93
src/fmt/nolayout.c
Normal file
93
src/fmt/nolayout.c
Normal file
@ -0,0 +1,93 @@
|
||||
#include "nolayout.h"
|
||||
#include "adx.h"
|
||||
#include "gcdsp.h"
|
||||
|
||||
void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
int samples_written=0;
|
||||
|
||||
const int samples_this_block = vgmstream->num_samples;
|
||||
int samples_per_frame;
|
||||
|
||||
switch(vgmstream->coding_type) {
|
||||
case coding_CRI_ADX:
|
||||
samples_per_frame = 32;
|
||||
break;
|
||||
case coding_NGC_DSP:
|
||||
samples_per_frame = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
while (samples_written<sample_count) {
|
||||
int samples_to_do;
|
||||
int chan;
|
||||
int samples_left_this_block;
|
||||
|
||||
samples_left_this_block = samples_this_block - vgmstream->samples_into_block;
|
||||
samples_to_do = samples_left_this_block;
|
||||
|
||||
/* fun loopy crap */
|
||||
/* Why did I think this would be any simpler? */
|
||||
if (vgmstream->loop_flag) {
|
||||
/* is this the loop end? */
|
||||
if (vgmstream->current_sample==vgmstream->loop_end_sample) {
|
||||
/* restore! */
|
||||
memcpy(vgmstream->ch,vgmstream->loop_ch,sizeof(VGMSTREAMCHANNEL)*vgmstream->channels);
|
||||
vgmstream->current_sample=vgmstream->loop_sample;
|
||||
vgmstream->samples_into_block=vgmstream->loop_samples_into_block;
|
||||
|
||||
continue; /* recalculate stuff */
|
||||
}
|
||||
|
||||
|
||||
/* is this the loop start? */
|
||||
if (!vgmstream->hit_loop && vgmstream->current_sample==vgmstream->loop_start_sample) {
|
||||
/* save! */
|
||||
memcpy(vgmstream->loop_ch,vgmstream->ch,sizeof(VGMSTREAMCHANNEL)*vgmstream->channels);
|
||||
|
||||
vgmstream->loop_sample=vgmstream->current_sample;
|
||||
vgmstream->loop_samples_into_block=vgmstream->samples_into_block;
|
||||
vgmstream->hit_loop=1;
|
||||
}
|
||||
|
||||
/* are we going to hit the loop end during this block? */
|
||||
if (vgmstream->current_sample+samples_left_this_block > vgmstream->loop_end_sample) {
|
||||
/* only do to just before it */
|
||||
samples_to_do = vgmstream->loop_end_sample-vgmstream->current_sample;
|
||||
}
|
||||
|
||||
/* are we going to hit the loop start during this block? */
|
||||
if (!vgmstream->hit_loop && vgmstream->current_sample+samples_left_this_block > vgmstream->loop_start_sample) {
|
||||
/* only do to just before it */
|
||||
samples_to_do = vgmstream->loop_start_sample-vgmstream->current_sample;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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_written+samples_to_do > sample_count)
|
||||
samples_to_do=sample_count-samples_written;
|
||||
|
||||
switch (vgmstream->coding_type) {
|
||||
case coding_CRI_ADX:
|
||||
for (chan=0;chan<vgmstream->channels;chan++) {
|
||||
decode_adx(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
|
||||
vgmstream->channels,vgmstream->samples_into_block,
|
||||
samples_to_do);
|
||||
}
|
||||
|
||||
break;
|
||||
case coding_NGC_DSP:
|
||||
for (chan=0;chan<vgmstream->channels;chan++) {
|
||||
decode_gcdsp(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
|
||||
vgmstream->channels,vgmstream->samples_into_block,
|
||||
samples_to_do);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
samples_written += samples_to_do;
|
||||
vgmstream->current_sample += samples_to_do;
|
||||
vgmstream->samples_into_block+=samples_to_do;
|
||||
}
|
||||
}
|
12
src/fmt/nolayout.h
Normal file
12
src/fmt/nolayout.h
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* interleave.h - interleaved layouts
|
||||
*/
|
||||
#include "../streamtypes.h"
|
||||
#include "../vgmstream.h"
|
||||
|
||||
#ifndef _NOLAYOUT_H
|
||||
#define _NOLAYOUT_H
|
||||
|
||||
void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream);
|
||||
|
||||
#endif
|
@ -2,6 +2,7 @@
|
||||
#include "fmt/adx.h"
|
||||
#include "fmt/brstm.h"
|
||||
#include "fmt/interleave.h"
|
||||
#include "fmt/nolayout.h"
|
||||
|
||||
/*
|
||||
* List of functions that will recognize files. These should correspond pretty
|
||||
@ -105,5 +106,8 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre
|
||||
case layout_interleave_shortblock:
|
||||
render_vgmstream_interleave(buffer,sample_count,vgmstream);
|
||||
break;
|
||||
case layout_none:
|
||||
render_vgmstream_nolayout(buffer,sample_count,vgmstream);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
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
|
||||
|
||||
clean:
|
||||
rm test
|
||||
|
Loading…
Reference in New Issue
Block a user