Add support for FDK (NX) Opus Header

This commit is contained in:
Adrian Graber 2023-09-27 14:50:21 +02:00
parent 58482731b5
commit 1d982bef6f
8 changed files with 65 additions and 0 deletions

View File

@ -1124,6 +1124,10 @@ different internally (encrypted, different versions, etc) and not always can be
- Entergram NXA header [*NXA*] - Entergram NXA header [*NXA*]
- *opus_nxa*: `.nxa` - *opus_nxa*: `.nxa`
- Codecs: Opus - Codecs: Opus
- **fdk_nxopus.c**
- Nihon Falcom FDK Opus Header [*FDK_NXOPUS*]
- *opus_fdk*: `.nxopus`
- Codecs: Opus
- **pc_ast.c** - **pc_ast.c**
- Capcom AST (PC) header [*PC_AST*] - Capcom AST (PC) header [*PC_AST*]
- *pc_ast*: `.ast` - *pc_ast*: `.ast`

View File

@ -392,6 +392,7 @@ static const char* extension_list[] = {
"nwa", "nwa",
"nwav", "nwav",
"nxa", "nxa",
"nxopus",
//"ogg", //common //"ogg", //common
"ogg_", "ogg_",
@ -1416,6 +1417,7 @@ static const meta_info meta_info_list[] = {
{meta_SQUEAKSTREAM, "Torus SqueakStream header"}, {meta_SQUEAKSTREAM, "Torus SqueakStream header"},
{meta_SQUEAKSAMPLE, "Torus SqueakSample header"}, {meta_SQUEAKSAMPLE, "Torus SqueakSample header"},
{meta_SNDS, "Sony SNDS header"}, {meta_SNDS, "Sony SNDS header"},
{meta_FDK_NXOPUS, "Nihon Falcom FDK Opus Header"},
}; };
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) { void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View File

@ -425,6 +425,7 @@
<ClCompile Include="meta\ezw.c" /> <ClCompile Include="meta\ezw.c" />
<ClCompile Include="meta\fag.c" /> <ClCompile Include="meta\fag.c" />
<ClCompile Include="meta\fda.c" /> <ClCompile Include="meta\fda.c" />
<ClCompile Include="meta\fdk_nxopus.c" />
<ClCompile Include="meta\ffdl.c" /> <ClCompile Include="meta\ffdl.c" />
<ClCompile Include="meta\ffmpeg.c" /> <ClCompile Include="meta\ffmpeg.c" />
<ClCompile Include="meta\ffw.c" /> <ClCompile Include="meta\ffw.c" />

View File

@ -1096,6 +1096,9 @@
<ClCompile Include="meta\fda.c"> <ClCompile Include="meta\fda.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="meta\fdk_nxopus.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ffdl.c"> <ClCompile Include="meta\ffdl.c">
<Filter>meta\Source Files</Filter> <Filter>meta\Source Files</Filter>
</ClCompile> </ClCompile>

52
src/meta/fdk_nxopus.c Normal file
View File

@ -0,0 +1,52 @@
#include "meta.h"
#include "../coding/coding.h"
/* Nihon Falcom FDK NXOpus [Ys X -NORDICS- (Switch)] */
VGMSTREAM* init_vgmstream_opus_fdk(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channels, sample_rate;
size_t data_size, skip = 0;
int32_t num_samples, loop_start, loop_end;
/* checks */
if (!is_id32le(0x00, sf, "nxof"))
goto fail;
if (!check_extensions(sf,"nxopus"))
goto fail;
channels = read_u8(0x05, sf);
sample_rate = read_u32le(0x08, sf);
start_offset = read_u32le(0x18, sf);
data_size = read_u32le(0x1C, sf);
num_samples = read_u32le(0x20, sf);
loop_start = read_u32le(0x30, sf);
loop_end = read_u32le(0x34, sf);
loop_flag = (loop_end > 0);
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_FDK_NXOPUS;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = loop_end;
#ifdef VGM_USE_FFMPEG
vgmstream->codec_data = init_ffmpeg_switch_opus(sf, start_offset, data_size, vgmstream->channels, skip, vgmstream->sample_rate);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
#else
goto fail;
#endif
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -625,6 +625,7 @@ VGMSTREAM* init_vgmstream_opus_opusnx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_nsopus(STREAMFILE* sf); VGMSTREAM* init_vgmstream_opus_nsopus(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_sqex(STREAMFILE* sf); VGMSTREAM* init_vgmstream_opus_sqex(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_rsnd(STREAMFILE* sf); VGMSTREAM* init_vgmstream_opus_rsnd(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_opus_fdk(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_pc_ast(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_pc_ast(STREAMFILE * streamFile);

View File

@ -309,6 +309,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_opus_nus3, init_vgmstream_opus_nus3,
init_vgmstream_opus_sps_n1, init_vgmstream_opus_sps_n1,
init_vgmstream_opus_nxa, init_vgmstream_opus_nxa,
init_vgmstream_opus_fdk,
init_vgmstream_pc_ast, init_vgmstream_pc_ast,
init_vgmstream_naac, init_vgmstream_naac,
init_vgmstream_ubi_sb, init_vgmstream_ubi_sb,

View File

@ -702,6 +702,7 @@ typedef enum {
meta_SQUEAKSTREAM, meta_SQUEAKSTREAM,
meta_SQUEAKSAMPLE, meta_SQUEAKSAMPLE,
meta_SNDS, meta_SNDS,
meta_FDK_NXOPUS,
} meta_t; } meta_t;