Merge pull request #467 from NicknineTheEagle/ubi-sb

ubi sb
This commit is contained in:
bnnm 2019-09-08 20:10:18 +02:00 committed by GitHub
commit c0e5267ce5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 353 additions and 264 deletions

View File

@ -73,7 +73,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..;../ext_libs/Getopt;../ext_includes;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_ATRAC9;VGM_USE_CELT;_DEBUG;_WINDOWS;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>

View File

@ -58,7 +58,6 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FloatingPointModel>Precise</FloatingPointModel>

View File

@ -72,7 +72,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..;../ext_includes;$(DependenciesDir)/WTL/Include;$(DependenciesDir)/foobar/foobar2000/SDK;$(DependenciesDir)/foobar/foobar2000/shared;$(DependenciesDir)/foobar/foobar2000;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_ATRAC9;VGM_USE_CELT;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@ -116,6 +115,7 @@
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)..\version.bat" "$(ProjectDir)..\version.h" VERSION</Command>

View File

@ -1197,40 +1197,111 @@ static const meta_info meta_info_list[] = {
{meta_PSF, "Pivotal PSF header"},
{meta_DSP_ITL_i, "Infernal .ITL DSP header"},
{meta_IMA, "Blitz Games .IMA header"},
{meta_XMV_VALVE, "Valve XMV header"},
};
const char * get_vgmstream_coding_description(coding_t coding_type) {
void get_vgmstream_coding_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
int i, list_length;
const char *description;
list_length = sizeof(coding_info_list) / sizeof(coding_info);
for (i=0; i < list_length; i++) {
if (coding_info_list[i].type == coding_type)
return coding_info_list[i].description;
/* we need to recurse down because of FFmpeg */
if (vgmstream->layout_type == layout_layered) {
layered_layout_data* layout_data = vgmstream->layout_data;
get_vgmstream_coding_description(layout_data->layers[0], out, out_size);
return;
} else if (vgmstream->layout_type == layout_segmented) {
segmented_layout_data* layout_data = vgmstream->layout_data;
get_vgmstream_coding_description(layout_data->segments[0], out, out_size);
return;
}
return NULL;
description = "CANNOT DECODE";
switch (vgmstream->coding_type) {
#ifdef VGM_USE_FFMPEG
case coding_FFmpeg:
{
ffmpeg_codec_data *data = vgmstream->codec_data;
if (data) {
if (data->codec && data->codec->long_name) {
description = data->codec->long_name;
} else if (data->codec && data->codec->name) {
description = data->codec->name;
} else {
description = "FFmpeg (unknown codec)";
}
} else {
description = "FFmpeg";
}
break;
}
#endif
default:
list_length = sizeof(coding_info_list) / sizeof(coding_info);
for (i = 0; i < list_length; i++) {
if (coding_info_list[i].type == vgmstream->coding_type)
description = coding_info_list[i].description;
}
break;
}
strncpy(out, description, out_size);
}
const char * get_vgmstream_layout_description(layout_t layout_type) {
const char * get_vgmstream_layout_name(layout_t layout_type) {
int i, list_length;
list_length = sizeof(layout_info_list) / sizeof(layout_info);
for (i=0; i < list_length; i++) {
for (i = 0; i < list_length; i++) {
if (layout_info_list[i].type == layout_type)
return layout_info_list[i].description;
}
return NULL;
}
const char * get_vgmstream_meta_description(meta_t meta_type) {
void get_vgmstream_layout_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
char temp[256];
VGMSTREAM* vgmstreamsub = NULL;
const char* description;
description = get_vgmstream_layout_name(vgmstream->layout_type);
if (!description) description = "INCONCEIVABLE";
if (vgmstream->layout_type == layout_layered) {
vgmstreamsub = ((layered_layout_data*)vgmstream->layout_data)->layers[0];
snprintf(temp, sizeof(temp), "%s (%i layers)", description, ((layered_layout_data*)vgmstream->layout_data)->layer_count);
} else if (vgmstream->layout_type == layout_segmented) {
snprintf(temp, sizeof(temp), "%s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
vgmstreamsub = ((segmented_layout_data*)vgmstream->layout_data)->segments[0];
} else {
snprintf(temp, sizeof(temp), "%s", description);
}
strncpy(out, temp, out_size);
/* layouts can contain layouts infinitely let's leave it at one level deep (most common) */
/* TODO: improve this somehow */
if (vgmstreamsub && vgmstreamsub->layout_type == layout_layered) {
description = get_vgmstream_layout_name(vgmstreamsub->layout_type);
snprintf(temp, sizeof(temp), " + %s (%i layers)", description, ((layered_layout_data*)vgmstreamsub->layout_data)->layer_count);
concatn(out_size, out, temp);
} else if (vgmstreamsub && vgmstreamsub->layout_type == layout_segmented) {
description = get_vgmstream_layout_name(vgmstreamsub->layout_type);
snprintf(temp, sizeof(temp), " + %s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
concatn(out_size, out, temp);
}
}
void get_vgmstream_meta_description(VGMSTREAM *vgmstream, char *out, size_t out_size) {
int i, list_length;
const char *description;
description = "THEY SHOULD HAVE SENT A POET";
list_length = sizeof(meta_info_list) / sizeof(meta_info);
for (i=0; i < list_length; i++) {
if (meta_info_list[i].type == meta_type)
return meta_info_list[i].description;
if (meta_info_list[i].type == vgmstream->meta_type)
description = meta_info_list[i].description;
}
return NULL;
strncpy(out, description, out_size);
}

View File

@ -60,7 +60,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../ext_includes;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_ATRAC9;VGM_USE_CELT;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@ -216,6 +215,7 @@
<ClCompile Include="meta\x360_cxs.c" />
<ClCompile Include="meta\x360_tra.c" />
<ClCompile Include="formats.c" />
<ClCompile Include="meta\xmv_valve.c" />
<ClCompile Include="mixing.c" />
<ClCompile Include="plugins.c" />
<ClCompile Include="meta\ps2_va3.c" />

View File

@ -1630,5 +1630,8 @@
<ClCompile Include="meta\rad.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\xmv_valve.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -862,4 +862,6 @@ VGMSTREAM * init_vgmstream_nub_xma(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_nub_idsp(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_nub_is14(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_xmv_valve(STREAMFILE * streamFile);
#endif /*_META_H*/

View File

@ -36,6 +36,7 @@ typedef struct {
int audio_external_and;
int audio_loop_and;
int audio_group_and;
int num_codec_flags;
int audio_has_internal_names;
size_t audio_interleave;
int audio_fix_psx_samples;
@ -1166,21 +1167,25 @@ static int parse_type_audio(ubi_sb_header * sb, off_t offset, STREAMFILE* stream
goto fail;
}
if (sb->cfg.audio_external_flag) {
if (sb->cfg.audio_external_flag && sb->cfg.audio_external_and) {
sb->is_external = (read_32bit(offset + sb->cfg.audio_external_flag, streamFile) & sb->cfg.audio_external_and);
}
if (sb->cfg.audio_group_id) {
sb->group_id = read_32bit(offset + sb->cfg.audio_group_id, streamFile);
if (sb->cfg.audio_group_and) sb->group_id &= sb->cfg.audio_group_and;
if (sb->cfg.audio_group_id && sb->cfg.audio_group_and) {
/* probably means "SW decoded" */
sb->group_id = read_32bit(offset + sb->cfg.audio_group_id, streamFile);
if (sb->cfg.audio_group_and) sb->group_id &= sb->cfg.audio_group_and;
/* normalize bitflag, known groups are only id 0/1 (if needed could calculate
* shift-right value here, based on cfg.audio_group_and first 1-bit) */
if (sb->group_id > 1)
sb->group_id = 1;
} else {
/* old group flag (HW decoded?) */
sb->group_id = (int)!(sb->stream_type & 0x01);
}
if (sb->cfg.audio_loop_flag) {
if (sb->cfg.audio_loop_flag && sb->cfg.audio_loop_and) {
sb->loop_flag = (read_32bit(offset + sb->cfg.audio_loop_flag, streamFile) & sb->cfg.audio_loop_and);
}
@ -1450,153 +1455,145 @@ static int parse_stream_codec(ubi_sb_header * sb) {
if (sb->type == UBI_SEQUENCE)
return 1;
/* in early versions, this is a bitfield with either 1 or 2 rightmost bits being flags */
sb->stream_type >>= sb->cfg.num_codec_flags;
if (sb->cfg.default_codec_for_group0 && sb->type == UBI_AUDIO && sb->group_id == 0) {
/* early Xbox games contain garbage in stream_type field in this case, it seems that 0x00 is assumed */
sb->stream_type = 0x00;
}
/* guess codec */
switch (sb->stream_type) {
case 0x00: /* platform default (rarely external) */
switch (sb->platform) {
case UBI_PC:
sb->codec = RAW_PCM;
break;
case UBI_PS2:
if (sb->stream_type == 0x00) {
switch (sb->platform) {
case UBI_PC:
sb->codec = RAW_PCM;
break;
case UBI_PS2:
sb->codec = RAW_PSX;
break;
case UBI_PSP:
if (sb->is_psp_old)
sb->codec = FMT_VAG;
else
sb->codec = RAW_PSX;
break;
case UBI_PSP:
if (sb->is_psp_old)
sb->codec = FMT_VAG;
else
sb->codec = RAW_PSX;
break;
case UBI_XBOX:
sb->codec = RAW_XBOX;
break;
case UBI_GC:
case UBI_WII:
sb->codec = RAW_DSP;
break;
case UBI_X360:
sb->codec = RAW_XMA1;
break;
break;
case UBI_XBOX:
sb->codec = RAW_XBOX;
break;
case UBI_GC:
case UBI_WII:
sb->codec = RAW_DSP;
break;
case UBI_X360:
sb->codec = RAW_XMA1;
break;
#if 0
case UBI_PS3: /* assumed, but no games seem to use it */
sb->codec = RAW_AT3;
break;
case UBI_PS3: /* assumed, but no games seem to use it */
sb->codec = RAW_AT3;
break;
#endif
case UBI_3DS:
sb->codec = FMT_CWAV;
break;
default:
VGM_LOG("UBI SB: unknown internal format\n");
goto fail;
}
break;
case UBI_3DS:
sb->codec = FMT_CWAV;
break;
default:
VGM_LOG("UBI SB: unknown internal format\n");
goto fail;
}
} else if (sb->version == 0x00000000) {
/* really old version predating SBx and SMx formats */
/* Rayman 2: The Great Escape */
/* Tonic Trouble */
/* Donald Duck: Goin' Quackers */
/* Disney's Dinosaur */
case 0x01:
switch (sb->version) {
case 0x00000003: /* Donald Duck: Goin' Quackers */
case 0x00000004: /* Myst III: Exile */
case 0x00000007: /* Splinter Cell */
case 0x0000000D: /* Prince of Persia: The Sands of Time Demo */
switch (sb->platform) {
case UBI_PS2: sb->codec = RAW_PSX; break;
case UBI_GC: sb->codec = RAW_DSP; break;
case UBI_PC: sb->codec = RAW_PCM; break;
case UBI_XBOX: sb->codec = RAW_XBOX; break;
default: VGM_LOG("UBI SB: unknown old internal format\n"); goto fail;
}
break;
default:
sb->codec = RAW_PCM; /* uncommon, ex. Wii/PSP/3DS */
break;
}
break;
switch (sb->stream_type) {
case 0x01:
sb->codec = FMT_MPDX;
break;
case 0x02:
sb->codec = FMT_APM;
break;
case 0x02:
switch (sb->version) {
case 0x00000000: /* Tonic Trouble Special Edition */
sb->codec = FMT_MPDX;
break;
case 0x00000007: /* Splinter Cell, Splinter Cell: Pandora Tomorrow */
case 0x0000000D: /* Prince of Persia: The Sands of Time Demo */
case 0x000A0000:
case 0x000A0002:
case 0x00120012: /* Myst IV: Exile */
//todo splinter Cell Essentials
sb->codec = UBI_ADPCM;
break;
default:
sb->codec = RAW_PSX; /* PS3 */
break;
}
break;
default:
VGM_LOG("Unknown stream_type %02x for version %08x\n", sb->stream_type, sb->version);
goto fail;
}
} else if (sb->version < 0x000A0000) {
switch (sb->stream_type) {
case 0x01:
sb->codec = UBI_ADPCM;
break;
case 0x03:
sb->codec = UBI_IMA; /* Ubi IMA v3+ (versions handled in decoder) */
break;
case 0x02:
sb->codec = UBI_IMA; /* Ubi IMA v2/v3 */
break;
case 0x04:
switch (sb->version) {
case 0x00000000: /* Rayman 2, Tonic Trouble */
sb->codec = FMT_APM;
break;
case 0x00000007: /* Splinter Cell, Splinter Cell: Pandora Tomorrow */
sb->codec = UBI_IMA;
break;
default:
sb->codec = FMT_OGG; /* later PC games */
break;
}
break;
default:
VGM_LOG("Unknown stream_type %02x for version %08x\n", sb->stream_type, sb->version);
goto fail;
}
} else {
switch (sb->stream_type) {
case 0x01:
sb->codec = RAW_PCM; /* uncommon, ex. Wii/PSP/3DS */
break;
case 0x05:
switch (sb->platform) {
case UBI_X360:
sb->codec = FMT_XMA1;
break;
case UBI_PS3:
case UBI_PSP:
sb->codec = FMT_AT3;
break;
default:
VGM_LOG("UBI SB: unknown codec for stream_type %x\n", sb->stream_type);
goto fail;
}
break;
case 0x02:
switch (sb->platform) {
case UBI_PS3:
sb->codec = RAW_PSX; /* PS3 */
break;
case UBI_PSP:
/* TODO: IMA using Ubisoft ADPCM frame layout [Splinter Cell: Essentials (PSP)] */
VGM_LOG("Unimplemented custom IMA codec.\n");
goto fail;
default:
sb->codec = UBI_ADPCM;
break;
}
break;
case 0x06:
switch (sb->version) {
case 0x00000003: /* Batman: Vengeance (PC) */
sb->codec = UBI_ADPCM;
break;
default:
sb->codec = RAW_PSX; /* later PSP and PS3(?) games */
break;
}
break;
case 0x03:
sb->codec = UBI_IMA; /* Ubi IMA v3+ (versions handled in decoder) */
break;
case 0x07:
sb->codec = RAW_AT3; /* PS3 games */
break;
case 0x04:
sb->codec = FMT_OGG; /* later PC games */
break;
case 0x08:
switch (sb->version) {
case 0x00000003: /* Donald Duck: Goin' Quackers */
case 0x00000004: /* Myst III: Exile */
sb->codec = UBI_IMA; /* Ubi IMA v2/v3 */
break;
default:
sb->codec = FMT_AT3;
break;
}
break;
case 0x05:
switch (sb->platform) {
case UBI_X360:
sb->codec = FMT_XMA1;
break;
case UBI_PS3:
case UBI_PSP:
sb->codec = FMT_AT3;
break;
default:
VGM_LOG("UBI SB: unknown codec for stream_type %x\n", sb->stream_type);
goto fail;
}
break;
default:
VGM_LOG("UBI SB: unknown stream_type %x\n", sb->stream_type);
goto fail;
case 0x06:
sb->codec = RAW_PSX; /* later PSP and PS3(?) games */
break;
case 0x07:
sb->codec = RAW_AT3; /* PS3 */
break;
case 0x08:
sb->codec = FMT_AT3;
break;
default:
VGM_LOG("Unknown stream_type %02x\n", sb->stream_type);
goto fail;
}
}
return 1;
@ -1614,11 +1611,6 @@ static int parse_offsets(ubi_sb_header * sb, STREAMFILE *streamFile) {
VGM_ASSERT(!sb->is_map && sb->section3_num > 2, "UBI SB: section3 > 2 found\n");
if (!(sb->cfg.audio_group_id || sb->is_map) && sb->section3_num > 1) {
VGM_LOG("UBI SB: unexpected number of internal stream groups %i\n", sb->section3_num);
goto fail;
}
if (sb->is_external)
return 1;
@ -1655,11 +1647,6 @@ static int parse_offsets(ubi_sb_header * sb, STREAMFILE *streamFile) {
int index = read_32bit(table_offset + 0x08 * j + 0x00, streamFile) & 0x0000FFFF;
if (index == sb->header_index) {
if (!sb->cfg.audio_group_id && table2_num > 1) {
VGM_LOG("UBI SB: unexpected number of internal stream map groups %i at %x\n", table2_num, (uint32_t)table2_offset);
goto fail;
}
sb->stream_offset = read_32bit(table_offset + 0x08 * j + 0x04, streamFile);
for (k = 0; k < table2_num; k++) {
uint32_t id = read_32bit(table2_offset + 0x10 * k + 0x00, streamFile);
@ -1685,7 +1672,7 @@ static int parse_offsets(ubi_sb_header * sb, STREAMFILE *streamFile) {
sounds_offset = align_size_to_block(sounds_offset, 0x10);
sb->stream_offset = sounds_offset + sb->stream_offset;
if (sb->cfg.audio_group_id && sb->section3_num > 1) { /* maybe should always test this? */
if (sb->section3_num > 1) { /* maybe should always test this? */
for (i = 0; i < sb->section3_num; i++) {
off_t offset = sb->section3_offset + sb->cfg.section3_entry_size * i;
@ -2096,8 +2083,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
sb->cfg.random_extra_offset = 0x10;
//sb->cfg.random_extra_size = 0x0c;
}
else if (sb->version <= 0x00000007) {
} else if (sb->version <= 0x00000007) {
sb->cfg.audio_stream_size = 0x0c;
sb->cfg.audio_extra_offset = 0x10;
sb->cfg.audio_stream_offset = 0x14;
@ -2105,8 +2091,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
sb->cfg.sequence_extra_offset = 0x10;
sb->cfg.layer_extra_offset = 0x10;
}
else {
} else {
sb->cfg.audio_stream_size = 0x08;
sb->cfg.audio_extra_offset = 0x0c;
sb->cfg.audio_stream_offset = 0x10;
@ -2116,6 +2101,14 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
sb->cfg.layer_extra_offset = 0x0c;
}
if (sb->version == 0x00000000 || sb->version == 0x00000200) {
sb->cfg.num_codec_flags = 1;
} else if (sb->version <= 0x00000004) {
sb->cfg.num_codec_flags = 2;
} else if (sb->version < 0x000A0000) {
sb->cfg.num_codec_flags = 1;
}
sb->allowed_types[0x01] = 1;
sb->allowed_types[0x05] = 1;
sb->allowed_types[0x0c] = 1;
@ -2173,7 +2166,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000000 && sb->platform == UBI_PC && is_ttse_pc) {
config_sb_entry(sb, 0x20, 0x5c);
config_sb_audio_fs(sb, 0x2c, 0x2c, 0x30); /* no group id */
config_sb_audio_fs(sb, 0x2c, 0x00, 0x30);
config_sb_audio_hs(sb, 0x42, 0x3c, 0x38, 0x38, 0x48, 0x44);
sb->cfg.audio_has_internal_names = 1;
@ -2195,7 +2188,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000000 && sb->platform == UBI_PC) {
config_sb_entry(sb, 0x20, 0x5c);
config_sb_audio_fs(sb, 0x2c, 0x2c, 0x30); /* no group id */
config_sb_audio_fs(sb, 0x2c, 0x00, 0x30);
config_sb_audio_hs(sb, 0x42, 0x3c, 0x34, 0x34, 0x48, 0x44);
sb->cfg.audio_has_internal_names = 1;
@ -2216,7 +2209,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
(sb->version == 0x00000003 && sb->platform == UBI_XBOX)) {
config_sb_entry(sb, 0x40, 0x68);
config_sb_audio_fs(sb, 0x30, 0x30, 0x34); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x30, 0x00, 0x34);
config_sb_audio_hs(sb, 0x52, 0x4c, 0x38, 0x40, 0x58, 0x54);
sb->cfg.audio_has_internal_names = 1;
@ -2233,7 +2226,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000003 && sb->platform == UBI_GC) {
config_sb_entry(sb, 0x40, 0x6c);
config_sb_audio_fs(sb, 0x30, 0x30, 0x34); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x30, 0x00, 0x34);
config_sb_audio_hs(sb, 0x56, 0x50, 0x48, 0x48, 0x5c, 0x58); /* 0x38 may be num samples too? */
config_sb_sequence(sb, 0x2c, 0x1c);
@ -2263,6 +2256,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
}
#endif
#if 0
//todo group flags and maybe num_samples for sfx are off
/* Myst III: Exile (2001)(PS2)-map */
if (sb->version == 0x00000004 && sb->platform == UBI_PS2) {
@ -2275,13 +2269,14 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
config_sb_sequence(sb, 0x2c, 0x24);
return 1;
}
#endif
/* Splinter Cell (2002)(PC)-map */
/* Splinter Cell: Pandora Tomorrow (2004)(PC)-map */
if (sb->version == 0x00000007 && sb->platform == UBI_PC) {
config_sb_entry(sb, 0x58, 0x80);
config_sb_audio_fs(sb, 0x28, 0x28, 0x2c); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x28, 0x00, 0x2c);
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c);
sb->cfg.audio_has_internal_names = 1;
@ -2297,7 +2292,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000007 && sb->platform == UBI_XBOX) {
config_sb_entry(sb, 0x58, 0x78);
config_sb_audio_fs(sb, 0x28, 0x28, 0x2c); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x28, 0x00, 0x2c);
config_sb_audio_hs(sb, 0x4a, 0x44, 0x30, 0x38, 0x50, 0x4c);
sb->cfg.audio_has_internal_names = 1;
@ -2325,7 +2320,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000007 && sb->platform == UBI_PS2) {
config_sb_entry(sb, 0x40, 0x70);
config_sb_audio_fb(sb, 0x1c, (1 << 2), (1 << 3), (1 << 4));
config_sb_audio_fb(sb, 0x1c, (1 << 2), 0, (1 << 4));
config_sb_audio_hs(sb, 0x24, 0x28, 0x34, 0x3c, 0x44, 0x6c); /* num_samples may be null */
config_sb_sequence(sb, 0x2c, 0x30);
@ -2346,7 +2341,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x00000007 && sb->platform == UBI_GC) {
config_sb_entry(sb, 0x58, 0x78);
config_sb_audio_fs(sb, 0x24, 0x24, 0x28); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x24, 0x00, 0x28);
config_sb_audio_hs(sb, 0x4a, 0x44, 0x2c, 0x34, 0x50, 0x4c);
config_sb_sequence(sb, 0x2c, 0x34);
@ -2365,7 +2360,7 @@ static int config_sb_version(ubi_sb_header * sb, STREAMFILE *streamFile) {
if (sb->version == 0x0000000D && sb->platform == UBI_XBOX) {
config_sb_entry(sb, 0x5c, 0x74);
config_sb_audio_fs(sb, 0x24, 0x24, 0x28); /* no group id? use external flag */
config_sb_audio_fs(sb, 0x24, 0x00, 0x28);
config_sb_audio_hs(sb, 0x46, 0x40, 0x2c, 0x34, 0x4c, 0x48);
sb->cfg.audio_has_internal_names = 1;
return 1;

96
src/meta/xmv_valve.c Normal file
View File

@ -0,0 +1,96 @@
#include "meta.h"
#include "../coding/coding.h"
/* .360.WAV - from Valve games running on Source Engine [The Orange Box (X360)] */
VGMSTREAM* init_vgmstream_xmv_valve(STREAMFILE* streamFile) {
VGMSTREAM* vgmstream = NULL;
int32_t loop_start;
uint32_t start_offset, data_size, sample_rate, num_samples;
uint16_t loop_block, loop_start_skip, loop_end_skip;
uint8_t format, freq_mode, channels;
int loop_flag;
/* checks */
if (!check_extensions(streamFile, "wav,lwav"))
goto fail;
/* check header magic */
if (read_32bitBE(0x00, streamFile) != 0x58575620) /* "XMV " */
goto fail;
/* only version 4 is known */
if (read_32bitBE(0x04, streamFile) != 0x04)
goto fail;
start_offset = read_32bitBE(0x10, streamFile);
data_size = read_32bitBE(0x14, streamFile);
num_samples = read_32bitBE(0x18, streamFile);
loop_start = read_32bitBE(0x1c, streamFile);
loop_block = read_16bitBE(0x20, streamFile);
loop_start_skip = read_16bitBE(0x22, streamFile);
loop_end_skip = read_16bitBE(0x24, streamFile);
format = read_8bit(0x28, streamFile);
freq_mode = read_8bit(0x2a, streamFile);
channels = read_8bit(0x2b, streamFile);
switch (freq_mode) {
case 0x00: sample_rate = 11025; break;
case 0x01: sample_rate = 22050; break;
case 0x02: sample_rate = 44100; break;
default: goto fail;
}
loop_flag = (loop_start != -1);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_XMV_VALVE;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = num_samples - loop_end_skip;
switch (format) {
case 0x00: /* PCM */
vgmstream->coding_type = coding_PCM16BE; /* assumed BE */
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x02;
break;
#ifdef VGM_USE_FFMPEG
case 0x01: { /* XMA */
ffmpeg_codec_data* ffmpeg_data;
uint8_t buf[0x100];
int block_count, block_size;
size_t bytes;
block_size = 0x800;
block_count = data_size / block_size;
bytes = ffmpeg_make_riff_xma2(buf, 0x100, num_samples, data_size, channels, sample_rate, block_count, block_size);
ffmpeg_data = init_ffmpeg_header_offset(streamFile, buf, bytes, start_offset, data_size);
if (!ffmpeg_data) goto fail;
vgmstream->codec_data = ffmpeg_data;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
xma_fix_raw_samples(vgmstream, streamFile, start_offset, data_size, 0, 1, 1);
break;
}
#endif
case 0x02: /* ADPCM, not actually implemented */
default:
goto fail;
}
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -476,6 +476,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_nub_xma,
init_vgmstream_nub_idsp,
init_vgmstream_nub_is14,
init_vgmstream_xmv_valve,
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
@ -2298,7 +2299,6 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
#define TEMPSIZE (256+32)
char temp[TEMPSIZE];
const char* description;
double time_mm, time_ss, seconds;
if (!vgmstream) {
@ -2378,83 +2378,14 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
snprintf(temp,TEMPSIZE, "encoding: ");
concatn(length,desc,temp);
switch (vgmstream->coding_type) {
#ifdef VGM_USE_FFMPEG
case coding_FFmpeg: {
//todo codec bugs with layout inside layouts (ex. TXTP)
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) {
snprintf(temp,TEMPSIZE, "%s",data->codec->long_name);
} else if (data->codec && data->codec->name) {
snprintf(temp,TEMPSIZE, "%s",data->codec->name);
} else {
snprintf(temp,TEMPSIZE, "FFmpeg (unknown codec)");
}
} else {
snprintf(temp,TEMPSIZE, "FFmpeg");
}
break;
}
#endif
default:
description = get_vgmstream_coding_description(vgmstream->coding_type);
if (!description) description = "CANNOT DECODE";
snprintf(temp,TEMPSIZE, "%s",description);
break;
}
get_vgmstream_coding_description(vgmstream, temp, TEMPSIZE);
concatn(length,desc,temp);
concatn(length,desc,"\n");
snprintf(temp,TEMPSIZE, "layout: ");
concatn(length,desc,temp);
{
VGMSTREAM* vgmstreamsub = NULL;
description = get_vgmstream_layout_description(vgmstream->layout_type);
if (!description) description = "INCONCEIVABLE";
if (vgmstream->layout_type == layout_layered) {
vgmstreamsub = ((layered_layout_data*)vgmstream->layout_data)->layers[0];
snprintf(temp,TEMPSIZE, "%s (%i layers)", description, ((layered_layout_data*)vgmstream->layout_data)->layer_count);
}
else if (vgmstream->layout_type == layout_segmented) {
snprintf(temp,TEMPSIZE, "%s (%i segments)", description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
vgmstreamsub = ((segmented_layout_data*)vgmstream->layout_data)->segments[0];
}
else {
snprintf(temp,TEMPSIZE, "%s",description);
}
concatn(length,desc,temp);
/* layouts can contain layouts infinitely let's leave it at one level deep (most common) */
if (vgmstreamsub && vgmstreamsub->layout_type == layout_layered) {
description = get_vgmstream_layout_description(vgmstreamsub->layout_type);
snprintf(temp,TEMPSIZE, " + %s (%i layers)",description, ((layered_layout_data*)vgmstreamsub->layout_data)->layer_count);
concatn(length,desc,temp);
}
else if (vgmstreamsub && vgmstreamsub->layout_type == layout_segmented) {
description = get_vgmstream_layout_description(vgmstreamsub->layout_type);
snprintf(temp,TEMPSIZE, " + %s (%i segments)",description, ((segmented_layout_data*)vgmstream->layout_data)->segment_count);
concatn(length,desc,temp);
}
}
get_vgmstream_layout_description(vgmstream, temp, TEMPSIZE);
concatn(length, desc, temp);
concatn(length,desc,"\n");
if (vgmstream->layout_type == layout_interleave && vgmstream->channels > 1) {
@ -2493,13 +2424,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
snprintf(temp,TEMPSIZE, "metadata from: ");
concatn(length,desc,temp);
switch (vgmstream->meta_type) {
default:
description = get_vgmstream_meta_description(vgmstream->meta_type);
if (!description) description = "THEY SHOULD HAVE SENT A POET";
snprintf(temp,TEMPSIZE, "%s", description);
break;
}
get_vgmstream_meta_description(vgmstream, temp, TEMPSIZE);
concatn(length,desc,temp);
concatn(length,desc,"\n");

View File

@ -710,6 +710,7 @@ typedef enum {
meta_PSF,
meta_DSP_ITL_i,
meta_IMA,
meta_XMV_VALVE,
} meta_t;
@ -1365,8 +1366,8 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream);
int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t start_offset);
/* Get description info */
const char * get_vgmstream_coding_description(coding_t coding_type);
const char * get_vgmstream_layout_description(layout_t layout_type);
const char * get_vgmstream_meta_description(meta_t meta_type);
void get_vgmstream_coding_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
void get_vgmstream_layout_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
void get_vgmstream_meta_description(VGMSTREAM *vgmstream, char *out, size_t out_size);
#endif

View File

@ -13,7 +13,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fdk-aac", "dependencies\fdk
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mp4v2", "dependencies\qaac\vcproject\mp4v2\mp4v2.vcxproj", "{86A064E2-C81B-4EEE-8BE0-A39A2E7C7C76}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "cli\vgmstream_cli.vcxproj", "{AF7D88A0-3CB1-4CD8-BAD1-0305EB996D69}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vgmstream_cli", "cli\vgmstream_cli.vcxproj", "{AF7D88A0-3CB1-4CD8-BAD1-0305EB996D69}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "in_vgmstream", "winamp\in_vgmstream.vcxproj", "{42D86561-8CE4-40F5-86CE-58C986B77502}"
EndProject

View File

@ -72,7 +72,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..;../ext_includes;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_ATRAC9;VGM_USE_CELT;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;VGM_WINAMP_UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
@ -152,4 +151,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -63,7 +63,6 @@
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..;../ext_includes;$(DependenciesDir)/qaac/mp4v2/include;$(DependenciesDir)/fdk-aac/libSYS/include;$(DependenciesDir)/fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;VGM_USE_VORBIS;VGM_USE_MPEG;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_ATRAC9;VGM_USE_CELT;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>

View File

@ -330,7 +330,7 @@ char * WINAPI xmplay_GetTags() {
/* main panel info text (short file info) */
void WINAPI xmplay_GetInfoText(char* format, char* length) {
int rate, samples, bps;
const char* fmt;
char fmt[128];
int t, tmin, tsec;
if (!format)
@ -341,7 +341,7 @@ void WINAPI xmplay_GetInfoText(char* format, char* length) {
rate = vgmstream->sample_rate;
samples = vgmstream->num_samples;
bps = get_vgmstream_average_bitrate(vgmstream) / 1000;
fmt = get_vgmstream_coding_description(vgmstream->coding_type);
get_vgmstream_coding_description(vgmstream, fmt, sizeof(fmt));
t = samples / rate;
tmin = t / 60;