Use fact_samples if possible and add .snd [Layton Brothers (iOS)]

fact_samples can be specified with non-PCM codecs, per spec.
This commit is contained in:
bnnm 2018-02-17 17:32:58 +01:00
parent e73023d6e2
commit 830f904afb

View File

@ -126,18 +126,18 @@ static int read_fmt(int big_endian, STREAMFILE * streamFile, off_t current_chunk
fmt->coding_type = coding_MSADPCM; fmt->coding_type = coding_MSADPCM;
break; break;
case 0x11: /* MS IMA ADPCM */ case 0x11: /* MS IMA ADPCM [Layton Brothers: Mystery Room (iOS/Android)] */
if (fmt->bps != 4) goto fail; if (fmt->bps != 4) goto fail;
fmt->coding_type = coding_MS_IMA; fmt->coding_type = coding_MS_IMA;
break; break;
case 0x69: /* XBOX IMA ADPCM [Rayman Raving Rabbids 2 (PC) -- waa/wac/wam/wad?] */ case 0x69: /* XBOX IMA ADPCM [Rayman Raving Rabbids 2 (PC) --maybe waa/wac/wam/wad?] */
if (fmt->bps != 4) goto fail; if (fmt->bps != 4) goto fail;
fmt->coding_type = coding_XBOX_IMA; fmt->coding_type = coding_XBOX_IMA;
break; break;
case 0x007A: /* MS IMA ADPCM [LA Rush, Psi Ops (PC)] */ case 0x007A: /* MS IMA ADPCM [LA Rush (PC), Psi Ops (PC)] */
/* 0x007A is apparently "Voxware SC3" but in .MED it's just MS-IMA */ /* 0x007A is apparently "Voxware SC3" but in .MED it's just MS-IMA (0x11) */
if (!check_extensions(streamFile,"med")) if (!check_extensions(streamFile,"med"))
goto fail; goto fail;
@ -246,9 +246,10 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
int at3 = 0; /* Sony ATRAC3 / ATRAC3plus */ int at3 = 0; /* Sony ATRAC3 / ATRAC3plus */
int at9 = 0; /* Sony ATRAC9 */ int at9 = 0; /* Sony ATRAC9 */
/* check extension, case insensitive
* .da: The Great Battle VI (PS), .cd: Exector (PS), .med: Psi Ops (PC) */ /* check extension */
if ( check_extensions(streamFile, "wav,lwav,da,cd,med") ) { /* .da: The Great Battle VI (PS), .cd: Exector (PS), .med: Psi Ops (PC), .snd: Layton Brothers (iOS/Android) */
if ( check_extensions(streamFile, "wav,lwav,da,cd,med,snd") ) {
; ;
} }
else if ( check_extensions(streamFile, "mwv") ) { else if ( check_extensions(streamFile, "mwv") ) {
@ -382,13 +383,14 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
if (!FormatChunkFound || !DataChunkFound) goto fail; if (!FormatChunkFound || !DataChunkFound) goto fail;
//todo improve detection using fmt sizes/values as Wwise's don't match the RIFF standard
/* JUNK is an optional Wwise chunk, and Wwise hijacks the MSADPCM/MS_IMA/XBOX IMA ids (how nice). /* JUNK is an optional Wwise chunk, and Wwise hijacks the MSADPCM/MS_IMA/XBOX IMA ids (how nice).
* To ensure their stuff is parsed in wwise.c we reject their JUNK, which they put almost always. * To ensure their stuff is parsed in wwise.c we reject their JUNK, which they put almost always.
* As JUNK is legal (if unusual) we only reject those codecs. * As JUNK is legal (if unusual) we only reject those codecs.
* (ex. Cave PC games have PCM16LE + JUNK + smpl created by "Samplitude software") */ * (ex. Cave PC games have PCM16LE + JUNK + smpl created by "Samplitude software") */
if (JunkFound if (JunkFound
&& check_extensions(streamFile,"wav,lwav") /* for some .MED IMA */ && check_extensions(streamFile,"wav,lwav") /* for some .MED IMA */
&& (fmt.coding_type==coding_MSADPCM || fmt.coding_type==coding_MS_IMA)) && (fmt.coding_type==coding_MSADPCM /*|| fmt.coding_type==coding_MS_IMA*/ || fmt.coding_type==coding_XBOX_IMA))
goto fail; goto fail;
@ -411,9 +413,11 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
case coding_PCM16LE: case coding_PCM16LE:
vgmstream->num_samples = pcm_bytes_to_samples(data_size, fmt.channel_count, 16); vgmstream->num_samples = pcm_bytes_to_samples(data_size, fmt.channel_count, 16);
break; break;
case coding_PCM8_U_int: case coding_PCM8_U_int:
vgmstream->num_samples = pcm_bytes_to_samples(data_size, vgmstream->channels, 8); vgmstream->num_samples = pcm_bytes_to_samples(data_size, vgmstream->channels, 8);
break; break;
case coding_L5_555: case coding_L5_555:
if (!mwv) goto fail; if (!mwv) goto fail;
vgmstream->num_samples = data_size / 0x12 / fmt.channel_count * 32; vgmstream->num_samples = data_size / 0x12 / fmt.channel_count * 32;
@ -439,15 +443,22 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
} }
break; break;
case coding_MSADPCM: case coding_MSADPCM:
vgmstream->num_samples = msadpcm_bytes_to_samples(data_size, fmt.block_size, fmt.channel_count); vgmstream->num_samples = fact_sample_count ? fact_sample_count :
msadpcm_bytes_to_samples(data_size, fmt.block_size, fmt.channel_count);
break; break;
case coding_MS_IMA: case coding_MS_IMA:
vgmstream->num_samples = ms_ima_bytes_to_samples(data_size, fmt.block_size, fmt.channel_count); vgmstream->num_samples = fact_sample_count ? fact_sample_count :
ms_ima_bytes_to_samples(data_size, fmt.block_size, fmt.channel_count);
break; break;
case coding_XBOX_IMA: case coding_XBOX_IMA:
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, fmt.channel_count); vgmstream->num_samples = fact_sample_count ? fact_sample_count :
xbox_ima_bytes_to_samples(data_size, fmt.channel_count);
break; break;
case coding_NGC_DSP: case coding_NGC_DSP:
if (!sns) goto fail; if (!sns) goto fail;
if (fact_sample_count <= 0) goto fail; if (fact_sample_count <= 0) goto fail;