Rename mzrt.c to idtech.c

This commit is contained in:
bnnm 2021-01-25 21:10:41 +01:00
parent 02fc37811f
commit 1df00d175d
5 changed files with 157 additions and 157 deletions

View File

@ -329,7 +329,7 @@
> >
</File> </File>
<File <File
RelativePath=".\meta\mzrt_streamfile.h" RelativePath=".\meta\idtech_streamfile.h"
> >
</File> </File>
<File <File
@ -987,7 +987,7 @@
> >
</File> </File>
<File <File
RelativePath=".\meta\mzrt.c" RelativePath=".\meta\idtech.c"
> >
</File> </File>
<File <File

View File

@ -130,7 +130,7 @@
<ClInclude Include="meta\mta2_streamfile.h" /> <ClInclude Include="meta\mta2_streamfile.h" />
<ClInclude Include="meta\mul_streamfile.h" /> <ClInclude Include="meta\mul_streamfile.h" />
<ClInclude Include="meta\mups_streamfile.h" /> <ClInclude Include="meta\mups_streamfile.h" />
<ClInclude Include="meta\mzrt_streamfile.h" /> <ClInclude Include="meta\idtech_streamfile.h" />
<ClInclude Include="meta\nus3bank_streamfile.h" /> <ClInclude Include="meta\nus3bank_streamfile.h" />
<ClInclude Include="meta\ogg_vorbis_streamfile.h" /> <ClInclude Include="meta\ogg_vorbis_streamfile.h" />
<ClInclude Include="meta\opus_interleave_streamfile.h" /> <ClInclude Include="meta\opus_interleave_streamfile.h" />
@ -378,7 +378,7 @@
<ClCompile Include="meta\musc.c" /> <ClCompile Include="meta\musc.c" />
<ClCompile Include="meta\musx.c" /> <ClCompile Include="meta\musx.c" />
<ClCompile Include="meta\myspd.c" /> <ClCompile Include="meta\myspd.c" />
<ClCompile Include="meta\mzrt.c" /> <ClCompile Include="meta\idtech.c" />
<ClCompile Include="meta\naac.c" /> <ClCompile Include="meta\naac.c" />
<ClCompile Include="meta\naomi_adpcm.c" /> <ClCompile Include="meta\naomi_adpcm.c" />
<ClCompile Include="meta\naomi_spsd.c" /> <ClCompile Include="meta\naomi_spsd.c" />

View File

@ -137,7 +137,7 @@
<ClInclude Include="meta\mups_streamfile.h"> <ClInclude Include="meta\mups_streamfile.h">
<Filter>meta\Header Files</Filter> <Filter>meta\Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="meta\mzrt_streamfile.h"> <ClInclude Include="meta\idtech_streamfile.h">
<Filter>meta\Header Files</Filter> <Filter>meta\Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="meta\nus3bank_streamfile.h"> <ClInclude Include="meta\nus3bank_streamfile.h">
@ -631,7 +631,7 @@
<ClCompile Include="meta\myspd.c"> <ClCompile Include="meta\myspd.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\mzrt.c"> <ClCompile Include="meta\idtech.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\naac.c"> <ClCompile Include="meta\naac.c">

View File

@ -1,151 +1,151 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
#include "mzrt_streamfile.h" #include "idtech_streamfile.h"
/* mzrt - idTech "4.5" audio found in .resource bigfiles (w/ internal filenames) [Doom 3 BFG edition (PC/PS3/X360)] */ /* mzrt - idTech "4.5" audio found in .resource bigfiles (w/ internal filenames) [Doom 3 BFG edition (PC/PS3/X360)] */
VGMSTREAM * init_vgmstream_mzrt(STREAMFILE *streamFile) { VGMSTREAM * init_vgmstream_mzrt(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM * vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag = 0, channel_count, codec, sample_rate, block_size = 0, bps = 0, num_samples; int loop_flag = 0, channel_count, codec, sample_rate, block_size = 0, bps = 0, num_samples;
STREAMFILE *temp_streamFile = NULL; STREAMFILE *temp_streamFile = NULL;
/* checks */ /* checks */
if (!check_extensions(streamFile, "idwav,idmsf,idxma")) if (!check_extensions(streamFile, "idwav,idmsf,idxma"))
goto fail; goto fail;
if (read_32bitBE(0x00,streamFile) != 0x6D7A7274) /* "mzrt" */ if (read_32bitBE(0x00,streamFile) != 0x6D7A7274) /* "mzrt" */
goto fail; goto fail;
/* this format is bizarrely mis-aligned (and mis-designed too) */ /* this format is bizarrely mis-aligned (and mis-designed too) */
num_samples = read_32bitBE(0x11,streamFile); num_samples = read_32bitBE(0x11,streamFile);
codec = read_16bitLE(0x15,streamFile); codec = read_16bitLE(0x15,streamFile);
switch(codec) { switch(codec) {
case 0x0001: case 0x0001:
case 0x0002: case 0x0002:
case 0x0166: case 0x0166:
channel_count = read_16bitLE(0x17,streamFile); channel_count = read_16bitLE(0x17,streamFile);
sample_rate = read_32bitLE(0x19, streamFile); sample_rate = read_32bitLE(0x19, streamFile);
block_size = read_16bitLE(0x21, streamFile); block_size = read_16bitLE(0x21, streamFile);
bps = read_16bitLE(0x23,streamFile); bps = read_16bitLE(0x23,streamFile);
start_offset = 0x25; start_offset = 0x25;
break; break;
case 0x0000: case 0x0000:
sample_rate = read_32bitBE(0x1D, streamFile); sample_rate = read_32bitBE(0x1D, streamFile);
channel_count = read_32bitBE(0x21, streamFile); channel_count = read_32bitBE(0x21, streamFile);
start_offset = 0x29; start_offset = 0x29;
break; break;
default: default:
goto fail; goto fail;
} }
/* skip MSADPCM data */ /* skip MSADPCM data */
if (codec == 0x0002) { if (codec == 0x0002) {
if (!msadpcm_check_coefs(streamFile, start_offset + 0x02 + 0x02)) if (!msadpcm_check_coefs(streamFile, start_offset + 0x02 + 0x02))
goto fail; goto fail;
start_offset += 0x02 + read_16bitLE(start_offset, streamFile); start_offset += 0x02 + read_16bitLE(start_offset, streamFile);
} }
/* skip extra data */ /* skip extra data */
if (codec == 0x0166) { if (codec == 0x0166) {
start_offset += 0x02 + read_16bitLE(start_offset, streamFile); start_offset += 0x02 + read_16bitLE(start_offset, streamFile);
} }
/* skip unknown table */ /* skip unknown table */
if (codec == 0x0000) { if (codec == 0x0000) {
start_offset += 0x04 + read_32bitBE(start_offset, streamFile) * 0x04; start_offset += 0x04 + read_32bitBE(start_offset, streamFile) * 0x04;
} }
/* skip unknown table */ /* skip unknown table */
start_offset += 0x04 + read_32bitBE(start_offset, streamFile); start_offset += 0x04 + read_32bitBE(start_offset, streamFile);
/* skip block info */ /* skip block info */
if (codec != 0x0000) { if (codec != 0x0000) {
/* 0x00: de-blocked size /* 0x00: de-blocked size
* 0x04: block count*/ * 0x04: block count*/
start_offset += 0x08; start_offset += 0x08;
/* idwav only uses 1 super-block though */ /* idwav only uses 1 super-block though */
temp_streamFile = setup_mzrt_streamfile(streamFile, start_offset); temp_streamFile = setup_mzrt_streamfile(streamFile, start_offset);
if (!temp_streamFile) goto fail; if (!temp_streamFile) goto fail;
} }
else { else {
/* 0x00: de-blocked size */ /* 0x00: de-blocked size */
start_offset += 0x04; start_offset += 0x04;
} }
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_MZRT; vgmstream->meta_type = meta_MZRT;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples; vgmstream->num_samples = num_samples;
switch(codec) { switch(codec) {
case 0x0001: case 0x0001:
if (bps != 16) goto fail; if (bps != 16) goto fail;
vgmstream->coding_type = coding_PCM16LE; vgmstream->coding_type = coding_PCM16LE;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = block_size / channel_count; vgmstream->interleave_block_size = block_size / channel_count;
break; break;
case 0x0002: case 0x0002:
if (bps != 4) goto fail; if (bps != 4) goto fail;
vgmstream->coding_type = coding_MSADPCM; vgmstream->coding_type = coding_MSADPCM;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
vgmstream->frame_size = block_size; vgmstream->frame_size = block_size;
break; break;
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG
case 0x0166: { case 0x0166: {
uint8_t buf[0x100]; uint8_t buf[0x100];
int bytes; int bytes;
size_t stream_size = get_streamfile_size(temp_streamFile); size_t stream_size = get_streamfile_size(temp_streamFile);
bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf,sizeof(buf), 0x15,0x34, stream_size, streamFile, 0); bytes = ffmpeg_make_riff_xma_from_fmt_chunk(buf,sizeof(buf), 0x15,0x34, stream_size, streamFile, 0);
vgmstream->codec_data = init_ffmpeg_header_offset(temp_streamFile, buf,bytes, 0x00,stream_size); vgmstream->codec_data = init_ffmpeg_header_offset(temp_streamFile, buf,bytes, 0x00,stream_size);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg; vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
xma_fix_raw_samples_hb(vgmstream, streamFile, temp_streamFile, 0x00,stream_size, 0x15, 0,0); xma_fix_raw_samples_hb(vgmstream, streamFile, temp_streamFile, 0x00,stream_size, 0x15, 0,0);
break; break;
} }
#endif #endif
#ifdef VGM_USE_MPEG #ifdef VGM_USE_MPEG
case 0x0000: { case 0x0000: {
mpeg_custom_config cfg = {0}; mpeg_custom_config cfg = {0};
cfg.skip_samples = 576; /* assumed */ cfg.skip_samples = 576; /* assumed */
vgmstream->codec_data = init_mpeg_custom(streamFile, start_offset, &vgmstream->coding_type, vgmstream->channels, MPEG_STANDARD, &cfg); vgmstream->codec_data = init_mpeg_custom(streamFile, start_offset, &vgmstream->coding_type, vgmstream->channels, MPEG_STANDARD, &cfg);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
break; break;
} }
#endif #endif
default: default:
goto fail; goto fail;
} }
if (!vgmstream_open_stream(vgmstream,temp_streamFile == NULL ? streamFile : temp_streamFile,temp_streamFile == NULL ? start_offset : 0x00)) if (!vgmstream_open_stream(vgmstream,temp_streamFile == NULL ? streamFile : temp_streamFile,temp_streamFile == NULL ? start_offset : 0x00))
goto fail; goto fail;
close_streamfile(temp_streamFile); close_streamfile(temp_streamFile);
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_streamFile);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }