Merge pull request #1425 from AGraber/master

Add support for .nxopus Opus [Ys X (Switch)]
This commit is contained in:
bnnm 2023-09-28 21:36:47 +02:00 committed by GitHub
commit 918eac436c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 0 deletions

View File

@ -1791,6 +1791,10 @@ different internally (encrypted, different versions, etc) and not always can be
- **snds.c**
- Sony SNDS header [*SNDS*]
- Codecs: ATRAC9
- **nxof.c**
- Nihon Falcom FDK Opus Header [*NXOF*]
- *nxof*: `.nxopus`
- Codecs: Opus
- **scd_pcm.c**
- Lunar: Eternal Blue .PCM header [*SCD_PCM*]
- *scd_pcm*: `.pcm`

View File

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

View File

@ -535,6 +535,7 @@
<ClCompile Include="meta\nwav.c" />
<ClCompile Include="meta\nxa.c" />
<ClCompile Include="meta\nxap.c" />
<ClCompile Include="meta\nxof.c" />
<ClCompile Include="meta\ogg_opus.c" />
<ClCompile Include="meta\ogg_vorbis.c" />
<ClCompile Include="meta\ogl.c" />

View File

@ -1426,6 +1426,9 @@
<ClCompile Include="meta\nxap.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\nxof.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\ogg_opus.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

View File

@ -982,4 +982,6 @@ VGMSTREAM* init_vgmstream_squeaksample(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_snds(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_nxof(STREAMFILE* sf);
#endif /*_META_H*/

53
src/meta/nxof.c Normal file
View File

@ -0,0 +1,53 @@
#include "meta.h"
#include "../coding/coding.h"
/* Nihon Falcom FDK NXOpus [Ys X -NORDICS- (Switch)] */
VGMSTREAM* init_vgmstream_nxof(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_NXOF;
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
skip = switch_opus_get_encoder_delay(start_offset, sf);
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

@ -521,6 +521,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_squeaksample,
init_vgmstream_snds,
init_vgmstream_adm2,
init_vgmstream_nxof,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_scd_pcm,

View File

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