Merge remote-tracking branch 'upstream/master' into ea-ubi

# Conflicts:
#	src/meta/ubi_sb.c
This commit is contained in:
NicknineTheEagle 2019-01-28 09:27:45 +03:00
commit ba30c79d59
17 changed files with 1588 additions and 727 deletions

View File

@ -233,6 +233,14 @@ channel mask to allow only certain channels (ex. "song.adx#c1,2").
Creation of those files is meant for advanced users, docs can be found in
vgmstream source.
### Plugin conflicts
Since vgmstream supports a huge amount of formats it's possibly that some of
them are also supported in other plugins, and this sometimes causes conflicts.
If a file that should isn't playing or looping, first make sure vgmstream is
really opening it (should show "vgmstream" somewhere in the file info), and
try to remove a few other plugins. foobar's ffmpeg plugin and foo_adpcm are
known to cause issues.
## Tagging
Some of vgmstream's plugins support simple read-only tagging via external files.
@ -282,7 +290,7 @@ are used in few games.
- Sony PSX ADPCM a.k.a VAG (standard, badflags, configurable)
- Sony HEVAG
- Electronic Arts EA-XA (stereo, mono, Maxis)
- Electronic Arts EA-XAS
- Electronic Arts EA-XAS (v0, v1)
- DVI/IMA ADPCM (stereo/mono + high/low nibble, 3DS, Omikron, SNDS, etc)
- Microsoft MS IMA ADPCM (standard, Xbox, NDS, Radical, Wwise, FSB, WV6, etc)
- Microsoft MS ADPCM (standard, Cricket Audio)
@ -298,7 +306,7 @@ are used in few games.
- Konami XMD 4-bit ADPCM
- Argonaut ASF 4-bit ADPCM
- Circus XPCM ADPCM
- PC-FX ADPCM
- OKI 4-bit ADPCM (16-bit output, PC-FX)
- SDX2 2:1 Squareroot-Delta-Exact compression DPCM
- CBD2 2:1 Cuberoot-Delta-Exact compression DPCM
- Activision EXAKT SASSC DPCM
@ -560,6 +568,8 @@ This list is not complete and many other files are supported.
- .um3 (Ogg Vorbis)
- .xa (CD-ROM XA audio)
- .xma (MS XMA/XMA2)
- .sb0/sb1/sb2/sb3/sb4/sb5/sb6/sb7 (many)
- .sm0/sm1/sm2/sm3/sm4/sm5/sm6/sm7 (many)
- artificial/generic headers:
- .genh (lots)
- .txth (lots)

View File

@ -41,7 +41,6 @@ void decode_h4m_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspaci
size_t ima_bytes_to_samples(size_t bytes, int channels);
size_t ms_ima_bytes_to_samples(size_t bytes, int block_align, int channels);
size_t xbox_ima_bytes_to_samples(size_t bytes, int channels);
size_t ubi_ima_bytes_to_samples(size_t bytes, int channels, STREAMFILE *streamFile, off_t offset);
size_t apple_ima4_bytes_to_samples(size_t bytes, int channels);
/* ngc_dsp_decoder */

View File

@ -937,16 +937,19 @@ void decode_ubi_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspaci
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
off_t offset = stream->offset;
/* header fields mostly unknown (vary a lot or look like flags),
* 0x07 0x06 = major/minor tool version?, 0x0c: stereo flag? */
/* header fields mostly unknown (vary a lot or look like flags, tool version?, 0x08: stereo flag?) */
version = read_8bit(offset + 0x00, stream->streamfile);
big_endian = version < 5; //todo and sb.big_endian?
big_endian = version < 5;
read_16bit = big_endian ? read_16bitBE : read_16bitLE;
header_samples = read_16bit(offset + 0x0E, stream->streamfile); /* always 10 (per channel) */
hist1 = read_16bit(offset + 0x10 + channel*0x04,stream->streamfile);
step_index = read_8bit(offset + 0x12 + channel*0x04,stream->streamfile);
offset += 0x10 + 0x08 + 0x04; //todo v6 has extra 0x08?
offset += 0x10 + 0x08;
if (version >= 3)
offset += 0x04;
//if (version >= 6) /* supposedly this exists, maybe in later BAOs */
// offset += 0x08;
/* write PCM samples, must be written to match header's num_samples (hist mustn't) */
max_samples_to_do = ((samples_to_do > header_samples) ? header_samples : samples_to_do);
@ -1081,19 +1084,3 @@ size_t apple_ima4_bytes_to_samples(size_t bytes, int channels) {
return (bytes / block_align) * (block_align - 0x02*channels) * 2 / channels
+ ((bytes % block_align) ? ((bytes % block_align) - 0x02*channels) * 2 / channels : 0);
}
size_t ubi_ima_bytes_to_samples(size_t bytes, int channels, STREAMFILE *streamFile, off_t offset) {
int version, big_endian, header_samples;
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
size_t header_size = 0;
version = read_8bit(offset + 0x00, streamFile);
big_endian = version < 5; //todo and sb.big_endian?
read_16bit = big_endian ? read_16bitBE : read_16bitLE;
header_samples = read_16bit(offset + 0x0E, streamFile); /* always 10 (per channel) */
header_size += 0x10 + 0x04 * channels + 0x04; //todo v6 has extra 0x08?
header_size += header_samples * channels * sizeof(sample);
return header_samples + ima_bytes_to_samples(bytes - header_size, channels);
}

View File

@ -351,6 +351,7 @@ static const char* extension_list[] = {
"sb6",
"sb7",
"sbr",
"sbv",
"sm0",
"sm1",
"sm2",
@ -485,6 +486,7 @@ static const char* extension_list[] = {
"wv6",
"wve",
"wvs",
"wvx",
"x",
"xa",
@ -1134,10 +1136,9 @@ static const meta_info meta_info_list[] = {
{meta_A2M, "Artificial Mind & Movement A2M header"},
{meta_AHV, "Amuze AHV header"},
{meta_MSV, "Sony MultiStream MSV header"},
{meta_SDF_PS2, "Beyond Reality PS2 SDF header"},
{meta_SDF, "Beyond Reality SDF header"},
{meta_SVG, "High Voltage SVG header"},
{meta_VIS, "Konami VIS header"},
{meta_SDF_3DS, "Beyond Reality 3DS SDF header"},
{meta_VAI, "Asobo Studio .VAI header"},
{meta_AIF_ASOBO, "Asobo Studio .AIF header"},
{meta_AO, "AlphaOgg .AO header"},

View File

@ -44,7 +44,5 @@ void block_update_mul(off_t block_offset, VGMSTREAM * vgmstream) {
for (i = 0; i < vgmstream->channels; i++) {
vgmstream->ch[i].offset = block_offset + block_header + data_header + vgmstream->current_block_size*i;
//VGM_LOG("ch%i of=%lx\n", i, vgmstream->ch[i].offset);
}
//getchar();
}

View File

@ -272,6 +272,10 @@
RelativePath=".\meta\sqex_scd_streamfile.h"
>
</File>
<File
RelativePath=".\meta\ubi_bao_streamfile.h"
>
</File>
<File
RelativePath=".\meta\ubi_sb_streamfile.h"
>

View File

@ -110,6 +110,7 @@
<ClInclude Include="meta\vsv_streamfile.h" />
<ClInclude Include="meta\opus_interleave_streamfile.h" />
<ClInclude Include="meta\sqex_scd_streamfile.h" />
<ClInclude Include="meta\ubi_bao_streamfile.h" />
<ClInclude Include="meta\ubi_sb_streamfile.h" />
<ClInclude Include="meta\ubi_lyn_ogg_streamfile.h" />
<ClInclude Include="meta\meta.h" />

View File

@ -104,6 +104,9 @@
<ClInclude Include="meta\sqex_scd_streamfile.h">
<Filter>meta\Header Files</Filter>
</ClInclude>
<ClInclude Include="meta\ubi_bao_streamfile.h">
<Filter>meta\Header Files</Filter>
</ClInclude>
<ClInclude Include="meta\ubi_sb_streamfile.h">
<Filter>meta\Header Files</Filter>
</ClInclude>

View File

@ -768,8 +768,7 @@ VGMSTREAM * init_vgmstream_ahv(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_msv(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf_ps2(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf_3ds(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_sdf(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_svg(STREAMFILE *streamFile);

View File

@ -279,8 +279,11 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) {
* .xsew: Mega Man X Legacy Collections (PC)
* .adpcm: Angry Birds Transformers (Android)
* .adw: Dead Rising 2 (PC)
* .wd: Genma Onimusha (Xbox) voices */
if ( check_extensions(streamFile, "wav,lwav,xwav,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd") ) {
* .wd: Genma Onimusha (Xbox) voices
* (extensionless): Myst III (Xbox)
* .sbv: Spongebob Squarepants - The Movie (PC)
* .wvx: Godzilla - Destroy All Monsters Melee (Xbox) */
if ( check_extensions(streamFile, "wav,lwav,xwav,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv") ) {
;
}
else if ( check_extensions(streamFile, "mwv") ) {

View File

@ -1,90 +1,93 @@
#include "meta.h"
#include "../coding/coding.h"
/* SDF - from Beyond Reality games [Agent Hugo - Lemoon Twist (PS2)] */
VGMSTREAM * init_vgmstream_sdf_ps2(STREAMFILE *streamFile) {
/* SDF - from Beyond Reality games */
VGMSTREAM * init_vgmstream_sdf(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
int loop_flag, channel_count, sample_rate, interleave, coefs_offset;
/* checks */
if ( !check_extensions(streamFile,"sdf") )
if (!check_extensions(streamFile,"sdf"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x53444600) /* "SDF\0" */
goto fail;
if (read_32bitBE(0x04,streamFile) != 0x03000000) /* version? */
goto fail;
start_offset = 0x18;
data_size = get_streamfile_size(streamFile) - start_offset;
if (read_32bitLE(0x08,streamFile) != data_size)
goto fail;
data_size = read_32bitLE(0x08,streamFile);
start_offset = get_streamfile_size(streamFile) - data_size;
channel_count = read_32bitLE(0x10,streamFile);
loop_flag = 0; /* all files have loop flags but simply fade out normally and repeat */
switch(start_offset) {
case 0x18: /* Agent Hugo - Lemoon Twist (PS2)*/
sample_rate = read_32bitLE(0x0c,streamFile);
channel_count = read_32bitLE(0x10,streamFile);
interleave = read_32bitLE(0x14,streamFile);
break;
case 0x78: /* Gummy Bears Mini Golf (3DS) */
sample_rate = read_32bitLE(0x10,streamFile);
channel_count = read_32bitLE(0x14,streamFile);
interleave = read_32bitLE(0x18,streamFile);
coefs_offset = 0x1c;
break;
case 0x84: /* Mr. Bean's Wacky World (Wii) */
sample_rate = read_32bitLE(0x10,streamFile);
channel_count = read_32bitLE(0x14,streamFile);
interleave = read_32bitLE(0x18,streamFile);
data_size = read_32bitLE(0x20,streamFile); /* usable size */
coefs_offset = 0x28;
break;
default:
goto fail;
}
loop_flag = 1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SDF_PS2;
vgmstream->sample_rate = read_32bitLE(0x0c,streamFile);
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);
vgmstream->meta_type = meta_SDF;
vgmstream->sample_rate = sample_rate;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
/* SDF - from Beyond Reality games [Gummy Bears Mini Golf (3DS)] */
VGMSTREAM * init_vgmstream_sdf_3ds(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
/* checks */
if ( !check_extensions(streamFile,"sdf") )
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x53444600) /* "SDF\0" */
goto fail;
if (read_32bitBE(0x04,streamFile) != 0x03000000) /* version? */
goto fail;
start_offset = 0x78; /* assumed */
data_size = get_streamfile_size(streamFile) - start_offset;
if (read_32bitLE(0x08,streamFile) != data_size)
goto fail;
channel_count = read_32bitLE(0x14,streamFile);
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SDF_3DS;
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
vgmstream->num_samples = dsp_bytes_to_samples(data_size,channel_count);
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = data_size / channel_count;
dsp_read_coefs_le(vgmstream,streamFile,0x1c,0x2e);
//todo: there be hist around 0x3c
switch(start_offset) {
case 0x18:
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
vgmstream->num_samples = ps_bytes_to_samples(data_size,channel_count);
break;
case 0x78:
case 0x84:
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
if (vgmstream->interleave_block_size == 0) /* Gummy Bears Mini Golf */
vgmstream->interleave_block_size = data_size / channel_count;
vgmstream->num_samples = dsp_bytes_to_samples(data_size,channel_count);
dsp_read_coefs_le(vgmstream, streamFile, coefs_offset+0x00,0x2e);
dsp_read_hist_le (vgmstream, streamFile, coefs_offset+0x24,0x2e);
break;
default:
goto fail;
}
/* most songs simply repeat; don't loop if too short (in seconds) */
if (vgmstream->num_samples > 10*sample_rate) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
#ifndef _UBI_BAO_STREAMFILE_H_
#define _UBI_BAO_STREAMFILE_H_
//todo fix dupe code, but would be nice to keep it all in separate compilation units
#include "ubi_sb_streamfile.h"
static STREAMFILE* setup_ubi_bao_streamfile(STREAMFILE *streamFile, off_t stream_offset, size_t stream_size, int layer_number, int layer_count, int big_endian) {
return setup_ubi_sb_streamfile(streamFile, stream_offset, stream_size, layer_number, layer_count, big_endian);
}
#endif /* _UBI_BAO_STREAMFILE_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -345,7 +345,7 @@ static STREAMFILE* setup_ubi_sb_streamfile(STREAMFILE *streamFile, off_t stream_
if (!new_streamFile) goto fail;
temp_streamFile = new_streamFile;
new_streamFile = open_io_streamfile(temp_streamFile, &io_data,io_data_size, ubi_sb_io_read,ubi_sb_io_size);
new_streamFile = open_io_streamfile(new_streamFile, &io_data,io_data_size, ubi_sb_io_read,ubi_sb_io_size);
if (!new_streamFile) goto fail;
temp_streamFile = new_streamFile;

View File

@ -430,10 +430,9 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_a2m,
init_vgmstream_ahv,
init_vgmstream_msv,
init_vgmstream_sdf_ps2,
init_vgmstream_sdf,
init_vgmstream_svg,
init_vgmstream_vis,
init_vgmstream_sdf_3ds,
init_vgmstream_vai,
init_vgmstream_aif_asobo,
init_vgmstream_ao,
@ -2280,14 +2279,25 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
"encoding: ");
concatn(length,desc,temp);
switch (vgmstream->coding_type) {
//todo codec bugs with layout inside layouts (ex. TXTP)
#ifdef VGM_USE_FFMPEG
case coding_FFmpeg: {
ffmpeg_codec_data *data = (ffmpeg_codec_data *)vgmstream->codec_data;
if (!data && vgmstream->layout_data) {
ffmpeg_codec_data *data = NULL;
if (vgmstream->layout_type == layout_layered) {
layered_layout_data* layout_data = vgmstream->layout_data;
if (layout_data->layers[0]->coding_type == coding_FFmpeg)
data = layout_data->layers[0]->codec_data;
}
else if (vgmstream->layout_type == layout_segmented) {
segmented_layout_data* layout_data = vgmstream->layout_data;
if (layout_data->segments[0]->coding_type == coding_FFmpeg)
data = layout_data->segments[0]->codec_data;
}
else {
data = vgmstream->codec_data;
}
if (data) {
if (data->codec && data->codec->long_name) {
@ -2637,7 +2647,7 @@ int get_vgmstream_average_bitrate(VGMSTREAM * vgmstream) {
return get_vgmstream_average_bitrate_from_size(vgmstream->stream_size, sample_rate, length_samples);
}
//todo bitrate bugs with layout inside layouts (ex. TXTP)
/* make a list of used streamfiles (repeats will be filtered below) */
if (vgmstream->layout_type==layout_segmented) {
segmented_layout_data *data = (segmented_layout_data *) vgmstream->layout_data;
@ -2786,7 +2796,6 @@ int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t s
if (!file) goto fail;
}
VGM_LOG("ch%i offset=%lx\n", ch,offset);
vgmstream->ch[ch].streamfile = file;
vgmstream->ch[ch].channel_start_offset =
vgmstream->ch[ch].offset = offset;

View File

@ -687,11 +687,10 @@ typedef enum {
meta_A2M, /* Scooby-Doo! Unmasked (PS2) */
meta_AHV, /* Headhunter (PS2) */
meta_MSV, /* Fight Club (PS2) */
meta_SDF_PS2, /* Agent Hugo - Lemoon Twist (PS2) */
meta_SDF,
meta_SVG, /* Hunter - The Reckoning - Wayward (PS2) */
meta_VIS, /* AirForce Delta Strike (PS2) */
meta_VAI, /* Ratatouille (GC) */
meta_SDF_3DS, /* Gummy Bears Mini Golf (3DS) */
meta_AIF_ASOBO, /* Ratatouille (PC) */
meta_AO, /* Cloudphobia (PC) */
meta_APC, /* MegaRace 3 (PC) */