Merge pull request #621 from bnnm/vxn-wa

vxn wa
This commit is contained in:
bnnm 2020-05-10 14:33:37 +02:00 committed by GitHub
commit 0614aa7f7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 150 additions and 135 deletions

View File

@ -334,6 +334,9 @@ static const hcakey_info hcakey_list[] = {
/* Detective Conan Runner / Case Closed Runner (Android) */
{1175268187653273344}, // 104f643098e3f700
/* I Chu EtoileStage (Android) */
{1433227444226663680}, // 13E3D8C45778A500
/* Dragalia Lost (iOS/Android) */
{2967411924141, subkeys_dgl, sizeof(subkeys_dgl) / sizeof(subkeys_dgl[0]) }, // 000002B2E7889CAD

View File

@ -1,113 +1,113 @@
#include "meta.h"
#include "../coding/coding.h"
/* VXN - from Gameloft mobile games */
VGMSTREAM * init_vgmstream_vxn(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
int loop_flag = 0, channel_count, codec, sample_rate, block_align, bits, num_samples;
off_t start_offset, stream_offset, chunk_offset, first_offset = 0x00;
size_t stream_size;
int total_subsongs, target_subsong = streamFile->stream_index;
/* checks */
if (!check_extensions(streamFile,"vxn"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x566F784E) /* "VoxN" */
goto fail;
if (read_32bitLE(0x10,streamFile) != get_streamfile_size(streamFile) )
goto fail;
/* header is RIFF-like with many custom chunks */
if (!find_chunk_le(streamFile, 0x41666D74,first_offset,0, &chunk_offset,NULL)) /* "Afmt" */
goto fail;
codec = (uint16_t)read_16bitLE(chunk_offset+0x00, streamFile);
channel_count = (uint16_t)read_16bitLE(chunk_offset+0x02, streamFile);
sample_rate = read_32bitLE(chunk_offset+0x04, streamFile);
block_align = (uint16_t)read_16bitLE(chunk_offset+0x08, streamFile);
bits = read_16bitLE(chunk_offset+0x0a, streamFile);
/* files are divided into segment subsongs, often a leadout and loop in that order
* (the "Plst" and "Rule" chunks may have order info) */
if (!find_chunk_le(streamFile, 0x5365676D,first_offset,0, &chunk_offset,NULL)) /* "Segm" */
goto fail;
total_subsongs = read_32bitLE(chunk_offset+0x00, streamFile);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
stream_offset = read_32bitLE(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x00, streamFile);
stream_size = read_32bitLE(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x04, streamFile);
num_samples = read_32bitLE(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x08, streamFile);
if (!find_chunk_le(streamFile, 0x44617461,first_offset,0, &chunk_offset,NULL)) /* "Data" */
goto fail;
start_offset = chunk_offset + stream_offset;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_VXN;
switch (codec) {
case 0x0001: /* PCM */
if (bits != 16) goto fail;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->interleave_block_size = block_align;
vgmstream->layout_type = layout_interleave;
break;
case 0x0002: /* MSADPCM (ex. Asphalt 7) */
if (bits != 4) goto fail;
vgmstream->coding_type = coding_MSADPCM;
vgmstream->frame_size = block_align;
vgmstream->layout_type = layout_none;
if (find_chunk_le(streamFile, 0x4D736165,first_offset,0, &chunk_offset,NULL)) { /* "Msae" */
if (!msadpcm_check_coefs(streamFile, chunk_offset + 0x02))
goto fail;
}
break;
case 0x0011: /* MS-IMA (ex. Asphalt 6) */
if (bits != 16) goto fail;
vgmstream->coding_type = coding_MS_IMA;
vgmstream->interleave_block_size = block_align;
vgmstream->layout_type = layout_none;
break;
#ifdef VGM_USE_FFMPEG
case 0x0800: /* Musepack (ex. Asphalt Xtreme) */
if (bits != -1) goto fail;
vgmstream->codec_data = init_ffmpeg_offset(streamFile, start_offset,stream_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
/* unlike standard .mpc, .vxn has no seek table so no need to fix */
//ffmpeg_set_force_seek(vgmstream->codec_data);
break;
#endif
default:
VGM_LOG("VXN: unknown codec 0x%02x\n", codec);
goto fail;
}
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}
#include "meta.h"
#include "../coding/coding.h"
/* VXN - from Gameloft mobile games */
VGMSTREAM* init_vgmstream_vxn(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int loop_flag = 0, channel_count, codec, sample_rate, block_align, bits, num_samples;
off_t start_offset, stream_offset, chunk_offset, first_offset = 0x00;
size_t stream_size;
int total_subsongs, target_subsong = sf->stream_index;
/* checks */
if (!check_extensions(sf,"vxn"))
goto fail;
if (read_u32be(0x00,sf) != 0x566F784E) /* "VoxN" */
goto fail;
if (read_u32le(0x10,sf) != get_streamfile_size(sf))
goto fail;
/* header is RIFF-like with many custom chunks */
if (!find_chunk_le(sf, 0x41666D74,first_offset,0, &chunk_offset,NULL)) /* "Afmt" */
goto fail;
codec = read_u16le(chunk_offset+0x00, sf);
channel_count = read_u16le(chunk_offset+0x02, sf);
sample_rate = read_u32le(chunk_offset+0x04, sf);
block_align = read_u16le(chunk_offset+0x08, sf);
bits = read_16bitLE(chunk_offset+0x0a, sf);
/* files are divided into segment subsongs, often a leadout and loop in that order
* (the "Plst" and "Rule" chunks may have order info) */
if (!find_chunk_le(sf, 0x5365676D,first_offset,0, &chunk_offset,NULL)) /* "Segm" */
goto fail;
total_subsongs = read_u32le(chunk_offset+0x00, sf);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
stream_offset = read_u32le(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x00, sf);
stream_size = read_u32le(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x04, sf);
num_samples = read_u32le(chunk_offset+0x04 + (target_subsong-1)*0x18 + 0x08, sf);
if (!find_chunk_le(sf, 0x44617461,first_offset,0, &chunk_offset,NULL)) /* "Data" */
goto fail;
start_offset = chunk_offset + stream_offset;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_VXN;
switch (codec) {
case 0x0001: /* PCM */
if (bits != 16) goto fail;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->interleave_block_size = block_align;
vgmstream->layout_type = layout_interleave;
break;
case 0x0002: /* MSADPCM (ex. Asphalt 7) */
if (bits != 4) goto fail;
vgmstream->coding_type = coding_MSADPCM;
vgmstream->frame_size = block_align;
vgmstream->layout_type = layout_none;
if (find_chunk_le(sf, 0x4D736165,first_offset,0, &chunk_offset,NULL)) { /* "Msae" */
if (!msadpcm_check_coefs(sf, chunk_offset + 0x02))
goto fail;
}
break;
case 0x0011: /* MS-IMA (ex. Asphalt 6) */
if (bits != 4 && bits != 16) goto fail; /* 16=common, 4=Asphalt Injection (Vita) */
vgmstream->coding_type = coding_MS_IMA;
vgmstream->interleave_block_size = block_align;
vgmstream->layout_type = layout_none;
break;
#ifdef VGM_USE_FFMPEG
case 0x0800: /* Musepack (ex. Asphalt Xtreme) */
if (bits != -1) goto fail;
vgmstream->codec_data = init_ffmpeg_offset(sf, start_offset,stream_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
/* unlike standard .mpc, .vxn has no seek table so no need to fix */
//ffmpeg_set_force_seek(vgmstream->codec_data);
break;
#endif
default:
VGM_LOG("VXN: unknown codec 0x%02x\n", codec);
goto fail;
}
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -77,6 +77,8 @@ typedef struct {
replay_gain_type_t gain_type;
replay_gain_type_t clip_type;
int is_xmplay;
} winamp_settings_t;
/* current song config */
@ -432,67 +434,75 @@ int priority_values[] = {
// todo finish UNICODE (requires IPC_GETINIDIRECTORYW from later SDKs to read the ini path properly)
/* Winamp INI reader */
static void ini_get_filename(TCHAR *iniFile) {
static void ini_get_filename(TCHAR *inifile) {
if (IsWindow(input_module.hMainWindow) && SendMessage(input_module.hMainWindow, WM_WA_IPC,0,IPC_GETVERSION) >= 0x5000) {
/* newer Winamp with per-user settings */
TCHAR *iniDir = (TCHAR *)SendMessage(input_module.hMainWindow, WM_WA_IPC, 0, IPC_GETINIDIRECTORY);
cfg_strncpy(iniFile, iniDir, PATH_LIMIT);
TCHAR *ini_dir = (TCHAR *)SendMessage(input_module.hMainWindow, WM_WA_IPC, 0, IPC_GETINIDIRECTORY);
cfg_strncpy(inifile, ini_dir, PATH_LIMIT);
cfg_strncat(iniFile, TEXT("\\Plugins\\"), PATH_LIMIT);
cfg_strncat(inifile, TEXT("\\Plugins\\"), PATH_LIMIT);
/* can't be certain that \Plugins already exists in the user dir */
CreateDirectory(iniFile,NULL);
CreateDirectory(inifile,NULL);
cfg_strncat(iniFile, CONFIG_INI_NAME, PATH_LIMIT);
cfg_strncat(inifile, CONFIG_INI_NAME, PATH_LIMIT);
}
else {
/* older winamp with single settings */
TCHAR *lastSlash;
GetModuleFileName(NULL, iniFile, PATH_LIMIT);
lastSlash = cfg_strrchr(iniFile, TEXT('\\'));
GetModuleFileName(NULL, inifile, PATH_LIMIT);
lastSlash = cfg_strrchr(inifile, TEXT('\\'));
*(lastSlash + 1) = 0;
cfg_strncat(iniFile, TEXT("Plugins\\") CONFIG_INI_NAME,PATH_LIMIT);
/* XMPlay doesn't have a "plugins" subfolder */
if (settings.is_xmplay)
cfg_strncat(inifile, CONFIG_INI_NAME,PATH_LIMIT);
else
cfg_strncat(inifile, TEXT("Plugins\\") CONFIG_INI_NAME,PATH_LIMIT);
/* Maybe should query IPC_GETINIDIRECTORY and use that, not sure what ancient Winamps need.
* There must be some proper way to handle dirs since other Winamp plugins save config in
* XMPlay correctly (this feels like archaeology, try later) */
}
}
static void ini_get_d(const char *iniFile, const char *entry, double defval, double *p_val) {
static void ini_get_d(const char *inifile, const char *entry, double defval, double *p_val) {
TCHAR buf[256];
TCHAR defbuf[256];
int consumed, res;
cfg_sprintf(defbuf, TEXT("%.2lf"), defval);
GetPrivateProfileString(CONFIG_APP_NAME, entry, defbuf, buf, 256, iniFile);
GetPrivateProfileString(CONFIG_APP_NAME, entry, defbuf, buf, 256, inifile);
res = cfg_sscanf(buf, TEXT("%lf%n"), p_val, &consumed);
if (res < 1 || consumed != cfg_strlen(buf) || *p_val < 0) {
*p_val = defval;
}
}
static void ini_get_i(const char *iniFile, const char *entry, int defval, int *p_val, int min, int max) {
*p_val = GetPrivateProfileInt(CONFIG_APP_NAME, entry, defval, iniFile);
static void ini_get_i(const char *inifile, const char *entry, int defval, int *p_val, int min, int max) {
*p_val = GetPrivateProfileInt(CONFIG_APP_NAME, entry, defval, inifile);
if (*p_val < min || *p_val > max) {
*p_val = defval;
}
}
static void ini_get_b(const char *iniFile, const char *entry, int defval, int *p_val) {
ini_get_i(iniFile, entry, defval, p_val, 0, 1);
static void ini_get_b(const char *inifile, const char *entry, int defval, int *p_val) {
ini_get_i(inifile, entry, defval, p_val, 0, 1);
}
static void ini_set_d(const char *iniFile, const char *entry, double val) {
static void ini_set_d(const char *inifile, const char *entry, double val) {
TCHAR buf[256];
cfg_sprintf(buf, TEXT("%.2lf"), val);
WritePrivateProfileString(CONFIG_APP_NAME, entry, buf, iniFile);
WritePrivateProfileString(CONFIG_APP_NAME, entry, buf, inifile);
}
static void ini_set_i(const char *iniFile, const char *entry, int val) {
static void ini_set_i(const char *inifile, const char *entry, int val) {
TCHAR buf[32];
cfg_sprintf(buf, TEXT("%d"), val);
WritePrivateProfileString(CONFIG_APP_NAME, entry, buf, iniFile);
WritePrivateProfileString(CONFIG_APP_NAME, entry, buf, inifile);
}
static void ini_set_b(const char *iniFile, const char *entry, int val) {
ini_set_i(iniFile, entry, val);
static void ini_set_b(const char *inifile, const char *entry, int val) {
ini_set_i(inifile, entry, val);
}
static void load_defaults(winamp_settings_t *defaults) {
@ -1062,12 +1072,14 @@ void winamp_About(HWND hwndParent) {
/* called at program init */
void winamp_Init() {
settings.is_xmplay = is_xmplay();
/* get ini config */
load_defaults(&defaults);
load_config(&settings, &defaults);
/* XMPlay with in_vgmstream doesn't support most IPC_x messages so no playlist manipulation */
if (is_xmplay()) {
if (settings.is_xmplay) {
settings.disable_subsongs = 1;
}