Add PCM8, fix subsongs for large files

This commit is contained in:
bnnm 2017-08-25 22:43:33 +02:00
parent 95057a1561
commit a04b83b206

View File

@ -42,23 +42,23 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
for (i = 1; i <= TotalStreams; i++) {
off_t DataStart = 0;
size_t StreamHeaderLength = 0;
uint32_t SampleMode, SampleMode2;
uint32_t SampleMode1, SampleMode2;
/* seems ok but could use some testing against FMOD's SDK */
SampleMode = (uint32_t)read_32bitLE(SampleHeaderStart+0x00,streamFile);
SampleMode1 = (uint32_t)read_32bitLE(SampleHeaderStart+0x00,streamFile);
SampleMode2 = (uint32_t)read_32bitLE(SampleHeaderStart+0x04,streamFile);
StreamHeaderLength += 0x08;
/* get samples */
NumSamples = ((SampleMode2 >> 2) & 0x3FFFFFFF); /* bits 31..2 (30) */
// bits 1..0 part of DataStart?
/* get offset inside data section */
DataStart = ((SampleMode >> 7) & 0x0FFFFFF) << 5; /* bits 31..8 (24) * 0x20 */
DataStart = ((SampleMode1 >> 7) & 0x1FFFFFF) << 5; /* bits 31..8 (25) * 0x20 */
//SampleMode2 bits 1..0 part of DataStart for files larger than 0x3FFFFFE0?
/* get channels (from tests seems correct, but multichannel isn't very common, ex. no 4ch mode?) */
switch ((SampleMode >> 5) & 0x03) { /* bits 7..6 (2) */
switch ((SampleMode1 >> 5) & 0x03) { /* bits 7..6 (2) */
case 0: ChannelCount = 1; break;
case 1: ChannelCount = 2; break;
case 2: ChannelCount = 6; break;/* some Dark Souls 2 MPEG; some IMA ADPCM */
@ -68,7 +68,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
}
/* get sample rate */
switch ((SampleMode >> 1) & 0x0f) { /* bits 5..1 (4) */
switch ((SampleMode1 >> 1) & 0x0f) { /* bits 5..1 (4) */
case 0: SampleRate = 4000; break; //???
case 1: SampleRate = 8000; break;
case 2: SampleRate = 11000; break;
@ -86,7 +86,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
}
/* get extra flags */
if (SampleMode & 0x01) { /* bit 0 (1) */
if (SampleMode1 & 0x01) { /* bit 0 (1) */
uint32_t ExtraFlag, ExtraFlagStart, ExtraFlagType, ExtraFlagSize, ExtraFlagEnd;
ExtraFlagStart = SampleHeaderStart+0x08;
@ -192,8 +192,11 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
case 0x00: /* FMOD_SOUND_FORMAT_NONE */
goto fail;
case 0x01: /* FMOD_SOUND_FORMAT_PCM8 */
goto fail;
case 0x01: /* FMOD_SOUND_FORMAT_PCM8 [Anima - Gate of Memories (PC)] */
vgmstream->layout_type = ChannelCount == 1 ? layout_none : layout_interleave;
vgmstream->interleave_block_size = 0x01;
vgmstream->coding_type = coding_PCM8_U;
break;
case 0x02: /* FMOD_SOUND_FORMAT_PCM16 */
if (ChannelCount == 1) {
@ -212,7 +215,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
case 0x04: /* FMOD_SOUND_FORMAT_PCM32 */
goto fail;
case 0x05: /* FMOD_SOUND_FORMAT_PCMFLOAT [Anima - Gate of Memories (PC)]*/
case 0x05: /* FMOD_SOUND_FORMAT_PCMFLOAT [Anima - Gate of Memories (PC)] */
vgmstream->coding_type = coding_PCMFLOAT;
vgmstream->layout_type = (ChannelCount == 1) ? layout_none : layout_interleave;
vgmstream->interleave_block_size = 0x04;