Add TXTH ULAW/ALAW codecs

This commit is contained in:
bnnm 2023-06-10 16:16:32 +02:00
parent 2e62b638c6
commit 35433e6650
3 changed files with 23 additions and 4 deletions

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 [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

@ -61,8 +61,8 @@ 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",
@ -568,7 +568,7 @@ static const char* extension_list[] = {
"u0",
"ue4opus",
"ulw",
"ulw", //txth/raw [Burnout (GC)]
"um3",
"utk",
"uv",

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);