Merge pull request #1371 from bnnm/law-dic

- Add HCA key
- Add TXTH ULAW/ALAW codecs
- Remove .al/al2 raw format (use TXTH + ALAW)
- Remove .ulw raw format (use TXTH + ULAW)
- Remove .amts/smta/ps2stm fake extension (use .stm/lstm)
- Add Codemasters .DIC [DiRT (PC), F1 2011 (PC)]
This commit is contained in:
bnnm 2023-06-11 19:51:47 +02:00 committed by GitHub
commit 53571e16f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 346 additions and 279 deletions

View File

@ -215,7 +215,7 @@ This list is not complete and many other files are supported.
- .sd9 (MS ADPCM)
- .smp (MS ADPCM)
- .spw (PSX configurable ADPCM)
- .stm/lstm [amts/ps2stm/stma] (16 bit PCM, DVI IMA ADPCM, GC DSP ADPCM)
- .stm/lstm (16 bit PCM, DVI IMA ADPCM, GC DSP ADPCM)
- .str (SDX2 DPCM)
- .stx (GC AFC ADPCM)
- .ulw (u-Law PCM)

View File

@ -107,6 +107,13 @@ as explained below, but often will use default values. Accepted codec strings:
# * For few rare games [Ikinari Maou (Switch)]
# * Interleave is multiple of 0x4 (default)
#
# - ULAW mu-Law 8-bit PCM
# * For few rare games [Burnout (GC)]
# * Interleave is multiple of 0x1 (default)
# - ALAW A-Law 8-bit PCM
# * For few rare games [Illwinter Game Design games: Conquest of Elysium 3 (PC), Dominions 3/4 (PC)]
# * Interleave is multiple of 0x1 (default)
#
# - IMA IMA ADPCM (mono/stereo)
# * For some PC games, and rarely consoles
# * Special interleave is multiple of 0x1, often +0x80

View File

@ -28,54 +28,53 @@ sudo apt-get install -y libao-dev
###############################################################################
# vorbis deps
sudo apt-get install -y libvorbis-dev
FLAGS+=" VGM_VORBIS=1"
FLAGS="${FLAGS} VGM_VORBIS=1"
###############################################################################
# mpeg deps
sudo apt-get install -y libmpg123-dev
FLAGS+=" VGM_MPEG=1"
FLAGS="${FLAGS} VGM_MPEG=1"
###############################################################################
# speex deps
sudo apt-get install -y libspeex-dev
FLAGS+=" VGM_SPEEX=1"
FLAGS="${FLAGS} VGM_SPEEX=1"
###############################################################################
# ffmpeg deps
sudo apt-get install -y libavformat-dev libavcodec-dev libavutil-dev libswresample-dev
FLAGS+=" VGM_FFMPEG=1"
FLAGS="${FLAGS} VGM_FFMPEG=1"
###############################################################################
# atrac9 deps (compile)
mkdir dependencies
mkdir -p dependencies
cd dependencies
git clone https://github.com/Thealexbarney/LibAtrac9
cd LibAtrac9/C
make
cd ../../../
FLAGS+=" VGM_ATRAC9=2"
#INCS+=" -I../dependencies/LibAtrac9/C/src"
LIBS+=" -L../dependencies/LibAtrac9/C/bin"
FLAGS="${FLAGS} VGM_ATRAC9=2"
#INCS="${INCS} -I../dependencies/LibAtrac9/C/src"
LIBS="${LIBS} -L../dependencies/LibAtrac9/C/bin"
###############################################################################
# celt deps (compile x2)
mkdir dependencies
cd dependencies
# used renames followed by unused renamed (but seems needed to avoid clashes)
CELT0061_RENAMES=" \
-Dcelt_decode=celt_0061_decode \
-Dcelt_decoder_create=celt_0061_decoder_create \
-Dcelt_decoder_destroy=celt_0061_decoder_destroy \
-Dcelt_mode_create=celt_0061_mode_create \
-Dcelt_mode_destroy=celt_0061_mode_destroy \
-Dcelt_mode_info=celt_0061_mode_info \
-Dcelt_decode=celt_decode_0061 \
-Dcelt_decoder_create=celt_decoder_create_0061 \
-Dcelt_decoder_destroy=celt_decoder_destroy_0061 \
-Dcelt_mode_create=celt_mode_create_0061 \
-Dcelt_mode_destroy=celt_mode_destroy_0061 \
-Dcelt_mode_info=celt_mode_info_0061 \
\
-Dalg_quant=alg_quant_0061 \
-Dalg_unquant=alg_unquant_0061 \
@ -113,12 +112,12 @@ CELT0061_RENAMES=" \
"
# same as the above but I don't know sh enough to normalize
CELT0110_RENAMES=" \
-Dcelt_decode=celt_0110_decode \
-Dcelt_decoder_create_custom=celt_0110_decoder_create_custom \
-Dcelt_decoder_destroy=celt_0110_decoder_destroy \
-Dcelt_mode_create=celt_0110_mode_create \
-Dcelt_mode_destroy=celt_0110_mode_destroy \
-Dcelt_mode_info=celt_0110_mode_info \
-Dcelt_decode=celt_decode_0110 \
-Dcelt_decoder_create_custom=celt_decoder_create_custom_0110 \
-Dcelt_decoder_destroy=celt_decoder_destroy_0110 \
-Dcelt_mode_create=celt_mode_create_0110 \
-Dcelt_mode_destroy=celt_mode_destroy_0110 \
-Dcelt_mode_info=celt_mode_info_0110 \
\
-Dalg_quant=alg_quant_0110 \
-Dalg_unquant=alg_unquant_0110 \
@ -154,6 +153,8 @@ CELT0110_RENAMES=" \
-Dunquant_fine_energy=unquant_fine_energy_0110 \
"
mkdir -p dependencies
cd dependencies
git clone --depth 1 --branch v0.6.1 https://gitlab.xiph.org/xiph/celt.git celt-0061
cd celt-0061
@ -174,12 +175,12 @@ cd ..
cd ..
FLAGS+="VGM_CELT=2"
#INCS+=" -I../dependencies/celt-0061/libcelt/.libs/"
LIBS+=" -L../dependencies/celt-0061/libcelt/.libs/ -L../dependencies/celt-0110/libcelt/.libs/"
FLAGS="${FLAGS} VGM_CELT=2"
#INCS="${INCS} -I../dependencies/celt-0061/libcelt/.libs/"
LIBS="${LIBS} -L../dependencies/celt-0061/libcelt/.libs/ -L../dependencies/celt-0110/libcelt/.libs/"
###############################################################################
# vgmstream
make vgmstream_cli $FLAGS EXTRA_CFLAGS=$INCS EXTRA_LDFLAGS=$LIBS
make vgmstream-cli $FLAGS EXTRA_CFLAGS=$INCS EXTRA_LDFLAGS=$LIBS
make vgmstream123 $FLAGS EXTRA_CFLAGS=$INCS EXTRA_LDFLAGS=$LIBS

View File

@ -61,10 +61,9 @@ static const char* extension_list[] = {
//"aiff", //common
"aix",
"akb",
"al",
"al2",
"al", //txth/raw [Dominions 3 - The Awakening (PC)]
"al2", //txth/raw [Conquest of Elysium 3 (PC)]
"ams", //txth/reserved [Super Dragon Ball Z (PS2) ELF names]
"amts", //fake extension/header id for .stm (renamed? to be removed?)
"an2",
"ao",
"ap",
@ -163,6 +162,7 @@ static const char* extension_list[] = {
"ddsp",
"de2",
"dec",
"dic",
"diva",
"dmsg", //fake extension/header id for .sgt (to be removed)
"ds2", //txth/reserved [Star Wars Bounty Hunter (GC)]
@ -415,7 +415,6 @@ static const char* extension_list[] = {
"pona",
"pos",
"ps3",
"ps2stm", //fake extension for .stm (renamed? to be removed?)
"psb",
"psf",
"psh", //fake extension for .vsv (to be removed)
@ -530,7 +529,6 @@ static const char* extension_list[] = {
"ster",
"sth",
"stm",
"stma", //fake extension/header id for .stm
"str",
"stream",
"strm",
@ -568,7 +566,7 @@ static const char* extension_list[] = {
"u0",
"ue4opus",
"ulw",
"ulw", //txth/raw [Burnout (GC)]
"um3",
"utk",
"uv",
@ -1261,7 +1259,6 @@ static const meta_info meta_info_list[] = {
{meta_GHS, "Hexadrive GHS/S_P_STH header"},
{meta_AAC_TRIACE, "tri-Ace AAC header"},
{meta_MTA2, "Konami MTA2 header"},
{meta_NGC_ULW, "Criterion ULW raw header"},
{meta_XA_XA30, "Reflections XA30 header"},
{meta_XA_04SW, "Reflections 04SW header"},
{meta_TXTH, "TXTH generic header"},
@ -1273,7 +1270,6 @@ static const meta_info meta_info_list[] = {
{meta_EA_SNU, "Electronic Arts SNU header"},
{meta_AWC, "Rockstar AWC header"},
{meta_OPUS, "Nintendo Switch OPUS header"},
{meta_RAW_AL, "Illwinter Game Design .AL raw header"},
{meta_PC_AST, "Capcom AST (PC) header"},
{meta_UBI_SB, "Ubisoft SBx header"},
{meta_NAAC, "Namco NAAC header"},
@ -1423,6 +1419,7 @@ static const meta_info meta_info_list[] = {
{meta_SNDZ, "Sony SNDZ header"},
{meta_VAB, "Sony VAB header"},
{meta_BIGRP, "Inti Creates .BIGRP header"},
{meta_DIC1, "Codemasters DIC1 header"},
};
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View File

@ -411,6 +411,7 @@
<ClCompile Include="meta\ea_swvr.c" />
<ClCompile Include="meta\ea_wve_ad10.c" />
<ClCompile Include="meta\ea_wve_au00.c" />
<ClCompile Include="meta\ego_dic.c" />
<ClCompile Include="meta\encrypted.c" />
<ClCompile Include="meta\esf.c" />
<ClCompile Include="meta\exakt_sc.c" />
@ -517,7 +518,6 @@
<ClCompile Include="meta\ngc_ssm.c" />
<ClCompile Include="meta\ngc_str_cauldron.c" />
<ClCompile Include="meta\ngc_tydsp.c" />
<ClCompile Include="meta\ngc_ulw.c" />
<ClCompile Include="meta\ngc_ymf.c" />
<ClCompile Include="meta\nps.c" />
<ClCompile Include="meta\nub.c" />
@ -593,7 +593,6 @@
<ClCompile Include="meta\psf.c" />
<ClCompile Include="meta\ps_headerless.c" />
<ClCompile Include="meta\rad.c" />
<ClCompile Include="meta\raw_al.c" />
<ClCompile Include="meta\raw_int.c" />
<ClCompile Include="meta\raw_pcm.c" />
<ClCompile Include="meta\raw_snds.c" />

View File

@ -1054,6 +1054,9 @@
<ClCompile Include="meta\ea_wve_au00.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ego_dic.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\encrypted.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
@ -1372,9 +1375,6 @@
<ClCompile Include="meta\ngc_tydsp.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ngc_ulw.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ngc_ymf.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
@ -1600,9 +1600,6 @@
<ClCompile Include="meta\rad.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\raw_al.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\raw_int.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

156
src/meta/ego_dic.c Normal file
View File

@ -0,0 +1,156 @@
#include "meta.h"
#include "../coding/coding.h"
#include "../util/reader_text.h"
/* DIC1 - from Codemaster's Ego engine 'dictionaries' [DiRT (PC), F1 2011 (PC), Race Driver Grid (PC)] */
VGMSTREAM* init_vgmstream_ego_dic(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* sb = NULL;
uint32_t stream_offset = 0, stream_size = 0, codec = 0;
int channels = 0, loop_flag = 0, sample_rate = 0;
/* checks */
if (!is_id32be(0x00, sf, "DIC1"))
return NULL;
if (!check_extensions(sf, "dic"))
return NULL;
/* 0x04: hash/info? */
/* 0x08: version ("0.46": DiRT, "2.00": DiRT 2+ (no diffs?) */
int containers = read_s32le(0x0c,sf);
int total_subsongs = 0;
int target_subsong = sf->stream_index;
if (target_subsong == 0) target_subsong = 1;
char container_name[0x10+1];
char track_name[0x10+1];
char ext[0x04+1];
{
/* N containers (external files) that may have N tracks, so we'll map all to subsongs */
bool track_found = false;
uint32_t offset = 0x10;
for (int i = 0; i < containers; i++) {
uint32_t header_offset = read_u32le(offset + 0x00,sf);
int tracks = read_s32le(offset + 0x04,sf);
/* target in container */
if (!track_found && target_subsong >= total_subsongs + 1 && target_subsong < total_subsongs + 1 + tracks) {
read_string(container_name, 0x10, offset + 0x08, sf);
int track_pos = target_subsong - total_subsongs - 1;
uint32_t track_offset = header_offset + track_pos * 0x18;
uint32_t curr_offset, flags, next_offset;
curr_offset = read_u32le(track_offset + 0x00, sf);
sample_rate = read_u16le(track_offset + 0x04, sf);
flags = read_u16le(track_offset + 0x06, sf);
read_string(track_name, 0x10, track_offset + 0x08, sf);
next_offset = read_u32le(track_offset + 0x18, sf); /* always exists as even after last track */
/* 8ch seen in Race Driver Grid music*.WIM, 2ch in other music tracks */
channels = ((flags >> 5) & 0x7) + 1;
loop_flag = flags & (1<<4);
/* flag 0x8000: ? (common) */
/* others: not seen */
stream_offset = curr_offset;
stream_size = next_offset - curr_offset;
/* after all tracks comes container size + extension/codec */
uint32_t ext_offset = header_offset + tracks * 0x18 + 0x04;
codec = read_u32be(ext_offset + 0x00, sf);
read_string(ext, 0x04, ext_offset + 0x00, sf);
track_found = true;
}
total_subsongs += tracks;
offset += 0x18;
}
if (target_subsong > total_subsongs || total_subsongs <= 0) goto fail;
if (!track_found) goto fail;
}
{
char resource_name[255];
snprintf(resource_name, sizeof(resource_name), "%s.%s", container_name, ext);
sb = open_streamfile_by_filename(sf, resource_name);
if (sb == NULL) {
vgm_logi("DIC1: external file '%s' not found (put together)\n", resource_name);
goto fail;
}
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_DIC1;
vgmstream->sample_rate = sample_rate;
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
switch(codec) {
case 0x57495000: //WIP\0
vgmstream->coding_type = coding_PCM16LE;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x02;
vgmstream->num_samples = pcm16_bytes_to_samples(stream_size, channels);
break;
case 0x57494D00: //WIM\0
vgmstream->coding_type = coding_ULAW;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x01;
vgmstream->num_samples = pcm8_bytes_to_samples(stream_size, channels);
break;
case 0x57494100: //WIA\0
vgmstream->coding_type = coding_XBOX_IMA;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = xbox_ima_bytes_to_samples(stream_size, channels);
stream_offset += 0x04; /* all streams start with 0xFFFFFFFF, may be some delimiter */
break;
#ifdef VGM_USE_VORBIS
case 0x57494F00: //WIO\0
vgmstream->codec_data = init_ogg_vorbis(sb, stream_offset, stream_size, NULL);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_OGG_VORBIS;
vgmstream->layout_type = layout_none;
ogg_vorbis_get_samples(vgmstream->codec_data, &vgmstream->num_samples);
break;
#endif
default:
VGM_LOG("DIC1: unknown codec\n");
goto fail;
}
snprintf(vgmstream->stream_name, STREAM_NAME_SIZE, "%s.%s/%s", container_name, ext, track_name);
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
if (!vgmstream_open_stream(vgmstream, sb, stream_offset))
goto fail;
close_streamfile(sb);
return vgmstream;
fail:
close_vgmstream(vgmstream);
close_streamfile(sb);
return NULL;
}

View File

@ -13,8 +13,8 @@ typedef struct {
/**
* List of known keys, extracted from the game files (several found in 2ch.net, others from data analisys).
* CRI's tools expect an unsigned 64 bit number string, but keys are commonly found online in hex form.
* List of known keys, extracted from the game files (most from data analisys, some from 2ch.net/forums).
* CRI's tools expect an unsigned 64 bit numberic string, but keys are commonly found online in hex form.
* Keys only use 56 bits though, so the upper 8 bits can be ignored.
*
* Some ACB+AWB after mid 2018 use a user seed key + a scramble subkey in the AWB (normally 16b LE at 0x0e)
@ -1181,9 +1181,12 @@ static const hcakey_info hcakey_list[] = {
// Love Live! School Idol Festival 2 MIRACLE LIVE (Android)
{5067530812966687744}, // 46537c6ceb39d400
// 404 Game RE:SET Prologue Demo (Android)
// 404 Game RE:SET (Android)
{21588207721978971}, // 004CB25C4C9B1C5B
// Disney Star Smash (Android)
{3941111674189632}, // 000E006B915C3740
};
#endif/*_HCA_KEYS_H_*/

View File

@ -606,8 +606,6 @@ VGMSTREAM * init_vgmstream_va3(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_mta2(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_mta2_container(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ngc_ulw(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_xa_xa30(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_xa_04sw(STREAMFILE * streamFile);
@ -627,7 +625,7 @@ VGMSTREAM * init_vgmstream_ea_schl_fixed(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_sk_aud(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_stm(STREAMFILE * streamFile);
VGMSTREAM* init_vgmstream_stm(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_awc(STREAMFILE * streamFile);
@ -646,8 +644,6 @@ VGMSTREAM* init_vgmstream_opus_nsopus(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_sqex(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_rsnd(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_raw_al(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_pc_ast(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_naac(STREAMFILE * streamFile);
@ -990,4 +986,6 @@ VGMSTREAM* init_vgmstream_bigrp(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_sscf_encrypted(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_ego_dic(STREAMFILE* sf);
#endif /*_META_H*/

View File

@ -1,60 +0,0 @@
#include "meta.h"
#include "../coding/coding.h"
/* ULW - headerless U-law, found in Burnout (GC) */
VGMSTREAM * init_vgmstream_ngc_ulw(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
/* check extension, case insensitive */
if ( !check_extensions(streamFile,"ulw"))
goto fail;
/* raw data, the info is in the filename (really!) */
{
char filename[PATH_LIMIT] = {0};
get_streamfile_filename(streamFile, filename,PATH_LIMIT);
/* first letter gives the channels */
if (filename[0]=='M') /* Mono */
channel_count = 1;
else if (filename[0]=='S' || filename[0]=='D') /* Stereo/Dolby */
channel_count = 2;
else
goto fail;
/* not very robust but meh (other tracks don't loop) */
if (strcmp(filename,"MMenu.ulw")==0 || strcmp(filename,"DMenu.ulw")==0) {
loop_flag = 1;
}
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = 32000;
vgmstream->coding_type = coding_ULAW;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x01;
vgmstream->meta_type = meta_NGC_ULW;
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), channel_count, 8);
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
start_offset = 0;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,42 +0,0 @@
#include "meta.h"
#include "../coding/coding.h"
/* AL/AL2 - headerless a-law, from Illwinter Game Design games */
VGMSTREAM * init_vgmstream_raw_al(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
/* checks */
/* .al: Dominions 3 - The Awakening (PC)
* .al2: Conquest of Elysium 3 (PC) */
if ( !check_extensions(streamFile,"al,al2"))
goto fail;
channel_count = check_extensions(streamFile,"al") ? 1 : 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_ALAW;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x01;
vgmstream->meta_type = meta_RAW_AL;
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), channel_count, 8);
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
}
start_offset = 0;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,27 +1,28 @@
#include "meta.h"
#include "../coding/coding.h"
/* STM - from Angel Studios/Rockstar San Diego games (Red Dead Revolver, Midnight Club 2, TransWorld Surf) */
VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
/* STM - from Angel Studios/Rockstar San Diego games [Red Dead Revolver (PS2), Spy Hunter 2 (PS2/Xbox)] */
VGMSTREAM* init_vgmstream_stm(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
int big_endian, bps, interleave, data_size, loop_start = 0, loop_end = 0;
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
/* check extension, case insensitive
* .stm is the real ext but common, rename to .lstm or .stma/amts/ps2stm (older) */
if ( !check_extensions(streamFile,"stm,lstm,stma,amts,ps2stm"))
/* checks */
if (!is_id32be(0x00,sf, "STMA") && /* LE */
!is_id32be(0x00,sf, "AMTS")) /* BE */
goto fail;
/* .stm: real extension
* .lstm: for plugins */
if (!check_extensions(sf,"stm,lstm"))
goto fail;
/* check header */
if ((read_32bitBE(0x00,streamFile) != 0x53544d41) && /* "SMTA" (LE) */
(read_32bitBE(0x00,streamFile) != 0x414D5453)) /* "AMTS" (BE) */
goto fail;
/* 0x04: revision (696F/696B/696A/6969) */
big_endian = (read_32bitBE(0x00,streamFile) == 0x414D5453);
big_endian = is_id32be(0x00,sf, "AMTS");
if (big_endian) {
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
@ -32,22 +33,22 @@ VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
start_offset = 0x800;
interleave = read_32bit(0x08,streamFile);
bps = read_32bit(0x10,streamFile);
channel_count = read_32bit(0x14,streamFile);
data_size = read_32bit(0x18,streamFile);
loop_end = read_32bit(0x1c,streamFile); /* absolute offset */
if (data_size + start_offset != get_streamfile_size(streamFile)) goto fail;
interleave = read_32bit(0x08,sf);
bps = read_32bit(0x10,sf);
channel_count = read_32bit(0x14,sf);
data_size = read_32bit(0x18,sf);
loop_end = read_32bit(0x1c,sf); /* absolute offset */
if (data_size + start_offset != get_streamfile_size(sf)) goto fail;
if (big_endian) {
/* GC AMTS have a regular DSP header beyond 0x20, just use what we need, no point on validating all fields */
loop_flag = read_16bit(0x2c,streamFile);
loop_flag = read_16bit(0x2c,sf);
}
else {
/* PS2/Xbox STMA have either loop info or padding beyond 0x20 */
if (read_32bit(0x20,streamFile) == 1) { /* may contain 0xCCCCCCCC garbage */
if (read_32bit(0x20,sf) == 1) { /* may contain 0xCCCCCCCC garbage */
loop_flag = 1;
loop_start = read_32bit(0x24,streamFile);
loop_start = read_32bit(0x24,sf);
/* 0x28 (32b * ch): loop start hist+step per channel */ //todo setup
}
#if 0
@ -63,7 +64,7 @@ VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bit(0xc,streamFile);
vgmstream->sample_rate = read_32bit(0xc,sf);
vgmstream->meta_type = meta_STM;
vgmstream->layout_type = (channel_count > 1) ? layout_interleave : layout_none;
@ -73,12 +74,12 @@ VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->interleave_block_size = interleave;
vgmstream->num_samples = read_32bit(0x20,streamFile);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bit(0x30,streamFile));
vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_32bit(0x34,streamFile))+1;
vgmstream->num_samples = read_32bit(0x20,sf);
vgmstream->loop_start_sample = dsp_nibbles_to_samples(read_32bit(0x30,sf));
vgmstream->loop_end_sample = dsp_nibbles_to_samples(read_32bit(0x34,sf))+1;
dsp_read_coefs_be(vgmstream, streamFile, 0x3c, 0x60);
dsp_read_hist_be(vgmstream, streamFile, 0x60, 0x60);
dsp_read_coefs_be(vgmstream, sf, 0x3c, 0x60);
dsp_read_hist_be(vgmstream, sf, 0x60, 0x60);
}
else { /* DVI IMA ADPCM (Red Dead Revolver, Midnight Club 2) */
vgmstream->coding_type = coding_DVI_IMA_int;
@ -108,7 +109,7 @@ VGMSTREAM * init_vgmstream_stm(STREAMFILE *streamFile) {
}
if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset) )
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
goto fail;
return vgmstream;

View File

@ -55,8 +55,10 @@ typedef enum {
PCM8_SB,
HEVAG,
YMZ,
ULAW,
ALAW,
UNKNOWN = 99,
UNKNOWN = 255,
} txth_codec_t;
typedef enum { DEFAULT, NEGATIVE, POSITIVE, INVERTED } txth_loop_t;
@ -238,6 +240,8 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
case PCM8_U:
case PCM8_SB: interleave = 0x01; break;
case PCM_FLOAT_LE: interleave = 0x04; break;
case ULAW:
case ALAW: interleave = 0x01; break;
default:
break;
}
@ -260,6 +264,8 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
case PCM8_U: coding = coding_PCM8_U; break;
case PCM8_U_int: coding = coding_PCM8_U_int; break;
case PCM8_SB: coding = coding_PCM8_SB; break;
case ULAW: coding = coding_ULAW; break;
case ALAW: coding = coding_ALAW; break;
case PCM_FLOAT_LE: coding = coding_PCMFLOAT; break;
case SDX2: coding = coding_SDX2; break;
case DVI_IMA: coding = coding_DVI_IMA; break;
@ -333,6 +339,8 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
case coding_PCM8:
case coding_PCM8_U:
case coding_PCM8_SB:
case coding_ULAW:
case coding_ALAW:
case coding_PCMFLOAT:
case coding_PCM4:
case coding_PCM4_U:
@ -993,6 +1001,8 @@ static txth_codec_t parse_codec(txth_header* txth, const char* val) {
else if (is_string(val,"PCM_FLOAT_LE")) return PCM_FLOAT_LE;
else if (is_string(val,"IMA_HV")) return IMA_HV;
else if (is_string(val,"HEVAG")) return HEVAG;
else if (is_string(val,"ULAW")) return ULAW;
else if (is_string(val,"ALAW")) return ALAW;
/* special handling */
else if (is_string(val,"name_value")) return txth->name_values[0];
else if (is_string(val,"name_value1")) return txth->name_values[0];
@ -2132,6 +2142,8 @@ static int get_bytes_to_samples(txth_header* txth, uint32_t bytes) {
case PCM8_U_int:
case PCM8_U:
case PCM8_SB:
case ULAW:
case ALAW:
return pcm8_bytes_to_samples(bytes, txth->channels);
case PCM_FLOAT_LE:
return pcm_bytes_to_samples(bytes, txth->channels, 32);

View File

@ -245,14 +245,14 @@ void utf_close(utf_context* utf) {
}
int utf_get_column(utf_context* utf, const char* column) {
int utf_get_column(utf_context* utf, const char* column_name) {
int i;
/* find target column */
for (i = 0; i < utf->columns; i++) {
struct utf_column_t* col = &utf->schema[i];
if (col->name == NULL || strcmp(col->name, column) != 0)
if (col->name == NULL || strcmp(col->name, column_name) != 0)
continue;
return i;
}

View File

@ -24,7 +24,7 @@ typedef struct utf_context utf_context;
utf_context* utf_open(STREAMFILE* sf, uint32_t table_offset, int* p_rows, const char** p_row_name);
void utf_close(utf_context* utf);
int utf_get_column(utf_context* utf, const char* column);
int utf_get_column(utf_context* utf, const char* column_name);
/* query calls (passing column index is faster, when you have to read lots of rows) */
int utf_query_col_s8(utf_context* utf, int row, int column, int8_t* value);

View File

@ -527,6 +527,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_sscf_encrypted,
init_vgmstream_s_p_sth,
init_vgmstream_utf_ahx,
init_vgmstream_ego_dic,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_scd_pcm,
@ -553,8 +554,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_raw_wavm, /* .wavm raw xbox */
init_vgmstream_raw_pcm, /* .raw raw PCM */
init_vgmstream_s14_sss, /* .s14/sss raw siren14 */
init_vgmstream_raw_al, /* .al/al2 raw A-LAW */
init_vgmstream_ngc_ulw, /* .ulw raw u-Law */
init_vgmstream_exakt_sc, /* .sc raw PCM */
init_vgmstream_zwdsp, /* fake format */
init_vgmstream_ps2_adm, /* weird non-constant PSX blocks */

View File

@ -549,7 +549,6 @@ typedef enum {
meta_GHS,
meta_AAC_TRIACE,
meta_MTA2,
meta_NGC_ULW, /* Burnout 1 (GC only) */
meta_XA_XA30,
meta_XA_04SW,
meta_TXTH, /* generic text header */
@ -560,7 +559,6 @@ typedef enum {
meta_EA_SNU, /* Electronic Arts SNU (Dead Space) */
meta_AWC, /* Rockstar AWC (GTA5, RDR) */
meta_OPUS, /* Nintendo Opus [Lego City Undercover (Switch)] */
meta_RAW_AL,
meta_PC_AST, /* Dead Rising (PC) */
meta_NAAC, /* Namco AAC (3DS) */
meta_UBI_SB, /* Ubisoft banks */
@ -712,6 +710,7 @@ typedef enum {
meta_SNDZ,
meta_VAB,
meta_BIGRP,
meta_DIC1,
} meta_t;