mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
take the first channel found
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@860 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
f2cbf2116d
commit
08c67aa7ae
@ -20,6 +20,8 @@ VGMSTREAM * init_vgmstream_cdxa(STREAMFILE *streamFile) {
|
||||
char filename[260];
|
||||
|
||||
int channel_count;
|
||||
int headerless=0;
|
||||
int* xa_channel=0;
|
||||
uint8_t bCoding;
|
||||
off_t start_offset;
|
||||
|
||||
@ -33,41 +35,54 @@ VGMSTREAM * init_vgmstream_cdxa(STREAMFILE *streamFile) {
|
||||
if (!((read_32bitBE(0x00,streamFile) == 0x52494646) &&
|
||||
(read_32bitBE(0x08,streamFile) == 0x43445841) &&
|
||||
(read_32bitBE(0x0C,streamFile) == 0x666D7420)))
|
||||
goto fail;
|
||||
headerless=1;
|
||||
|
||||
/* First init to have the correct info of the channel */
|
||||
start_offset=init_xa_channel(0,streamFile);
|
||||
if (!headerless) {
|
||||
start_offset=init_xa_channel(&xa_channel,streamFile);
|
||||
|
||||
/* No sound ? */
|
||||
if(start_offset==0)
|
||||
goto fail;
|
||||
/* No sound ? */
|
||||
if(start_offset==0)
|
||||
goto fail;
|
||||
|
||||
bCoding = read_8bit(start_offset-5,streamFile);
|
||||
bCoding = read_8bit(start_offset-5,streamFile);
|
||||
|
||||
switch (AUDIO_CODING_GET_STEREO(bCoding)) {
|
||||
case 0: channel_count = 1; break;
|
||||
case 1: channel_count = 2; break;
|
||||
default: channel_count = 0; break;
|
||||
switch (AUDIO_CODING_GET_STEREO(bCoding)) {
|
||||
case 0: channel_count = 1; break;
|
||||
case 1: channel_count = 2; break;
|
||||
default: channel_count = 0; break;
|
||||
}
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,0);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->xa_channel = xa_channel;
|
||||
|
||||
switch (AUDIO_CODING_GET_FREQ(bCoding)) {
|
||||
case 0: vgmstream->sample_rate = 37800; break;
|
||||
case 1: vgmstream->sample_rate = 18900; break;
|
||||
default: vgmstream->sample_rate = 0; break;
|
||||
}
|
||||
|
||||
/* Check for Compression Scheme */
|
||||
vgmstream->num_samples = (int32_t)((((get_streamfile_size(streamFile) - 0x3C)/2352)*0x1F80)/(2*channel_count));
|
||||
} else
|
||||
{
|
||||
channel_count=2;
|
||||
vgmstream = allocate_vgmstream(2,0);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->xa_headerless=1;
|
||||
vgmstream->sample_rate=44100;
|
||||
vgmstream->channels=2;
|
||||
vgmstream->num_samples = (int32_t)(((get_streamfile_size(streamFile)/ 0x80)*0xE0)/2);
|
||||
start_offset=0;
|
||||
}
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,0);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->xa_channel = 0;
|
||||
|
||||
switch (AUDIO_CODING_GET_FREQ(bCoding)) {
|
||||
case 0: vgmstream->sample_rate = 37800; break;
|
||||
case 1: vgmstream->sample_rate = 18900; break;
|
||||
default: vgmstream->sample_rate = 0; break;
|
||||
}
|
||||
|
||||
/* Check for Compression Scheme */
|
||||
vgmstream->coding_type = coding_XA;
|
||||
vgmstream->num_samples = (int32_t)((((get_streamfile_size(streamFile) - 0x3C)/2352)*0x1F80)/(2*channel_count));
|
||||
|
||||
vgmstream->layout_type = layout_xa_blocked;
|
||||
vgmstream->meta_type = meta_PSX_XA;
|
||||
|
||||
@ -93,7 +108,7 @@ fail:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
off_t init_xa_channel(int channel,STREAMFILE* streamFile) {
|
||||
off_t init_xa_channel(int* channel,STREAMFILE* streamFile) {
|
||||
|
||||
off_t block_offset=0x44;
|
||||
size_t filelength=get_streamfile_size(streamFile);
|
||||
@ -109,9 +124,10 @@ begin:
|
||||
|
||||
currentChannel=read_8bit(block_offset-7,streamFile);
|
||||
subAudio=read_8bit(block_offset-6,streamFile);
|
||||
if (!((currentChannel==channel) && (subAudio==0x64))) {
|
||||
block_offset+=2352;
|
||||
goto begin;
|
||||
}
|
||||
*channel=currentChannel;
|
||||
//if (!((currentChannel==channel) && (subAudio==0x64))) {
|
||||
// block_offset+=2352;
|
||||
// goto begin;
|
||||
//}
|
||||
return block_offset;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user