mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +01:00
HLWAV: Reworked the parser, removed fake "hlwav" extension
This commit is contained in:
parent
68f1184da7
commit
1b3ad0af47
@ -191,7 +191,6 @@ static const char* extension_list[] = {
|
|||||||
"hdr",
|
"hdr",
|
||||||
"hgc1",
|
"hgc1",
|
||||||
"his",
|
"his",
|
||||||
"hlwav",
|
|
||||||
"hps",
|
"hps",
|
||||||
"hsf",
|
"hsf",
|
||||||
"hx2",
|
"hx2",
|
||||||
@ -1028,7 +1027,7 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_EXAKT_SC, "assumed Activision / EXAKT SC by extension"},
|
{meta_EXAKT_SC, "assumed Activision / EXAKT SC by extension"},
|
||||||
{meta_WII_BNS, "Nintendo BNS header"},
|
{meta_WII_BNS, "Nintendo BNS header"},
|
||||||
{meta_WII_WAS, "Sumo Digital iSWS header"},
|
{meta_WII_WAS, "Sumo Digital iSWS header"},
|
||||||
{meta_XBOX_HLWAV, "Half Life 2 bgm header"},
|
{meta_XBOX_HLWAV, "Half-Life 2 .WAV header"},
|
||||||
{meta_MYSPD, "U-Sing .MYSPD header"},
|
{meta_MYSPD, "U-Sing .MYSPD header"},
|
||||||
{meta_HIS, "Her Interactive HIS header"},
|
{meta_HIS, "Her Interactive HIS header"},
|
||||||
{meta_PS2_AST, "KOEI AST header"},
|
{meta_PS2_AST, "KOEI AST header"},
|
||||||
|
@ -512,7 +512,6 @@
|
|||||||
<ClCompile Include="meta\wwise.c" />
|
<ClCompile Include="meta\wwise.c" />
|
||||||
<ClCompile Include="meta\xau.c" />
|
<ClCompile Include="meta\xau.c" />
|
||||||
<ClCompile Include="meta\xavs.c" />
|
<ClCompile Include="meta\xavs.c" />
|
||||||
<ClCompile Include="meta\xbox_hlwav.c" />
|
|
||||||
<ClCompile Include="meta\xbox_ims.c" />
|
<ClCompile Include="meta\xbox_ims.c" />
|
||||||
<ClCompile Include="meta\raw_wavm.c" />
|
<ClCompile Include="meta\raw_wavm.c" />
|
||||||
<ClCompile Include="meta\xmu.c" />
|
<ClCompile Include="meta\xmu.c" />
|
||||||
|
@ -1072,9 +1072,6 @@
|
|||||||
<ClCompile Include="meta\xavs.c">
|
<ClCompile Include="meta\xavs.c">
|
||||||
<Filter>meta\Source Files</Filter>
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="meta\xbox_hlwav.c">
|
|
||||||
<Filter>meta\Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="meta\xbox_ims.c">
|
<ClCompile Include="meta\xbox_ims.c">
|
||||||
<Filter>meta\Source Files</Filter>
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
#include "meta.h"
|
|
||||||
#include "../util.h"
|
|
||||||
|
|
||||||
/* HLWAV (from Half Life 2 [XBOX]) */
|
|
||||||
VGMSTREAM * init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
|
|
||||||
VGMSTREAM * vgmstream = NULL;
|
|
||||||
char filename[PATH_LIMIT];
|
|
||||||
off_t start_offset;
|
|
||||||
int loop_flag;
|
|
||||||
int channel_count;
|
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
||||||
if (strcasecmp("hlwav",filename_extension(filename))) goto fail;
|
|
||||||
|
|
||||||
/* check header and size */
|
|
||||||
if ((read_32bitBE(0x00,streamFile) != 0x14000000)) goto fail;
|
|
||||||
if (((read_32bitLE(0x4,streamFile) + (read_32bitLE(0x8,streamFile))) != get_streamfile_size(streamFile))) goto fail;
|
|
||||||
|
|
||||||
loop_flag = (read_32bitLE(0xC,streamFile)!= 0xFFFFFFFF);
|
|
||||||
channel_count = 2;
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
||||||
if (!vgmstream) goto fail;
|
|
||||||
|
|
||||||
/* fill in the vital statistics */
|
|
||||||
start_offset = read_32bitLE(0x8,streamFile);
|
|
||||||
vgmstream->channels = channel_count;
|
|
||||||
vgmstream->sample_rate = 22050;
|
|
||||||
vgmstream->coding_type = coding_PCM16LE;
|
|
||||||
vgmstream->num_samples = read_32bitLE(0x4,streamFile)/2/channel_count;
|
|
||||||
if (loop_flag) {
|
|
||||||
vgmstream->loop_start_sample = read_32bitLE(0x4,streamFile)/2/channel_count;
|
|
||||||
vgmstream->loop_end_sample = read_32bitLE(0xC,streamFile)/2/channel_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
vgmstream->layout_type = layout_interleave;
|
|
||||||
vgmstream->interleave_block_size = 0x2;
|
|
||||||
vgmstream->meta_type = meta_XBOX_HLWAV;
|
|
||||||
|
|
||||||
/* open the file for reading */
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
STREAMFILE * file;
|
|
||||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
if (!file) goto fail;
|
|
||||||
for (i=0;i<channel_count;i++) {
|
|
||||||
vgmstream->ch[i].streamfile = file;
|
|
||||||
|
|
||||||
vgmstream->ch[i].channel_start_offset=
|
|
||||||
vgmstream->ch[i].offset=start_offset+
|
|
||||||
vgmstream->interleave_block_size*i;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vgmstream;
|
|
||||||
|
|
||||||
/* clean up anything we may have opened */
|
|
||||||
fail:
|
|
||||||
if (vgmstream) close_vgmstream(vgmstream);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
@ -1,7 +1,80 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* .360.WAV, .PS3.WAV - from Valve games running on Source Engine */
|
/* .WAV - from Half-Life 2 (Xbox) */
|
||||||
|
VGMSTREAM *init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
|
||||||
|
VGMSTREAM *vgmstream = NULL;
|
||||||
|
uint32_t header_size, data_size, start_offset, sample_rate;
|
||||||
|
int32_t loop_start;
|
||||||
|
uint8_t format, freq_mode, channels;
|
||||||
|
int loop_flag;
|
||||||
|
|
||||||
|
/* checks */
|
||||||
|
if (!check_extensions(streamFile, "wav,lwav"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* check header and size */
|
||||||
|
header_size = read_u32le(0x00, streamFile);
|
||||||
|
if (header_size != 0x14)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
data_size = read_u32le(0x04, streamFile);
|
||||||
|
start_offset = read_u32le(0x08, streamFile);
|
||||||
|
if (data_size != get_streamfile_size(streamFile) - start_offset)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
loop_start = read_s32le(0x0c, streamFile);
|
||||||
|
format = read_u8(0x12, streamFile);
|
||||||
|
freq_mode = read_u8(0x13, streamFile) & 0x0F;
|
||||||
|
channels = (read_u8(0x13, streamFile) >> 4) & 0x0F;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* fill in the vital statistics */
|
||||||
|
vgmstream->meta_type = meta_XBOX_HLWAV;
|
||||||
|
vgmstream->channels = channels;
|
||||||
|
vgmstream->sample_rate = sample_rate;
|
||||||
|
vgmstream->loop_start_sample = loop_start;
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case 0x00: /* PCM */
|
||||||
|
vgmstream->coding_type = coding_PCM16LE;
|
||||||
|
vgmstream->layout_type = layout_interleave;
|
||||||
|
vgmstream->interleave_block_size = 0x02;
|
||||||
|
vgmstream->num_samples = pcm_bytes_to_samples(data_size, channels, 16);
|
||||||
|
vgmstream->loop_end_sample = vgmstream->num_samples; /* always loops from the end */
|
||||||
|
break;
|
||||||
|
case 0x01: /* XBOX ADPCM */
|
||||||
|
vgmstream->coding_type = coding_XBOX_IMA;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, channels);
|
||||||
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
||||||
|
goto fail;
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* .360.WAV, .PS3.WAV - from Valve games running on Source Engine, evolution of Xbox .WAV format */
|
||||||
/* [The Orange Box (X360), Portal 2 (PS3/X360), Counter-Strike: Global Offensive (PS3/X360)] */
|
/* [The Orange Box (X360), Portal 2 (PS3/X360), Counter-Strike: Global Offensive (PS3/X360)] */
|
||||||
VGMSTREAM* init_vgmstream_xmv_valve(STREAMFILE* streamFile) {
|
VGMSTREAM* init_vgmstream_xmv_valve(STREAMFILE* streamFile) {
|
||||||
VGMSTREAM* vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user