mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
Add Codemasters .DIC [DiRT (PC), F1 2011 (PC)]
This commit is contained in:
parent
03d09e9308
commit
47feac9eb6
@ -162,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)]
|
||||
@ -1418,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) {
|
||||
|
@ -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" />
|
||||
|
@ -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
156
src/meta/ego_dic.c
Normal 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;
|
||||
}
|
@ -986,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*/
|
||||
|
@ -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,
|
||||
|
@ -710,6 +710,7 @@ typedef enum {
|
||||
meta_SNDZ,
|
||||
meta_VAB,
|
||||
meta_BIGRP,
|
||||
meta_DIC1,
|
||||
|
||||
} meta_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user