mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
Yamaha AICA decoder, and Dreamcast .str (Sega Stream Asset Builder)
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@408 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
7315f6fabc
commit
e580858ca3
@ -14,7 +14,8 @@ CODING_OBJS=coding/adx_decoder.o \
|
||||
coding/mpeg_decoder.o \
|
||||
coding/acm_decoder.o \
|
||||
coding/nwa_decoder.o \
|
||||
coding/msadpcm_decoder.o
|
||||
coding/msadpcm_decoder.o \
|
||||
coding/aica_decoder.o
|
||||
|
||||
LAYOUT_OBJS=layout/ast_blocked.o \
|
||||
layout/blocked.o \
|
||||
@ -120,7 +121,8 @@ META_OBJS=meta/adx_header.o \
|
||||
meta/xbox_wvs.o \
|
||||
meta/xbox_ims.o \
|
||||
meta/xbox_stma.o \
|
||||
meta/de2.o
|
||||
meta/de2.o \
|
||||
meta/dc_str.o
|
||||
|
||||
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)
|
||||
|
||||
|
@ -22,5 +22,6 @@ libcoding_la_SOURCES += mpeg_decoder.c
|
||||
libcoding_la_SOURCES += acm_decoder.c
|
||||
libcoding_la_SOURCES += nwa_decoder.c
|
||||
libcoding_la_SOURCES += msadpcm_decoder.c
|
||||
libcoding_la_SOURCES += aica_decoder.c
|
||||
|
||||
EXTRA_DIST = coding.h g72x_state.h
|
||||
|
50
src/coding/aica_decoder.c
Normal file
50
src/coding/aica_decoder.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include "../util.h"
|
||||
#include "coding.h"
|
||||
|
||||
/* fixed point (.8) amount to scale the current step size by */
|
||||
/* part of the same series as used in MS ADPCM "ADPCMTable" */
|
||||
static const unsigned int scale_step[16] =
|
||||
{
|
||||
230, 230, 230, 230, 307, 409, 512, 614,
|
||||
230, 230, 230, 230, 307, 409, 512, 614
|
||||
};
|
||||
|
||||
/* expand an unsigned four bit delta to a wider signed range */
|
||||
static const int scale_delta[16] =
|
||||
{
|
||||
1, 3, 5, 7, 9, 11, 13, 15,
|
||||
-1, -3, -5, -7, -9,-11,-13,-15
|
||||
};
|
||||
|
||||
/* Yamaha AICA ADPCM (as seen in Dreamcast) */
|
||||
|
||||
void decode_aica(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) {
|
||||
int i;
|
||||
int32_t sample_count;
|
||||
int32_t hist1 = stream->adpcm_history1_16;
|
||||
unsigned long step_size = stream->adpcm_step_index;
|
||||
|
||||
for (i=first_sample,sample_count=0; i<first_sample+samples_to_do; i++,sample_count+=channelspacing) {
|
||||
int sample_nibble =
|
||||
(
|
||||
(unsigned)read_8bit(stream->offset+i/2,stream->streamfile) >>
|
||||
(i&1?4:0)
|
||||
)&0xf;
|
||||
|
||||
int32_t sample_delta = (int32_t)step_size * scale_delta[sample_nibble];
|
||||
int32_t new_sample;
|
||||
|
||||
new_sample = hist1 + sample_delta/8;
|
||||
|
||||
outbuf[sample_count] = clamp16(new_sample);
|
||||
|
||||
hist1 = outbuf[sample_count];
|
||||
|
||||
step_size = (step_size * scale_step[sample_nibble])/0x100;
|
||||
if (step_size < 0x7f) step_size = 0x7f;
|
||||
if (step_size > 0x6000) step_size = 0x6000;
|
||||
}
|
||||
|
||||
stream->adpcm_history1_16 = hist1;
|
||||
stream->adpcm_step_index = step_size;
|
||||
}
|
@ -68,4 +68,6 @@ void decode_nwa(NWAData *nwa, sample *outbuf, int32_t samples_to_do);
|
||||
|
||||
void decode_msadpcm_stereo(VGMSTREAM * vgmstream, sample * outbuf, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
void decode_aica(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
|
||||
|
||||
#endif
|
||||
|
@ -604,6 +604,10 @@
|
||||
RelativePath=".\coding\adx_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\aica_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\coding\eaxa_decoder.c"
|
||||
>
|
||||
|
@ -92,5 +92,6 @@ libmeta_la_SOURCES += ngc_vjdsp.c
|
||||
libmeta_la_SOURCES += xbox_stma.c
|
||||
libmeta_la_SOURCES += xbox_ims.c
|
||||
libmeta_la_SOURCES += de2.c
|
||||
libmeta_la_SOURCES += dc_str.c
|
||||
|
||||
EXTRA_DIST = meta.h
|
||||
|
@ -29,7 +29,7 @@ VGMSTREAM * init_vgmstream_dc_str(STREAMFILE *streamFile) {
|
||||
vgmstream->channels = channel_count;
|
||||
start_offset = 0x800;
|
||||
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
|
||||
vgmstream->coding_type = coding_DVI_IMA;
|
||||
vgmstream->coding_type = coding_AICA;
|
||||
|
||||
vgmstream->num_samples = read_32bitLE(0x14,streamFile);
|
||||
|
||||
@ -56,6 +56,7 @@ VGMSTREAM * init_vgmstream_dc_str(STREAMFILE *streamFile) {
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
vgmstream->ch[i].adpcm_step_index = 0x7f; /* AICA */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
|
||||
init_vgmstream_xbox_stma,
|
||||
init_vgmstream_xbox_matx,
|
||||
init_vgmstream_de2,
|
||||
init_vgmstream_dc_str,
|
||||
};
|
||||
|
||||
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
|
||||
@ -526,6 +527,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
|
||||
case coding_IMA:
|
||||
return 1;
|
||||
case coding_INT_DVI_IMA:
|
||||
case coding_AICA:
|
||||
return 2;
|
||||
case coding_NGC_AFC:
|
||||
return 16;
|
||||
@ -609,6 +611,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
|
||||
case coding_WS:
|
||||
return vgmstream->current_block_size;
|
||||
case coding_INT_DVI_IMA:
|
||||
case coding_AICA:
|
||||
return 1;
|
||||
case coding_MSADPCM:
|
||||
return vgmstream->interleave_block_size;
|
||||
@ -873,6 +876,13 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to
|
||||
samples_to_do);
|
||||
}
|
||||
break;
|
||||
case coding_AICA:
|
||||
for (chan=0;chan<vgmstream->channels;chan++) {
|
||||
decode_aica(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan,
|
||||
vgmstream->channels,vgmstream->samples_into_block,
|
||||
samples_to_do);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1178,6 +1188,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case coding_MSADPCM:
|
||||
snprintf(temp,TEMPSIZE,"Microsoft 4-bit ADPCM");
|
||||
break;
|
||||
case coding_AICA:
|
||||
snprintf(temp,TEMPSIZE,"Yamaha AICA 4-bit ADPCM");
|
||||
break;
|
||||
default:
|
||||
snprintf(temp,TEMPSIZE,"CANNOT DECODE");
|
||||
}
|
||||
@ -1627,6 +1640,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case meta_DE2:
|
||||
snprintf(temp,TEMPSIZE,"gurumin .de2 with embedded funky RIFF");
|
||||
break;
|
||||
case meta_DC_STR:
|
||||
snprintf(temp,TEMPSIZE,"Sega Stream Asset Builder header");
|
||||
break;
|
||||
default:
|
||||
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ typedef enum {
|
||||
coding_NWA4,
|
||||
coding_NWA5,
|
||||
|
||||
coding_MSADPCM /* Microsoft ADPCM */
|
||||
coding_MSADPCM, /* Microsoft ADPCM */
|
||||
coding_AICA, /* Yamaha AICA ADPCM */
|
||||
} coding_t;
|
||||
|
||||
/* The layout type specifies how the sound data is laid out in the file */
|
||||
|
Loading…
x
Reference in New Issue
Block a user