Move NXA Opus to its own file, since it's not very standard

This commit is contained in:
bnnm 2018-09-10 02:24:59 +02:00
parent 804fceb5e7
commit 37d7fe83c4
7 changed files with 72 additions and 60 deletions

View File

@ -1091,6 +1091,7 @@ static const meta_info meta_info_list[] = {
{meta_XAU_KONAMI, "Konami XAU header"},
{meta_DERF, "Xilam DERF header"},
{meta_UTK, "Maxis UTK header"},
{meta_NXA, "Entergram NXA header"},
};

View File

@ -830,10 +830,14 @@
RelativePath=".\meta\nus3bank.c"
>
</File>
<File
RelativePath=".\meta\nwa.c"
>
</File>
<File
RelativePath=".\meta\nwa.c"
>
</File>
<File
RelativePath=".\meta\nxa.c"
>
</File>
<File
RelativePath=".\meta\nxap.c"
>

View File

@ -312,6 +312,7 @@
<ClCompile Include="meta\nub_xma.c" />
<ClCompile Include="meta\nus3bank.c" />
<ClCompile Include="meta\nwa.c" />
<ClCompile Include="meta\nxa.c" />
<ClCompile Include="meta\nxap.c" />
<ClCompile Include="meta\ogg_vorbis.c" />
<ClCompile Include="meta\ogl.c" />

View File

@ -511,6 +511,9 @@
<ClCompile Include="meta\nwa.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\nxa.c">
<Filter>meta\Source Files</Filter>
</ClCompile>
<ClCompile Include="meta\nxap.c">
<Filter>meta\Source Files</Filter>
</ClCompile>

58
src/meta/nxa.c Normal file
View File

@ -0,0 +1,58 @@
#include "meta.h"
#include "../coding/coding.h"
/* Entergram NXA Opus [Higurashi no Naku Koro ni Hou (Switch)] */
VGMSTREAM * init_vgmstream_opus_nxa(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
size_t data_size, skip = 0;
/* checks */
if (!check_extensions(streamFile, "nxa"))
goto fail;
if (read_32bitBE(0x00, streamFile) != 0x4E584131) /* "NXA1" */
goto fail;
channel_count = read_16bitLE(0x10, streamFile);
skip = read_16bitLE(0x16, streamFile);
data_size = read_32bitLE(0x08, streamFile)-0x30;
start_offset = 0x30;
/* TODO: Determine if loop points are stored externally. No visible loop points in header */
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_NXA;
vgmstream->num_samples = read_32bitLE(0x20, streamFile);
vgmstream->sample_rate = read_32bitLE(0x0C, streamFile);
#ifdef VGM_USE_FFMPEG
{
vgmstream->codec_data = init_ffmpeg_switch_opus(streamFile, 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;
if (vgmstream->num_samples == 0) {
vgmstream->num_samples = switch_opus_get_samples(start_offset, data_size, vgmstream->sample_rate, streamFile) - skip;
}
}
#else
goto fail;
#endif
/* open the file for reading */
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,5 +1,4 @@
#include "meta.h"
#include "../util.h"
#include "../coding/coding.h"
#include "../layout/layout.h"
#include "opus_interleave_streamfile.h"
@ -314,58 +313,3 @@ VGMSTREAM * init_vgmstream_opus_nlsd(STREAMFILE *streamFile) {
fail:
return NULL;
}
/* Entergram NXA Opus [Higurashi no Naku Koro ni Hou (Switch)] */
VGMSTREAM * init_vgmstream_opus_nxa(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0, channel_count;
size_t data_size, skip = 0;
/* checks */
if (!check_extensions(streamFile, "nxa"))
goto fail;
if (read_32bitBE(0x00, streamFile) != 0x4E584131) /* "NXA1" */
goto fail;
channel_count = read_16bitLE(0x10, streamFile);
skip = read_16bitLE(0x16, streamFile);
data_size = read_32bitLE(0x08, streamFile)-0x30;
start_offset = 0x30;
/* TODO: Determine if loop points are stored externally. No visible loop points in header */
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_OPUS;
vgmstream->num_samples = read_32bitLE(0x20, streamFile);
vgmstream->sample_rate = read_32bitLE(0x0C, streamFile);
#ifdef VGM_USE_FFMPEG
{
vgmstream->codec_data = init_ffmpeg_switch_opus(streamFile, 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;
if (vgmstream->num_samples == 0) {
vgmstream->num_samples = switch_opus_get_samples(start_offset, data_size, vgmstream->sample_rate, streamFile) - skip;
}
}
#else
goto fail;
#endif
/* open the file for reading */
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -704,6 +704,7 @@ typedef enum {
meta_XAU_KONAMI, /* Yu-Gi-Oh - The Dawn of Destiny (Xbox) */
meta_DERF, /* Stupid Invaders (PC) */
meta_UTK,
meta_NXA,
} meta_t;