Updated VGMStream to r1776-97-g845961bb

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
main
Christopher Snowhill 2022-10-11 22:45:07 -07:00
parent 7ad895b95c
commit 929ab11738
43 changed files with 2565 additions and 476 deletions

View File

@ -10,9 +10,7 @@
8301659A1F256BD000CA0941 /* txth.c in Sources */ = {isa = PBXBuildFile; fileRef = 830165971F256BD000CA0941 /* txth.c */; };
8301659B1F256BD000CA0941 /* ea_schl_fixed.c in Sources */ = {isa = PBXBuildFile; fileRef = 830165981F256BD000CA0941 /* ea_schl_fixed.c */; };
8301659C1F256BD000CA0941 /* nds_strm_ffta2.c in Sources */ = {isa = PBXBuildFile; fileRef = 830165991F256BD000CA0941 /* nds_strm_ffta2.c */; };
83031EC4243C50A800C3F3E0 /* circus_decoder_miniz.h in Headers */ = {isa = PBXBuildFile; fileRef = 83031EBE243C50A700C3F3E0 /* circus_decoder_miniz.h */; };
83031EC5243C50A800C3F3E0 /* circus_decoder_lib_data.h in Headers */ = {isa = PBXBuildFile; fileRef = 83031EBF243C50A800C3F3E0 /* circus_decoder_lib_data.h */; };
83031EC6243C50A800C3F3E0 /* circus_decoder_miniz.c in Sources */ = {isa = PBXBuildFile; fileRef = 83031EC0243C50A800C3F3E0 /* circus_decoder_miniz.c */; };
83031EC7243C50A800C3F3E0 /* circus_decoder_lib.h in Headers */ = {isa = PBXBuildFile; fileRef = 83031EC1243C50A800C3F3E0 /* circus_decoder_lib.h */; };
83031EC8243C50A800C3F3E0 /* circus_decoder_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = 83031EC2243C50A800C3F3E0 /* circus_decoder_lib.c */; };
83031EC9243C50A800C3F3E0 /* circus_decoder_lzxpcm.h in Headers */ = {isa = PBXBuildFile; fileRef = 83031EC3243C50A800C3F3E0 /* circus_decoder_lzxpcm.h */; };
@ -89,6 +87,12 @@
8315958720FEC832007002F0 /* asf_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 8315958320FEC831007002F0 /* asf_decoder.c */; };
8315958920FEC83F007002F0 /* asf.c in Sources */ = {isa = PBXBuildFile; fileRef = 8315958820FEC83F007002F0 /* asf.c */; };
8317C24C26982CC1007DD0B8 /* sspr.c in Sources */ = {isa = PBXBuildFile; fileRef = 8317C24826982CC1007DD0B8 /* sspr.c */; };
8319017B28F67EE100B70711 /* miniz.h in Headers */ = {isa = PBXBuildFile; fileRef = 8319017928F67EE000B70711 /* miniz.h */; };
8319017C28F67EE100B70711 /* miniz.c in Sources */ = {isa = PBXBuildFile; fileRef = 8319017A28F67EE100B70711 /* miniz.c */; };
8319018028F67F1500B70711 /* ice_decoder_icelib.h in Headers */ = {isa = PBXBuildFile; fileRef = 8319017D28F67F1500B70711 /* ice_decoder_icelib.h */; };
8319018128F67F1500B70711 /* ice_decoder_icelib.c in Sources */ = {isa = PBXBuildFile; fileRef = 8319017E28F67F1500B70711 /* ice_decoder_icelib.c */; };
8319018228F67F1500B70711 /* ice_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 8319017F28F67F1500B70711 /* ice_decoder.c */; };
8319018428F67F2B00B70711 /* bigrp.c in Sources */ = {isa = PBXBuildFile; fileRef = 8319018328F67F2B00B70711 /* bigrp.c */; };
831BA6181EAC61A500CF89B0 /* adx.c in Sources */ = {isa = PBXBuildFile; fileRef = 831BA60E1EAC61A500CF89B0 /* adx.c */; };
831BA6191EAC61A500CF89B0 /* ogl.c in Sources */ = {isa = PBXBuildFile; fileRef = 831BA60F1EAC61A500CF89B0 /* ogl.c */; };
831BA61A1EAC61A500CF89B0 /* ps2_vds_vdm.c in Sources */ = {isa = PBXBuildFile; fileRef = 831BA6101EAC61A500CF89B0 /* ps2_vds_vdm.c */; };
@ -832,9 +836,7 @@
830165971F256BD000CA0941 /* txth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = txth.c; sourceTree = "<group>"; };
830165981F256BD000CA0941 /* ea_schl_fixed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ea_schl_fixed.c; sourceTree = "<group>"; };
830165991F256BD000CA0941 /* nds_strm_ffta2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = nds_strm_ffta2.c; sourceTree = "<group>"; };
83031EBE243C50A700C3F3E0 /* circus_decoder_miniz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = circus_decoder_miniz.h; sourceTree = "<group>"; };
83031EBF243C50A800C3F3E0 /* circus_decoder_lib_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = circus_decoder_lib_data.h; sourceTree = "<group>"; };
83031EC0243C50A800C3F3E0 /* circus_decoder_miniz.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = circus_decoder_miniz.c; sourceTree = "<group>"; };
83031EC1243C50A800C3F3E0 /* circus_decoder_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = circus_decoder_lib.h; sourceTree = "<group>"; };
83031EC2243C50A800C3F3E0 /* circus_decoder_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = circus_decoder_lib.c; sourceTree = "<group>"; };
83031EC3243C50A800C3F3E0 /* circus_decoder_lzxpcm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = circus_decoder_lzxpcm.h; sourceTree = "<group>"; };
@ -911,6 +913,12 @@
8315958320FEC831007002F0 /* asf_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asf_decoder.c; sourceTree = "<group>"; };
8315958820FEC83F007002F0 /* asf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = asf.c; sourceTree = "<group>"; };
8317C24826982CC1007DD0B8 /* sspr.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sspr.c; sourceTree = "<group>"; };
8319017928F67EE000B70711 /* miniz.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = miniz.h; sourceTree = "<group>"; };
8319017A28F67EE100B70711 /* miniz.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = miniz.c; sourceTree = "<group>"; };
8319017D28F67F1500B70711 /* ice_decoder_icelib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ice_decoder_icelib.h; sourceTree = "<group>"; };
8319017E28F67F1500B70711 /* ice_decoder_icelib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ice_decoder_icelib.c; sourceTree = "<group>"; };
8319017F28F67F1500B70711 /* ice_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ice_decoder.c; sourceTree = "<group>"; };
8319018328F67F2B00B70711 /* bigrp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bigrp.c; sourceTree = "<group>"; };
831BA60E1EAC61A500CF89B0 /* adx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = adx.c; sourceTree = "<group>"; };
831BA60F1EAC61A500CF89B0 /* ogl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ogl.c; sourceTree = "<group>"; };
831BA6101EAC61A500CF89B0 /* ps2_vds_vdm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_vds_vdm.c; sourceTree = "<group>"; };
@ -1792,8 +1800,6 @@
83031EC2243C50A800C3F3E0 /* circus_decoder_lib.c */,
83031EC1243C50A800C3F3E0 /* circus_decoder_lib.h */,
83031EC3243C50A800C3F3E0 /* circus_decoder_lzxpcm.h */,
83031EC0243C50A800C3F3E0 /* circus_decoder_miniz.c */,
83031EBE243C50A700C3F3E0 /* circus_decoder_miniz.h */,
832BF7FC21E050B6006F50F1 /* circus_decoder.c */,
8346D97F25BF83B200D1A8B0 /* coding_utils_samples.h */,
831BA6221EAC61CB00CF89B0 /* coding_utils.c */,
@ -1824,6 +1830,9 @@
83FC416F26D32FF5009A2022 /* hca_decoder_clhca.c */,
83FC416E26D32FF5009A2022 /* hca_decoder_clhca.h */,
832389511D224C0800482226 /* hca_decoder.c */,
8319017E28F67F1500B70711 /* ice_decoder_icelib.c */,
8319017D28F67F1500B70711 /* ice_decoder_icelib.h */,
8319017F28F67F1500B70711 /* ice_decoder.c */,
836F6DEA18BDC2180095E648 /* ima_decoder.c */,
83F1EE28245D4FB10076E182 /* imuse_decoder.c */,
836F6DEB18BDC2180095E648 /* l5_555_decoder.c */,
@ -1994,6 +2003,7 @@
83A5F75E198DF021009AF94C /* bfwav.c */,
837CEAD723487E8300E62A4A /* bgw_streamfile.h */,
836F6E3818BDC2180095E648 /* bgw.c */,
8319018328F67F2B00B70711 /* bigrp.c */,
83299FCE1E7660C7003A3242 /* bik.c */,
83031ECF243C50DE00C3F3E0 /* bkhd.c */,
837CEAD423487E8300E62A4A /* bmp_konami.c */,
@ -2438,6 +2448,8 @@
83D26A7F26E66DC2001A9475 /* log.h */,
8315868826F586F900803A3A /* m2_psb.c */,
8315868926F586F900803A3A /* m2_psb.h */,
8319017A28F67EE100B70711 /* miniz.c */,
8319017928F67EE000B70711 /* miniz.h */,
8339B324280FDF4B0076F74B /* text_reader.c */,
8339B325280FDF4B0076F74B /* text_reader.h */,
);
@ -2568,6 +2580,7 @@
83FBD506235D31F800D35BCD /* riff_ogg_streamfile.h in Headers */,
8339B327280FDF4B0076F74B /* text_reader.h in Headers */,
836F6F9A18BDC2190095E648 /* meta.h in Headers */,
8319017B28F67EE100B70711 /* miniz.h in Headers */,
83A8BAE625667AA8000F5F3F /* ps2_enth_streamfile.h in Headers */,
83256CE428666C620036D9C0 /* abi_align.h in Headers */,
8306B0D820984590000302D4 /* ea_eaac_streamfile.h in Headers */,
@ -2594,7 +2607,6 @@
83256CD828666C620036D9C0 /* gapless.h in Headers */,
834FE0EF215C79ED000A5D3D /* xvag_streamfile.h in Headers */,
83256CC428666C620036D9C0 /* debug.h in Headers */,
83031EC4243C50A800C3F3E0 /* circus_decoder_miniz.h in Headers */,
83256CCB28666C620036D9C0 /* mangle.h in Headers */,
83256CD728666C620036D9C0 /* synth_mono.h in Headers */,
8349A91B1FE6258200E26435 /* adx_keys.h in Headers */,
@ -2602,6 +2614,7 @@
83269DD22399F5DE00F49FE3 /* nus3bank_streamfile.h in Headers */,
83AA5D251F6E2F9C0020821C /* hca_keys.h in Headers */,
83031EC7243C50A800C3F3E0 /* circus_decoder_lib.h in Headers */,
8319018028F67F1500B70711 /* ice_decoder_icelib.h in Headers */,
83256CDA28666C620036D9C0 /* l2tables.h in Headers */,
83256CC828666C620036D9C0 /* getbits.h in Headers */,
83256CC728666C620036D9C0 /* optimize.h in Headers */,
@ -2922,6 +2935,7 @@
836F6F6518BDC2190095E648 /* 2dx9.c in Sources */,
830EBE102004655D0023AA10 /* atrac9_decoder.c in Sources */,
836F700818BDC2190095E648 /* ps2_vms.c in Sources */,
8319018428F67F2B00B70711 /* bigrp.c in Sources */,
836F702418BDC2190095E648 /* rwsd.c in Sources */,
830EBE142004656E0023AA10 /* ktss.c in Sources */,
836F6F6618BDC2190095E648 /* aax.c in Sources */,
@ -2940,6 +2954,7 @@
8349A9101FE6258200E26435 /* ea_eaac.c in Sources */,
836F700F18BDC2190095E648 /* ps2_xa30.c in Sources */,
835B9B912730BF2D00F87EE3 /* lopu_fb.c in Sources */,
8319017C28F67EE100B70711 /* miniz.c in Sources */,
8346D97B25BF838C00D1A8B0 /* ktac.c in Sources */,
8349A8ED1FE6253900E26435 /* blocked_ea_sns.c in Sources */,
830595D8277EEAA500EBFAAE /* ffmpeg_decoder_custom_mp4.c in Sources */,
@ -2998,6 +3013,7 @@
836F703918BDC2190095E648 /* vgs.c in Sources */,
834FE0F8215C79ED000A5D3D /* adpcm_capcom.c in Sources */,
836F6F2C18BDC2190095E648 /* mp4_aac_decoder.c in Sources */,
8319018228F67F1500B70711 /* ice_decoder.c in Sources */,
836F701F18BDC2190095E648 /* riff.c in Sources */,
83AA5D191F6E2F600020821C /* ea_xas_decoder.c in Sources */,
836F6F9318BDC2190095E648 /* ivaud.c in Sources */,
@ -3070,7 +3086,6 @@
836F6FE618BDC2190095E648 /* ps2_mcg.c in Sources */,
83AA5D241F6E2F9C0020821C /* awc.c in Sources */,
8349A8E91FE6253900E26435 /* blocked_ea_1snh.c in Sources */,
83031EC6243C50A800C3F3E0 /* circus_decoder_miniz.c in Sources */,
8306B0E620984590000302D4 /* msb_msh.c in Sources */,
836F702918BDC2190095E648 /* sat_sap.c in Sources */,
8351F3292212B53400A606E4 /* dsa_decoder.c in Sources */,
@ -3215,6 +3230,7 @@
83A21F88201D8981000F04B9 /* ogg_vorbis.c in Sources */,
837CEAF923487F2C00E62A4A /* xavs.c in Sources */,
836F6F8E18BDC2190095E648 /* halpst.c in Sources */,
8319018128F67F1500B70711 /* ice_decoder_icelib.c in Sources */,
836F6FEE18BDC2190095E648 /* ps2_p2bt.c in Sources */,
836F702618BDC2190095E648 /* s14_sss.c in Sources */,
834FE102215C79ED000A5D3D /* rfrm.c in Sources */,

View File

@ -21,7 +21,7 @@
/* use miniz (API-compatible) to avoid adding external zlib just for this codec
* - https://github.com/richgel999/miniz */
#include "circus_decoder_miniz.h"
#include "../util/miniz.h"
//#include "zlib.h"

View File

@ -171,7 +171,7 @@ int msadpcm_check_coefs(STREAMFILE* sf, uint32_t offset);
/* yamaha_decoder */
void decode_aica(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo);
void decode_aica(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo, int is_high_first);
void decode_cp_ym(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo);
void decode_aska(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, size_t frame_size);
void decode_nxap(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do);
@ -353,6 +353,16 @@ void seek_tac(tac_codec_data* data, int32_t num_sample);
void free_tac(tac_codec_data* data);
/* ice_decoder */
typedef struct ice_codec_data ice_codec_data;
ice_codec_data* init_ice(STREAMFILE* sf, int subsong);
void decode_ice(ice_codec_data* data, sample_t* outbuf, int32_t samples_to_do);
void reset_ice(ice_codec_data* data);
void seek_ice(ice_codec_data* data, int32_t num_sample);
void free_ice(ice_codec_data* data);
#ifdef VGM_USE_VORBIS
/* ogg_vorbis_decoder */
typedef struct ogg_vorbis_codec_data ogg_vorbis_codec_data;

View File

@ -0,0 +1,138 @@
#include "coding.h"
#include "ice_decoder_icelib.h"
typedef struct {
STREAMFILE* sf;
int offset;
} icelib_io_t;
struct ice_codec_data {
STREAMFILE* sf;
int channels;
icesnd_handle_t* ctx;
icelib_io_t io;
};
static void icelib_set_callbacks(icesnd_callback_t* cb, STREAMFILE* sf, icelib_io_t* io);
ice_codec_data* init_ice(STREAMFILE* sf, int subsong) {
ice_codec_data* data = NULL;
data = calloc(1, sizeof(ice_codec_data));
if (!data) goto fail;
data->sf = reopen_streamfile(sf, 0);
if (!data->sf) goto fail;
{
icesnd_callback_t cb = {0};
icesnd_info_t info = {0};
int err;
icelib_set_callbacks(&cb, data->sf, &data->io);
data->ctx = icesnd_init(subsong, &cb);
if (!data->ctx) goto fail;
err = icesnd_info(data->ctx, &info);
if (err < ICESND_RESULT_OK) goto fail;
data->channels = info.channels;
}
return data;
fail:
free_ice(data);
return NULL;
}
void decode_ice(ice_codec_data* data, sample_t* outbuf, int32_t samples_to_do) {
int channels = data->channels;
while (samples_to_do > 0) {
int done = icesnd_decode(data->ctx, outbuf, samples_to_do);
if (done <= 0) goto decode_fail;
outbuf += done * channels;
samples_to_do -= done;
}
return;
decode_fail:
VGM_LOG("ICE: decode error\n");
memset(outbuf, 0, samples_to_do * channels * sizeof(sample_t));
}
void reset_ice(ice_codec_data* data) {
if (!data) return;
icesnd_reset(data->ctx, 0);
}
void seek_ice(ice_codec_data* data, int32_t num_sample) {
if (!data) return;
//todo discard (this should only be called when looping)
icesnd_reset(data->ctx, 1);
}
void free_ice(ice_codec_data* data) {
if (!data) return;
close_streamfile(data->sf);
icesnd_free(data->ctx);
free(data);
}
/* ************************* */
static int icelib_read(void* dst, int size, int n, void* arg) {
icelib_io_t* io = arg;
int bytes_read, items_read;
bytes_read = read_streamfile(dst, io->offset, size * n, io->sf);
items_read = bytes_read / size;
io->offset += bytes_read;
return items_read;
}
static int icelib_seek(void* arg, int offset, int whence) {
icelib_io_t* io = arg;
int base_offset, new_offset;
switch (whence) {
case ICESND_SEEK_SET:
base_offset = 0;
break;
case ICESND_SEEK_CUR:
base_offset = io->offset;
break;
case ICESND_SEEK_END:
base_offset = get_streamfile_size(io->sf);
break;
default:
return -1;
break;
}
new_offset = base_offset + offset;
if (new_offset < 0 /*|| new_offset > get_streamfile_size(config->sf)*/) {
return -1; /* unseekable */
}
else {
io->offset = new_offset;
return 0;
}
}
static void icelib_set_callbacks(icesnd_callback_t* cb, STREAMFILE* sf, icelib_io_t* io) {
io->offset = 0;
io->sf = sf;
cb->arg = io;
cb->read = icelib_read;
cb->seek = icelib_seek;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
#ifndef _ICELIB_H_
#define _ICELIB_H_
#include <stdint.h>
/* Decodes Inti Creates's "ICE" engine BIGRP sounds. */
#define ICESND_CODEC_RANGE 0x00
#define ICESND_CODEC_DATA 0x01
#define ICESND_CODEC_MIDI 0x02
#define ICESND_CODEC_DCT 0x03
#define ICESND_RESULT_OK 0
#define ICESND_ERROR_HEADER -1
#define ICESND_ERROR_SETUP -2
#define ICESND_ERROR_DECODE -3
typedef struct icesnd_handle_t icesnd_handle_t;
#define ICESND_SEEK_SET 0
#define ICESND_SEEK_CUR 1
#define ICESND_SEEK_END 2
typedef struct {
/* whole file in memory (for testing) */
const uint8_t* filebuf;
int filebuf_size;
/* custom IO */
void* arg;
int (*read)(void* dst, int size, int n, void* arg);
int (*seek)(void* arg, int offset, int whence);
} icesnd_callback_t;
/* Inits ICE lib with config.
* Original code expects all data in memory, but this allows setting read callbacks
* (making it feed-style was a bit complex due to how data is laid out) */
icesnd_handle_t* icesnd_init(int target_subsong, icesnd_callback_t* cb);
void icesnd_free(icesnd_handle_t* handle);
/* resets the decoder. If loop_starts and file loops and
* (format is not seekable but separated into intro+body blocks) */
void icesnd_reset(icesnd_handle_t* handle, int loop_start);
/* Decodes up to samples for N channels into sbuf (interleaved). Returns samples done,
* 0 if not possible (non-looped files past end) or negative on error.
* May return less than wanted samples on block boundaries.
*
* It's designed to decode an arbitrary number of samples, as data isn't divided into frames (original
* player does sample_rate/60.0 at a time). Codec 0 is aligned to 100 samples and codec 3 to 16 though. */
int icesnd_decode(icesnd_handle_t* handle, int16_t* sbuf, int max_samples);
typedef struct {
int total_subsongs;
int codec;
int sample_rate;
int channels;
int loop_start;
int num_samples;
int loop_flag;
} icesnd_info_t;
/* loads info */
int icesnd_info(icesnd_handle_t* handle, icesnd_info_t* info);
#endif

View File

@ -17,8 +17,9 @@ static int build_header_identification(uint8_t* buf, size_t bufsize, int channel
static int build_header_comment(uint8_t* buf, size_t bufsize);
static int build_header_setup(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf);
static int load_fvs_file_single(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf);
static int load_fvs_file_multi(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf);
#if !(FSB_VORBIS_USE_PRECOMPILED_FVS)
static int load_fvs_file(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf);
#endif
static int load_fvs_array(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf);
@ -58,7 +59,7 @@ int vorbis_custom_parse_packet_fsb(VGMSTREAMCHANNEL* stream, vorbis_custom_codec
size_t bytes;
/* get next packet size from the FSB 16b header (doesn't count this 16b) */
data->op.bytes = (uint16_t)read_16bitLE(stream->offset, stream->streamfile);
data->op.bytes = read_u16le(stream->offset, stream->streamfile);
stream->offset += 2;
if (data->op.bytes == 0 || data->op.bytes == 0xFFFF || data->op.bytes > data->buffer_size) goto fail; /* EOF or end padding */
@ -108,16 +109,16 @@ static int build_header_identification(uint8_t* buf, size_t bufsize, int channel
}
blocksizes = (exp_blocksize_0 << 4) | (exp_blocksize_1);
put_8bit (buf+0x00, 0x01); /* packet_type (id) */
put_u8 (buf+0x00, 0x01); /* packet_type (id) */
memcpy (buf+0x01, "vorbis", 6); /* id */
put_32bitLE(buf+0x07, 0x00); /* vorbis_version (fixed) */
put_8bit (buf+0x0b, channels); /* audio_channels */
put_32bitLE(buf+0x0c, sample_rate); /* audio_sample_rate */
put_32bitLE(buf+0x10, 0x00); /* bitrate_maximum (optional hint) */
put_32bitLE(buf+0x14, 0x00); /* bitrate_nominal (optional hint) */
put_32bitLE(buf+0x18, 0x00); /* bitrate_minimum (optional hint) */
put_8bit (buf+0x1c, blocksizes); /* blocksize_0 + blocksize_1 nibbles */
put_8bit (buf+0x1d, 0x01); /* framing_flag (fixed) */
put_u32le(buf+0x07, 0x00); /* vorbis_version (fixed) */
put_u8 (buf+0x0b, channels); /* audio_channels */
put_s32le(buf+0x0c, sample_rate); /* audio_sample_rate */
put_u32le(buf+0x10, 0x00); /* bitrate_maximum (optional hint) */
put_u32le(buf+0x14, 0x00); /* bitrate_nominal (optional hint) */
put_u32le(buf+0x18, 0x00); /* bitrate_minimum (optional hint) */
put_u8 (buf+0x1c, blocksizes); /* blocksize_0 + blocksize_1 nibbles */
put_u8 (buf+0x1d, 0x01); /* framing_flag (fixed) */
return bytes;
}
@ -127,12 +128,12 @@ static int build_header_comment(uint8_t* buf, size_t bufsize) {
if (bytes > bufsize) return 0;
put_8bit (buf+0x00, 0x03); /* packet_type (comments) */
memcpy (buf+0x01, "vorbis", 6); /* id */
put_32bitLE(buf+0x07, 0x09); /* vendor_length */
memcpy (buf+0x0b, "vgmstream", 9); /* vendor_string */
put_32bitLE(buf+0x14, 0x00); /* user_comment_list_length */
put_8bit (buf+0x18, 0x01); /* framing_flag (fixed) */
put_u8 (buf+0x00, 0x03); /* packet_type (comments) */
memcpy (buf+0x01, "vorbis", 6); /* id */
put_u32le(buf+0x07, 0x09); /* vendor_length */
memcpy (buf+0x0b, "vgmstream", 9); /* vendor_string */
put_u32le(buf+0x14, 0x00); /* user_comment_list_length */
put_u8 (buf+0x18, 0x01); /* framing_flag (fixed) */
return bytes;
}
@ -145,49 +146,20 @@ static int build_header_setup(uint8_t* buf, size_t bufsize, uint32_t setup_id, S
if (bytes)
return bytes;
#if !(FSB_VORBIS_USE_PRECOMPILED_FVS)
/* try to load from external files */
bytes = load_fvs_file_single(buf, bufsize, setup_id, sf);
if (bytes)
return bytes;
bytes = load_fvs_file_multi(buf, bufsize, setup_id, sf);
bytes = load_fvs_file(buf, bufsize, setup_id, sf);
if (bytes)
return bytes;
#endif
/* not found */
VGM_LOG("FSB Vorbis: setup_id %08x not found\n", setup_id);
return 0;
}
static int load_fvs_file_single(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf) {
STREAMFILE* sf_setup = NULL;
/* get from artificial external file (used if compiled without codebooks) */
{
char setupname[0x20];
snprintf(setupname, sizeof(setupname), ".fvs_%08x", setup_id);
sf_setup = open_streamfile_by_filename(sf, setupname);
}
/* get codebook and copy to buffer */
if (sf_setup) {
size_t bytes = sf_setup->get_size(sf_setup);
if (bytes > bufsize) goto fail;
if (read_streamfile(buf, 0, bytes, sf_setup) != bytes)
goto fail;
close_streamfile(sf_setup);
return bytes;
}
fail:
close_streamfile(sf_setup);
return 0;
}
static int load_fvs_file_multi(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf) {
#if !(FSB_VORBIS_USE_PRECOMPILED_FVS)
static int load_fvs_file(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf) {
STREAMFILE* sf_setup = NULL;
/* from to get from artificial external file (used if compiled without codebooks) */
@ -230,6 +202,7 @@ fail:
if (sf_setup) sf_setup->close(sf_setup);
return 0;
}
#endif
static int load_fvs_array(uint8_t* buf, size_t bufsize, uint32_t setup_id, STREAMFILE* sf) {
#if FSB_VORBIS_USE_PRECOMPILED_FVS

View File

@ -34,7 +34,9 @@ static int ww2ogg_generate_vorbis_packet(bitstream_t* ow, bitstream_t* iw, wpack
static int ww2ogg_generate_vorbis_setup(bitstream_t* ow, bitstream_t* iw, vorbis_custom_codec_data* data, size_t packet_size, STREAMFILE* sf);
static int load_wvc(uint8_t* ibuf, size_t ibufsize, uint32_t codebook_id, wwise_setup_t setup_type, STREAMFILE* sf);
#if !(WWISE_VORBIS_USE_PRECOMPILED_WVC)
static int load_wvc_file(uint8_t* buf, size_t bufsize, uint32_t codebook_id, STREAMFILE* sf);
#endif
static int load_wvc_array(uint8_t* buf, size_t bufsize, uint32_t codebook_id, wwise_setup_t setup_type);
@ -1133,16 +1135,19 @@ static int load_wvc(uint8_t* ibuf, size_t ibufsize, uint32_t codebook_id, wwise_
if (bytes)
return bytes;
#if !(WWISE_VORBIS_USE_PRECOMPILED_WVC)
/* try to load from external file (ignoring type, just use file if found) */
bytes = load_wvc_file(ibuf, ibufsize, codebook_id, sf);
if (bytes)
return bytes;
#endif
/* not found */
VGM_LOG("Wwise Vorbis: codebook_id %04x not found\n", codebook_id);
return 0;
}
#if !(WWISE_VORBIS_USE_PRECOMPILED_WVC)
static int load_wvc_file(uint8_t* buf, size_t bufsize, uint32_t codebook_id, STREAMFILE* sf) {
STREAMFILE* sf_setup = NULL;
size_t wvc_size = 0;
@ -1185,6 +1190,7 @@ fail:
close_streamfile(sf_setup);
return 0;
}
#endif
static int load_wvc_array(uint8_t* buf, size_t bufsize, uint32_t codebook_id, wwise_setup_t setup_type) {
#if WWISE_VORBIS_USE_PRECOMPILED_WVC
@ -1217,7 +1223,7 @@ static int load_wvc_array(uint8_t* buf, size_t bufsize, uint32_t codebook_id, ww
}
}
// this can be used if the lists contained a 1:1 dump of the codebook files
// this can be used with 1:1 dump of the codebook file
#if 0
if (wvc == NULL) goto fail;
/* find codebook and copy to buffer */

View File

@ -44,12 +44,12 @@ static void yamaha_adpcmb_expand_nibble(uint8_t byte, int shift, int32_t* hist1,
/* Yamaha AICA expand, slightly filtered vs "ACM" Yamaha ADPCM, same as Creative ADPCM
* (some info from https://github.com/vgmrips/vgmplay, https://wiki.multimedia.cx/index.php/Creative_ADPCM) */
static void yamaha_aica_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, int nibble_shift, int32_t* hist1, int32_t* step_size, int16_t *out_sample) {
static void yamaha_aica_expand_nibble(uint8_t byte, int shift, int32_t* hist1, int32_t* step_size, int16_t *out_sample) {
int code, delta, sample;
*hist1 = *hist1 * 254 / 256; /* hist filter is vital to get correct waveform but not done in many emus */
code = ((read_8bit(byte_offset,stream->streamfile) >> nibble_shift))&0xf;
code = (byte >> shift) & 0xf;
delta = (*step_size * scale_delta[code]) / 8; /* 'mul' IMA with table (not sure if part of encoder) */
sample = *hist1 + delta;
@ -108,8 +108,8 @@ static void yamaha_capcom_expand_nibble(uint8_t byte, int shift, int32_t* hist1,
*/
/* Yamaha AICA ADPCM (also used in YMZ280B with high nibble first) */
void decode_aica(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo) {
/* Yamaha AICA ADPCM (also used in YMZ263B/YMZ280B with high nibble first) */
void decode_aica(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo, int is_high_first) {
int i, sample_count = 0;
int16_t out_sample;
int32_t hist1 = stream->adpcm_history1_16;
@ -120,14 +120,16 @@ void decode_aica(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacin
if (step_size > 0x6000) step_size = 0x6000;
for (i = first_sample; i < first_sample + samples_to_do; i++) {
off_t byte_offset = is_stereo ?
uint8_t byte;
off_t offset = is_stereo ?
stream->offset + i : /* stereo: one nibble per channel */
stream->offset + i/2; /* mono: consecutive nibbles */
int nibble_shift = is_stereo ?
(!(channel&1) ? 0:4) : /* even = low/L, odd = high/R */
(!(i&1) ? 0:4); /* low nibble first */
int shift = is_high_first ?
is_stereo ? (!(channel&1) ? 4:0) : (!(i&1) ? 4:0) : /* even = high/L, odd = low/R */
is_stereo ? (!(channel&1) ? 0:4) : (!(i&1) ? 0:4); /* even = low/L, odd = high/L */
yamaha_aica_expand_nibble(stream, byte_offset, nibble_shift, &hist1, &step_size, &out_sample);
byte = read_u8(offset, stream->streamfile);
yamaha_aica_expand_nibble(byte, shift, &hist1, &step_size, &out_sample);
outbuf[sample_count] = out_sample;
sample_count += channelspacing;
}

View File

@ -39,6 +39,11 @@ void free_codec(VGMSTREAM* vgmstream) {
free_tac(vgmstream->codec_data);
}
if (vgmstream->coding_type == coding_ICE_RANGE ||
vgmstream->coding_type == coding_ICE_DCT) {
free_ice(vgmstream->codec_data);
}
if (vgmstream->coding_type == coding_UBI_ADPCM) {
free_ubi_adpcm(vgmstream->codec_data);
}
@ -140,6 +145,11 @@ void seek_codec(VGMSTREAM* vgmstream) {
seek_tac(vgmstream->codec_data, vgmstream->loop_current_sample);
}
if (vgmstream->coding_type == coding_ICE_RANGE ||
vgmstream->coding_type == coding_ICE_DCT) {
seek_ice(vgmstream->codec_data, vgmstream->loop_current_sample);
}
if (vgmstream->coding_type == coding_UBI_ADPCM) {
seek_ubi_adpcm(vgmstream->codec_data, vgmstream->loop_current_sample);
}
@ -246,6 +256,11 @@ void reset_codec(VGMSTREAM* vgmstream) {
reset_tac(vgmstream->codec_data);
}
if (vgmstream->coding_type == coding_ICE_RANGE ||
vgmstream->coding_type == coding_ICE_DCT) {
reset_ice(vgmstream->codec_data);
}
if (vgmstream->coding_type == coding_UBI_ADPCM) {
reset_ubi_adpcm(vgmstream->codec_data);
}
@ -535,6 +550,9 @@ int get_vgmstream_samples_per_frame(VGMSTREAM* vgmstream) {
return 0; /* 1024 - delay/padding (which can be bigger than 1024) */
case coding_TAC:
return 0; /* 1024 - delay/padding */
case coding_ICE_RANGE:
case coding_ICE_DCT:
return 0; /* ~100 (range), ~16 (DCT) */
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
case coding_MP4_AAC:
return ((mp4_aac_codec_data*)vgmstream->codec_data)->samples_per_frame;
@ -1075,6 +1093,10 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_
case coding_TAC:
decode_tac(vgmstream, buffer, samples_to_do);
break;
case coding_ICE_RANGE:
case coding_ICE_DCT:
decode_ice(vgmstream->codec_data, buffer, samples_to_do);
break;
#ifdef VGM_USE_FFMPEG
case coding_FFmpeg:
decode_ffmpeg(vgmstream, buffer, samples_to_do, vgmstream->channels);
@ -1332,10 +1354,11 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_
case coding_AICA:
case coding_AICA_int: {
int is_stereo = (vgmstream->channels > 1 && vgmstream->coding_type == coding_AICA);
int is_high_first = vgmstream->codec_config == 1;
for (ch = 0; ch < vgmstream->channels; ch++) {
decode_aica(&vgmstream->ch[ch], buffer+ch,
vgmstream->channels, vgmstream->samples_into_block, samples_to_do, ch,
is_stereo);
is_stereo, is_high_first);
}
break;
}

View File

@ -105,6 +105,7 @@ static const char* extension_list[] = {
"bgm",
"bgw",
"bh2pcm",
"bigrp",
"bik",
"bika", //fake extension for .bik (to be removed)
"bik2",
@ -128,9 +129,10 @@ static const char* extension_list[] = {
"bvg",
"bwav",
"cads",
"caf",
"cbd2",
"ccc",
"ccc", //fake extension (to be removed)
"cd",
"cfn", //fake extension for CAF (renamed, to be removed?)
"chd", //txth/reserved [Donkey Konga (GC), Star Fox Assault (GC)]
@ -215,6 +217,7 @@ static const char* extension_list[] = {
"his",
"hps",
"hsf",
"hvqm",
"hwx", //txth/reserved [Star Wars Episode III (Xbox)]
"hx2",
"hx3",
@ -403,6 +406,7 @@ static const char* extension_list[] = {
"pnb",
"pona",
"pos",
"ps3",
"ps2stm", //fake extension for .stm (renamed? to be removed?)
"psb",
"psf",
@ -572,6 +576,8 @@ static const char* extension_list[] = {
"vb", //txth/reserved [Tantei Jinguji Saburo: Mikan no Rupo (PS1)]
"vbk",
"vbx", //txth/reserved [THE Taxi 2 (PS2)]
"vca", //txth/reserved [Pac-Man World (PS1)]
"vcb", //txth/reserved [Pac-Man World (PS1)]
"vds",
"vdm",
"vgi", //txth/reserved [Time Crisis II (PS2)]
@ -857,6 +863,8 @@ static const coding_info coding_info_list[] = {
{coding_RELIC, "Relic Codec"},
{coding_CRI_HCA, "CRI HCA"},
{coding_TAC, "tri-Ace Codec"},
{coding_ICE_RANGE, "Inti Creates Range Codec"},
{coding_ICE_DCT, "Inti Creates DCT Codec"},
#ifdef VGM_USE_VORBIS
{coding_OGG_VORBIS, "Ogg Vorbis"},
@ -1411,6 +1419,7 @@ static const meta_info meta_info_list[] = {
{meta_TT_AD, "Traveller's Tales AUDIO_DATA header"},
{meta_SNDZ, "Sony SNDZ header"},
{meta_VAB, "Sony VAB header"},
{meta_BIGRP, "Inti Creates .BIGRP header"},
};
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View File

@ -45,7 +45,7 @@ void block_update_ubi_sce(off_t block_offset, VGMSTREAM* vgmstream) {
/* First step is always 0x500, not sure if it's a bug or a feature but the game just takes it as is and
* ends up reading 0 from out-of-bounds memory area which causes a pop at the start. Yikes.
* It gets clampled later so the rest of the sound plays ok.
* It gets clamped later so the rest of the sound plays ok.
* We put 89 here as our special index which contains 0 to simulate this.
*/
if (vgmstream->ch[i].adpcm_step_index == 0x500) {

View File

@ -336,19 +336,26 @@ VGMSTREAM* init_vgmstream_ads_container(STREAMFILE* sf) {
size_t subfile_size;
/* checks */
if (!check_extensions(sf, "ads"))
goto fail;
if (read_32bitBE(0x00,sf) == 0x41445343 && /* "ADSC" */
read_32bitBE(0x04,sf) == 0x01000000) {
if (is_id32be(0x00,sf, "ADSC")) {
/* Kenka Bancho 2, Kamen Rider Hibiki/Kabuto, Shinjuku no Okami */
if (read_u32le(0x04,sf) != 0x01)
goto fail;
if (!check_extensions(sf, "ads"))
goto fail;
subfile_offset = 0x08;
}
else if (read_32bitBE(0x00,sf) == 0x63617669 && /* "cavi" */
read_32bitBE(0x04,sf) == 0x61207374 && /* "a st" */
read_32bitBE(0x08,sf) == 0x7265616D) { /* "ream" */
else if (is_id32be(0x00,sf, "cavi") &&
is_id32be(0x04,sf, "a st") &&
is_id32be(0x08,sf, "ream")) {
/* cavia games: Drakengard 1/2, Dragon Quest Yangus, GITS: Stand Alone Complex */
subfile_offset = 0x7d8;
/* .ads: assumed
* .cads: probable extension (found in bigfiles as LE field) */
if (!check_extensions(sf, "ads,cads"))
goto fail;
}
else {
goto fail;

View File

@ -138,10 +138,8 @@ VGMSTREAM* init_vgmstream_akb(STREAMFILE* sf) {
/* enable encryption */
if (version >= 3 && (flags & 8)) {
VGM_LOG("temp1\n");
temp_sf = setup_sqex_streamfile(sf, start_offset, stream_size, 1, 0x00, 0x00, "ogg");
if (!temp_sf) goto fail;
VGM_LOG("temp2\n");
ogg_vgmstream = init_vgmstream_ogg_vorbis_config(temp_sf, 0x00, &ovmi);
close_streamfile(temp_sf);

View File

@ -16,7 +16,7 @@ VGMSTREAM* init_vgmstream_awb_memory(STREAMFILE* sf, STREAMFILE* sf_acb) {
uint32_t offset, subfile_offset, subfile_next, subfile_size;
int total_subsongs, target_subsong = sf->stream_index;
uint8_t offset_size;
uint16_t alignment, subkey;
uint16_t waveid_alignment, offset_alignment, subkey;
int waveid;
@ -29,11 +29,11 @@ VGMSTREAM* init_vgmstream_awb_memory(STREAMFILE* sf, STREAMFILE* sf_acb) {
goto fail;
/* 0x04(1): version? 0x01=common, 0x02=2018+ (no apparent differences) */
offset_size = read_u8(0x05,sf);
/* 0x06(2): always 0x0002? */
total_subsongs = read_s32le(0x08,sf);
alignment = read_u16le(0x0c,sf);
subkey = read_u16le(0x0e,sf);
offset_size = read_u8 (0x05,sf);
waveid_alignment = read_u16le(0x06,sf); /* usually 0x02, rarely 0x04 [Voice of Cards: The Beasts of Burden (Switch)]*/
total_subsongs = read_s32le(0x08,sf);
offset_alignment = read_u16le(0x0c,sf);
subkey = read_u16le(0x0e,sf);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong > total_subsongs || total_subsongs <= 0) goto fail;
@ -42,11 +42,11 @@ VGMSTREAM* init_vgmstream_awb_memory(STREAMFILE* sf, STREAMFILE* sf_acb) {
/* id table: read target */
{
uint32_t waveid_offset = offset + (target_subsong-1) * 0x02;
uint32_t waveid_offset = offset + (target_subsong-1) * waveid_alignment;
waveid = read_u16le(waveid_offset,sf);
offset += total_subsongs * 0x02;
offset += total_subsongs * waveid_alignment;
}
/* offset table: find target */
@ -71,10 +71,10 @@ VGMSTREAM* init_vgmstream_awb_memory(STREAMFILE* sf, STREAMFILE* sf_acb) {
}
/* offset are absolute but sometimes misaligned (specially first that just points to offset table end) */
subfile_offset += (subfile_offset % alignment) ?
alignment - (subfile_offset % alignment) : 0;
subfile_next += (subfile_next % alignment) && subfile_next < file_size ?
alignment - (subfile_next % alignment) : 0;
subfile_offset += (subfile_offset % offset_alignment) ?
offset_alignment - (subfile_offset % offset_alignment) : 0;
subfile_next += (subfile_next % offset_alignment) && subfile_next < file_size ?
offset_alignment - (subfile_next % offset_alignment) : 0;
subfile_size = subfile_next - subfile_offset;
}

View File

@ -0,0 +1,110 @@
#include "meta.h"
#include "../coding/coding.h"
#include "../coding/ice_decoder_icelib.h"
/* .BIGRP - from Inti Creates "ICE"/"Imperial" engine [Blaster Master Zero 2 (SW), Gunvolt 3 (SW)] */
VGMSTREAM* init_vgmstream_bigrp(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t header_size, entry_size, stream_size;
int total_subsongs, target_subsong = sf->stream_index;
int codec, channels, loop_flag, sample_rate;
int32_t loop_start, num_samples;
/* checks */
/* simple checks to avoid opening the lib if possible
* early games use smaller sizes [Bloodstained COTM (Vita), Mighty Gunvolt Burst (PC)] */
header_size = read_u32le(0x00,sf);
if (read_u32le(0x00,sf) != 0x0c && read_u32le(0x00,sf) != 0x10)
goto fail;
entry_size = read_u32le(0x04,sf);
if (entry_size != 0x34 && entry_size != 0x40)
goto fail;
if (!check_extensions(sf, "bigrp"))
goto fail;
if (target_subsong == 0) target_subsong = 1;
total_subsongs = read_s32le(0x08,sf);
if (target_subsong > total_subsongs || total_subsongs <= 0) goto fail;
/* could read all this from the lib, meh */
{
uint32_t offset = header_size + entry_size * (target_subsong - 1);
/* 00: hash */
/* 04: group? */
codec = read_u32le(offset + 0x08, sf);
switch(codec) {
case 0x00: /* range [BMZ2 (SW), Bloodstained COTM (Vita), BMZ1 (PS4)] */
case 0x03:
sample_rate = read_s32le(offset + 0x0c, sf);
channels = read_u8 (offset + 0x10, sf);
/* 0x11: spf */
/* 0x12: unknown (volume?) */
loop_flag = read_u32le(offset + 0x14, sf);
/* 0x18: frame codes */
loop_start = read_s32le(offset + 0x1c, sf);
stream_size = read_u32le(offset + 0x20, sf); /* intro block */
/* 0x24: intro offset */
num_samples = read_s32le(offset + 0x28, sf) + loop_start;
stream_size = read_u32le(offset + 0x2c, sf) + stream_size; /* body block */
/* 0x30: body offset */
break;
default:
/* dummy to avoid breaking some files that mix codecs with midi */
channels = 1;
sample_rate = 48000;
loop_flag = 0;
loop_start = 0;
num_samples = sample_rate;
stream_size = 0;
break;
}
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_BIGRP;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = num_samples;
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
switch(codec) {
case 0x00:
case 0x03:
vgmstream->codec_data = init_ice(sf, target_subsong);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = codec == 0x00 ? coding_ICE_RANGE : coding_ICE_DCT;
vgmstream->layout_type = layout_none;
break;
case 0x01:
case 0x02:
vgmstream->coding_type = coding_SILENCE;
snprintf(vgmstream->stream_name, STREAM_NAME_SIZE, "[%s]", (codec == 0x01 ? "data" : "midi"));
break;
default:
goto fail;
}
//if (!vgmstream_open_stream(vgmstream, sf, 0x00))
// goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View File

@ -19,8 +19,11 @@ VGMSTREAM* init_vgmstream_bik(STREAMFILE* sf) {
/* .bik/bik2/bk2: standard
* .xmv: Reflections games [Driver: Parallel Lines (Wii), Emergency Heroes (Wii)]
* .bik.ps3: Neversoft games [Guitar Hero: Warriors of Rock (PS3)]
* .bik.xen: Neversoft games [various Guitar Hero (PC/PS3/X360)]
* .vid: Etrange Libellules games [Alice in Wonderland (PC)]
* .bika: fake extension for demuxed audio */
if (!check_extensions(sf,"bik,bik2,bk2,xmv,bika"))
if (!check_extensions(sf,"bik,bik2,bk2,ps3,xmv,xen,vid,bika"))
goto fail;
/* find target stream info and samples */

View File

@ -8,8 +8,8 @@ VGMSTREAM* init_vgmstream_bkhd(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* temp_sf = NULL;
uint32_t subfile_offset, subfile_size, base_offset = 0;
uint32_t subfile_id;
int big_endian, version, is_dummy = 0, is_wmid = 0;
uint32_t subfile_id, version;
int big_endian, is_dummy = 0, is_wmid = 0;
uint32_t (*read_u32)(off_t,STREAMFILE*);
float (*read_f32)(off_t,STREAMFILE*);
int total_subsongs, target_subsong = sf->stream_index;
@ -35,7 +35,7 @@ VGMSTREAM* init_vgmstream_bkhd(STREAMFILE* sf) {
* complex and better handled with TXTP (some info from Nicknine's script).
* Use this to explore HIRC and covert to .txtp: https://github.com/bnnm/wwiser */
version = read_u32(base_offset + 0x08, sf);
version = read_u32(base_offset + 0x08, sf); /* rarely version can be encrypted, but ok as u32 [Tamarin (PC)] */
if (version == 0 || version == 1) { /* early games */
version = read_u32(base_offset + 0x10, sf);
}

View File

@ -127,6 +127,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
case 0x0d: /* Polara (Vita), Crypt of the Necrodancer (Vita) */
case 0x0e: /* Yakuza 6's Puyo Puyo (PS4) */
case 0x0f: /* Ikaruga (PS4) */
table1_offset = sblk_offset + read_u32(sblk_offset+0x18,sf);
table2_offset = sblk_offset + read_u32(sblk_offset+0x1c,sf);
table3_offset = sblk_offset + read_u32(sblk_offset+0x2c,sf);
@ -298,6 +299,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
case 0x0d:
case 0x0e:
case 0x0f:
flags = read_u8 (table3_offset+table3_entry_offset+0x12,sf);
stream_offset = read_u32(table3_offset+table3_entry_offset+0x44,sf);
stream_size = read_u32(table3_offset+table3_entry_offset+0x48,sf);
@ -471,6 +473,7 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
case 0x0d:
case 0x0e:
case 0x0f:
type = read_u16(start_offset+0x00,sf);
if (read_u32(start_offset+0x04,sf) != 0x01) /* type? */
goto fail;
@ -509,16 +512,18 @@ VGMSTREAM* init_vgmstream_bnk_sony(STREAMFILE* sf) {
codec = PCM16;
break;
case 0x00: /* PS-ADPCM (test banks) */
case 0x00: /* HEVAG (test banks) */
case 0x03: /* HEVAG (Ikaruga) */
/* 0x10: null? */
channels = read_u32(start_offset+0x14,sf);
interleave = 0x02;
interleave = 0x10;
loop_start = read_u32(start_offset+0x18,sf);
loop_length = read_u32(start_offset+0x1c,sf);
loop_end = loop_start + loop_length; /* loop_start is -1 if not set */
codec = HEVAG;
//TODO: in v0x0f right before start_offset is the .vag filename, see if offset can be found
break;
default:

View File

@ -20,15 +20,14 @@ VGMSTREAM* init_vgmstream_bwav(STREAMFILE* sf) {
/* 0x04: BOM (always 0xFEFF = LE) */
/* 0x06: version? (0x0001) */
/* 0x08: crc32? (supposedly from all channel data without padding) */
if (read_u16le(0x0c, sf) != 0x00) /* supposedly prefetch flag */
goto fail;
/* 0x0c: prefetch flag */
channels = read_u16le(0x0e, sf);
/* - per channel (size 0x4c) */
codec = read_u16le(0x10 + 0x00, sf);
/* 0x02: channel layout (0=L, 1=R, 2=C) */
sample_rate = read_s32le(0x10 + 0x04, sf);
/* 0x08: num_samples for full (non-prefetch) file? */
/* 0x08: num_samples for full (non-prefetch) file, same as below if not prefetch */
num_samples = read_s32le(0x10 + 0x0c, sf);
/* 0x10: coefs */
/* 0x30: offset for full (non-prefetch) file? */
@ -36,9 +35,9 @@ VGMSTREAM* init_vgmstream_bwav(STREAMFILE* sf) {
/* 0x38: flag? (always 1) */
loop_end = read_s32le(0x10 + 0x3C, sf);
loop_start = read_s32le(0x10 + 0x40, sf);
/* 0x44: start predictor? */
/* 0x46: hist1 sample? */
/* 0x48: hist2 sample? */
/* 0x44: start predictor */
/* 0x46: hist1 sample */
/* 0x48: hist2 sample */
/* 0x4a: null? */
loop_flag = (loop_end != -1);
@ -70,7 +69,8 @@ VGMSTREAM* init_vgmstream_bwav(STREAMFILE* sf) {
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave;
dsp_read_coefs_le(vgmstream, sf, 0x20, 0x4C);
dsp_read_coefs_le(vgmstream, sf, 0x10 + 0x10, 0x4C);
dsp_read_hist_le(vgmstream, sf, 0x10 + 0x46, 0x4C);
break;
default:

View File

@ -997,8 +997,8 @@ VGMSTREAM* init_vgmstream_ea_mpf_mus(STREAMFILE* sf) {
total_streams = (eof_offset - samples_table) / 0x08;
off_mult = 0x80;
/* check to distinguish it from SNR/SNS version (first streamed sample is always at 0x100) */
if (read_u16(tracks_data + 0x04, sf) == 0 && read_u32(samples_table + 0x00, sf) != 0x02)
/* check to distinguish it from SNR/SNS version (first streamed sample is always at 0x00 or 0x100) */
if (read_u16(tracks_data + 0x04, sf) == 0 && read_u32(samples_table + 0x00, sf) > 0x02)
goto fail;
track_start = total_streams;

View File

@ -1,40 +1,93 @@
#include "meta.h"
#include "../coding/coding.h"
/* .ESF - from Mortal Kombat 4 (PC) */
/* .ESF - found in old Eurocom PC games [Mortal Kombat 4 (PC), Disney's Tarzan (PC)] */
VGMSTREAM* init_vgmstream_esf(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t pcm_size;
uint8_t version;
off_t start_offset;
int loop_flag, bps_flag, hq_flag, channels, bps;
int loop_flag = 0, bps_flag = 0, hq_flag = 0, codec_flag = 0,
sample_rate, channels, bps;
/* checks */
if (!is_id32be(0x00, sf, "ESF\x06"))
if (!is_id32be(0x00, sf, "ESF\x03") &&
!is_id32be(0x00, sf, "ESF\x06") &&
!is_id32be(0x00, sf, "ESF\x08"))
goto fail;
if (!check_extensions(sf, "esf"))
goto fail;
version = read_u8(0x03, sf);
pcm_size = read_u32le(0x04, sf);
bps_flag = pcm_size & 0x20000000;
hq_flag = pcm_size & 0x40000000;
loop_flag = pcm_size & 0x80000000;
pcm_size &= 0x1FFFFFFF;
switch (version) {
case 3:
/* Disney's Hercules */
sample_rate = read_u32le(0x08, sf);
loop_flag = read_u8(0x0c, sf);
bps_flag = read_u8(0x0d, sf);
//bps = bps_flag ? 8 : 16;
bps = 16;
start_offset = 0x10;
break;
case 6:
/* Mortal Kombat 4 */
bps_flag = pcm_size & 0x20000000;
hq_flag = pcm_size & 0x40000000;
loop_flag = pcm_size & 0x80000000;
pcm_size &= 0x1FFFFFFF;
bps = bps_flag ? 16 : 8;
sample_rate = hq_flag ? 22050 : 11025;
start_offset = 0x08;
break;
case 8:
/* Disney's Tarzan, Hydro Thunder */
bps_flag = pcm_size & 0x10000000;
hq_flag = pcm_size & 0x20000000;
loop_flag = pcm_size & 0x40000000;
codec_flag = pcm_size & 0x80000000;
pcm_size &= 0x0FFFFFFF;
bps = bps_flag ? 16 : 8;
sample_rate = hq_flag ? 22050 : 11025;
start_offset = 0x08;
break;
default:
goto fail;
}
channels = 1; /* mono only */
start_offset = 0x08;
bps = bps_flag ? 16 : 8; /* 16 is supposed to mean PCM16 but is actually IMA */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_ESF;
vgmstream->sample_rate = hq_flag ? 22050 : 11025;
vgmstream->coding_type = (bps == 8) ? coding_PCM8_U : coding_DVI_IMA;
vgmstream->num_samples = pcm_bytes_to_samples(pcm_size, 1, bps);
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = pcm_bytes_to_samples(pcm_size, channels, bps);
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->layout_type = layout_none;
switch (version) {
case 3:
vgmstream->coding_type = coding_DVI_IMA;
break;
case 6:
vgmstream->coding_type = (bps == 8) ? coding_PCM8_U : coding_DVI_IMA;
break;
case 8:
if (bps == 8) {
vgmstream->coding_type = coding_PCM8_U;
} else {
vgmstream->coding_type = codec_flag ? coding_DVI_IMA : coding_PCM16LE;
}
break;
}
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;

View File

@ -118,8 +118,9 @@ VGMSTREAM* init_vgmstream_fsb(STREAMFILE* sf) {
/* .fsb: standard
* .bnk: Hard Corps Uprising (PS3)
* .sfx: Geon Cube (Wii) */
if ( !check_extensions(sf, "fsb,bnk,sfx") )
* .sfx: Geon Cube (Wii)
* .xen: Guitar Hero: World Tour (PC) */
if ( !check_extensions(sf, "fsb,bnk,sfx,xen") )
goto fail;
fsb.id = read_u32be(0x00,sf);

View File

@ -13,8 +13,9 @@ VGMSTREAM* init_vgmstream_fsb_encrypted(STREAMFILE* sf) {
/* checks */
/* .fsb: standard
* .fsb.ps3: various Guitar Hero (PS3)
* .fsb.xen: various Guitar Hero (X360/PC) */
if (!check_extensions(sf, "fsb,xen"))
if (!check_extensions(sf, "fsb,ps3,xen"))
goto fail;

View File

@ -1,21 +1,25 @@
#include "meta.h"
#include "../coding/coding.h"
/* GCub - found in Sega Soccer Slam (GC) */
static int check_subinterleave(STREAMFILE* sf, uint32_t start_offset);
/* GCub - found in Black Box/Shaba games (engine?) [Sega Soccer Slam (GC), Shrek the Third (CC), Shrek Superslam (GC)] */
VGMSTREAM* init_vgmstream_gcub(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
uint32_t start_offset, data_size;
int channels, loop_flag, sample_rate;
size_t data_size;
int is_subinterleave;
/* checks */
if (!is_id32be(0x00,sf, "GCub"))
goto fail;
/* .wav: extension found in bigfile
* .gcub: header id */
if (!check_extensions(sf, "wav,lwav,gcub"))
goto fail;
if (!is_id32be(0x00,sf, "GCub"))
goto fail;
loop_flag = 0;
channels = read_u32be(0x04,sf);
@ -27,6 +31,12 @@ VGMSTREAM* init_vgmstream_gcub(STREAMFILE* sf) {
else
start_offset = 0x60;
/* Shaba/Shrek games use it but no header diffs, detect by inspecting data
* (could try checking initial PS but not enough for files that start with 0s) */
is_subinterleave = 0;
if (channels > 1)
is_subinterleave = check_subinterleave(sf, start_offset);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
@ -35,9 +45,9 @@ VGMSTREAM* init_vgmstream_gcub(STREAMFILE* sf) {
vgmstream->meta_type = meta_GCUB;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = dsp_bytes_to_samples(data_size, channels);
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x8000;
vgmstream->coding_type = is_subinterleave ? coding_NGC_DSP_subint : coding_NGC_DSP;
vgmstream->layout_type = is_subinterleave ? layout_none : layout_interleave;
vgmstream->interleave_block_size = is_subinterleave ? 0x01 : 0x8000;
dsp_read_coefs_be(vgmstream, sf, 0x10, 0x20);
/* 0x50: initial ps for ch1/2 (16b) */
@ -51,3 +61,32 @@ fail:
close_vgmstream(vgmstream);
return NULL;
}
static int check_subinterleave(STREAMFILE* sf, uint32_t offset) {
int test_frames = 50;
uint32_t size = get_streamfile_size(sf);
/* DSP frame headers can't go past certain values, while nibbles can, so check that supposed headers are so */
while (test_frames >= 0 && offset < size) {
uint8_t h2 = read_u8(offset + 0x01,sf); /* only need to test header for 2nd channel */
/* ignore blank frames */
if (h2 != 0x00) {
uint8_t factor = (h2 >> 0) & 0xF; /* not sure about actual max but 0x0b is max usually */
uint8_t index = (h2 >> 4) & 0xF;
if (factor > 0x0c || index > 8)
return 0;
test_frames--;
}
offset += 0x10;
}
/* too many blanks */
if (test_frames > 0)
return 0;
return 1;
}

View File

@ -19,7 +19,10 @@ VGMSTREAM* init_vgmstream_h4m(STREAMFILE* sf) {
!is_id32be(0x08,sf, "5\0\0\0"))
goto fail;
if (!check_extensions(sf, "h4m"))
/* checks */
/* .h4m: common
* .hvqm: Shrek: Extra Large (GC) */
if (!check_extensions(sf, "h4m,hvqm"))
goto fail;
/* header */

View File

@ -521,6 +521,7 @@ static const hcakey_info hcakey_list[] = {
{0xfff671f0ddb660b1}, //music_0310015
{0x22e33db9b5625a96}, //music_0310016
{0xb78070802414de7a}, //music_0310017
{0x572aeeed86655119}, //music_0310018
{0xb921c3992807dadd}, //music_0320001
{0x38ad99a045dc971f}, //music_0320002
{0xf616642579ba5850}, //music_0320003
@ -538,6 +539,7 @@ static const hcakey_info hcakey_list[] = {
{0xf06a6bfdd00c8286}, //music_0320015
{0x2df608ef06aca41c}, //music_0320016
{0x641af19c287d4a2e}, //music_0320017
{0x82de7b71b30d7bc2}, //music_0320019
{0x776c4aded0bca5d1}, //music_0410001
{0xb7bff4fbf66be43f}, //music_0410002
{0x904f50c5ce8ec6e4}, //music_0410003
@ -565,11 +567,12 @@ static const hcakey_info hcakey_list[] = {
{0x1bb363adcf4eb3f8}, //music_0420010
{0xd80d3dcc7c75cea}, //music_0420011
{0x52723f026d5238e8}, //music_0420012
{0xd13a315c0005f0}, //music_0420013
{0xd13a315c0005f0}, //music_0420013
{0x35f2d3cec84aba1}, //music_0420014
{0xdad11fe0e397ede}, //music_0420015
{0xc94236c936f50cc}, //music_0420016
{0xbf8a2d951bc01dff}, //music_0420017
{0xb945505638f972e4}, //music_0420018
{0xdf31e26a7b036a2}, //music_0510001
{0xb2770dced3cfd9a7}, //music_0510002
{0x6c6c1fd51e28a1e7}, //music_0510003
@ -605,6 +608,7 @@ static const hcakey_info hcakey_list[] = {
{0x1bf43def1e4b103a}, //music_0520014
{0x6721ad5109e4840d}, //music_0520015
{0xc488dd62fc89090}, //music_0520016
{0xd3d24f1db0b74363}, //music_0520019
{0xd2ce91dbfc209b10}, //music_0610001
{0xa662be1601e49476}, //music_0610002
{0xe5e83d31e64273f8}, //music_0610003
@ -622,11 +626,13 @@ static const hcakey_info hcakey_list[] = {
{0x750ab11487f9d6e8}, //music_0610015
{0xd22171fda74c5615}, //music_0610016
{0x3aa02e0a37543b5c}, //music_0610017
{0xc451f1deddae08ca}, //music_0610018
{0xc0fa6669d9904919}, //music_0610019
{0x8258ddd6a1d0849b}, //music_0620001
{0x1dd21a1244ca12f1}, //music_0620002
{0xfdec74b23d8b494b}, //music_0620003
{0x6f9735c02faf6aae}, //music_0620004
{0xe978d394512cfd}, //music_0620005
{0xe978d394512cfd}, //music_0620005
{0xaba147637d52efbe}, //music_0620006
{0xe67f4da6012c5d24}, //music_0620007
{0xc352bbf3d519256e}, //music_0620008
@ -640,6 +646,7 @@ static const hcakey_info hcakey_list[] = {
{0x5de2b0a34eee1c89}, //music_0620016
{0x5c1195d8afcb1901}, //music_0620017
{0x1ad8db767d9ba4a7}, //music_0620018
{0x9bc820aa161b0f08}, //music_0620019
{0x2a47feac8dc3ca9c}, //music_3010001
{0x9ebbaf63ffe9d9ef}, //music_3010002
{0xe553dba6592293d8}, //music_3010003
@ -655,6 +662,7 @@ static const hcakey_info hcakey_list[] = {
{0xbdd0c58062c675d4}, //music_3010014
{0xef257f41a265a0af}, //music_3010015
{0x5e23d8a2488bc715}, //music_3010016
{0x198cc607e20dd264}, //music_3010017
{0xfd3ea450350d666f}, //music_3020001
{0x5e91a3790c32e2b3}, //music_3020002
{0x358adfd1bbd3a95e}, //music_3020003
@ -748,6 +756,14 @@ static const hcakey_info hcakey_list[] = {
{0x1dd99ac6f1a07f00}, //music_5030081
{0x2fd298ade03f7f0f}, //music_5030082
{0xbeb0df818f88b99c}, //music_5030083
{0x886df2bdcc645cc}, //music_5030084
{0x6420fc8d2d67ef1}, //music_5030085
{0x29d61d19434b640b}, //music_5030086
{0xf4d7569bb4fa06ab}, //music_5030087
{0x1de64ce0c1054a5a}, //music_5030088
{0xd51e8d88fff1aa5c}, //music_5030089
{0xa2ea81812297bf73}, //music_5030090
{0x276f1e23c97cf8d}, //music_5030091
{0x444dda6d55d76095}, //music_5040001
{0xcbf4f1324081e0a6}, //music_5040002
{0xf1db3c1d9542063a}, //music_5040003
@ -758,7 +774,7 @@ static const hcakey_info hcakey_list[] = {
{0xf877dea1180b9b90}, //music_5040008
{0xcd3fb92065d9f373}, //music_5040009
{0xee8da2806a13eecf}, //music_5040010
{0x46fd87a21859ac}, //music_5040011
{0x46fd87a21859ac}, //music_5040011
{0x90fefcd350bd2cb8}, //music_5040012
{0xf7edc5d72fdd6ceb}, //music_5040013
{0x4c7d7c251c6bfa95}, //music_5040014
@ -916,11 +932,18 @@ static const hcakey_info hcakey_list[] = {
{0x74e058fd628364c9}, //music_5050152
{0x3ade68d4857395c0}, //music_5050153
{0x68f7f556af1c2fc6}, //music_5050154
{0xaf67059daac6c89d}, //music_5050155
{0xc557fa24c5c887e8}, //music_5050156
{0xbad0b0f6dc3b004c}, //music_5050157
{0x1838300a8bb9b8ff}, //music_5050158
{0xffb4afe38bb4a3dd}, //music_5050159
{0x22cfb3e29832a25a}, //music_5050160
{0xa86bbfe35949b53e}, //music_5050161
{0xa86bbfe35949b53e}, //music_5050163
{0x6f321adde08396e3}, //music_5050163
{0x58afa6381eeb1425}, //music_5050164
{0x751daf7d1a5401cb}, //music_5050165
{0x2550e145b93723ae}, //music_5050169
{0x26e5bf2c66a9898d}, //music_5050171
{0x52c250eade92393b}, //music_9010001
{0xf66e6bb5b0599b07}, //music_9010002
{0x8582b5a60dbbf948}, //music_9010003
@ -1014,7 +1037,7 @@ static const hcakey_info hcakey_list[] = {
// Priconne! Grand Masters (iOS/Android)
{185705658241}, // 0000002B3CEB7781
// Sonic Origins
// Sonic Origins (multi)
{1991062320220623}, // 000712DC525289CF
// Pachislot Gyakuten Saiban (iOS/Android)
@ -1023,8 +1046,14 @@ static const hcakey_info hcakey_list[] = {
// Alice Fiction (Android)
{112089817}, // 0000000006AE5AD9
// Taiko no Tatsujin: Rhythm Festival Demo (Switch)
// Taiko no Tatsujin: Rhythm Festival (Switch)
{52539816150204134}, // 00baa8af36327ee6
// Fairy Fencer F: Refrain Chord (multi)
{348693553056839375}, // 04D6CEF0656BF6CF
// Echoes of Mana (Android)
{1090221945250803295}, // 0F213F153D026E5F
};
#endif/*_HCA_KEYS_H_*/

View File

@ -991,4 +991,6 @@ VGMSTREAM* init_vgmstream_sndz(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_vab(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_bigrp(STREAMFILE* sf);
#endif /*_META_H*/

View File

@ -235,6 +235,7 @@ static int parse_musx_stream(STREAMFILE* sf, musx_header* musx) {
break;
case 0x58425F5F: /* "XB__" */
case 0x5842315F: /* "XB1_" */
default_channels = 2;
default_sample_rate = 44100;
musx->codec = DAT;
@ -254,7 +255,7 @@ static int parse_musx_stream(STREAMFILE* sf, musx_header* musx) {
case 0x5749495F: /* "WII_" */
default_channels = 2;
default_sample_rate = 44100;
default_sample_rate = 32000;
musx->codec = DAT;
break;

View File

@ -572,13 +572,14 @@ fail:
return NULL;
}
/* .(mp)dsp - single header + interleaved dsp [Monopoly Party! (GC)] */
/* .STE - single header + interleaved dsp [Monopoly Party! (GC)] */
VGMSTREAM* init_vgmstream_ngc_mpdsp(STREAMFILE* sf) {
dsp_meta dspm = {0};
/* checks */
/* .mpdsp: renamed since standard .dsp would catch it otherwise */
if (!check_extensions(sf, "mpdsp"))
/* .ste: real extension
* .mpdsp: fake/renamed since standard .dsp would catch it otherwise */
if (!check_extensions(sf, "mpdsp,ste"))
goto fail;
/* at 0x48 is extra data that could help differenciating these DSPs, but seems like
@ -757,7 +758,7 @@ fail:
return NULL;
}
/* IDSP - from Next Level games [Super Mario Strikers (GC), Mario Strikers: Charged (Wii)] */
/* IDSP - from Next Level games [Super Mario Strikers (GC), Mario Strikers Charged (Wii), Spider-Man: Friend or Foe (Wii)] */
VGMSTREAM* init_vgmstream_idsp_nl(STREAMFILE* sf) {
dsp_meta dspm = {0};
@ -821,12 +822,14 @@ fail:
return NULL;
}
/* .ddsp - full interleaved dsp [The Sims 2: Pets (Wii)] */
/* .ddsp - full interleaved dsp [Shark Tale, (GC), The Sims 2: Pets (Wii), Wacky Races: Crash & Dash (Wii)] */
VGMSTREAM* init_vgmstream_dsp_ddsp(STREAMFILE* sf) {
dsp_meta dspm = {0};
/* checks */
if (!check_extensions(sf, "ddsp"))
/* .ddsp: assumed?
* .wav: Wacky Races: Crash & Dash (Wii) */
if (!check_extensions(sf, "ddsp,wav,lwav"))
goto fail;
dspm.channels = 2;

View File

@ -91,6 +91,13 @@ VGMSTREAM* init_vgmstream_ogg_opus(STREAMFILE* sf) {
sscanf(strrchr(user_comment, '=') + 1, "%d-%d", &loop_start, &loop_end);
loop_flag = 1;
}
else if (strstr(user_comment,"loopstart=")==user_comment) { /* The Legend of Heroes: Kuro no Kiseki (PC) */
loop_start= atol(strrchr(user_comment,'=')+1);
loop_flag = (loop_start >= 0);
}
else if (strstr(user_comment,"loopend=")==user_comment) { /* LoopStart pair */
loop_end = atol(strrchr(user_comment,'=')+1);
}
//;VGM_LOG("OggOpus: user_comment=%s\n", user_comment);
offset += 0x04 + user_comment_size;

View File

@ -33,10 +33,10 @@ VGMSTREAM * init_vgmstream_ps2_ccc(STREAMFILE *streamFile) {
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
vgmstream->coding_type = coding_PSX;
vgmstream->num_samples = (read_32bitLE(0x08,streamFile))/channel_count/32*28;
vgmstream->num_samples = (read_32bitLE(0x08,streamFile))/channel_count/0x10*28;
if (loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = (read_32bitLE(0x08,streamFile))/channel_count/32*28;
vgmstream->loop_end_sample = (read_32bitLE(0x08,streamFile))/channel_count/0x10*28;
}
vgmstream->layout_type = layout_interleave;

View File

@ -377,8 +377,9 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) {
* .pcm: Silent Hill Arcade (PC)
* .xvag: Uncharted Golden Abyss (Vita)[ATRAC9]
* .ogg/logg: Luftrausers (Vita)[ATRAC9]
* .p1d: Farming Simulator 15 (Vita)[ATRAC9]
*/
if ( check_extensions(sf, "wav,lwav,xwav,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg") ) {
if ( check_extensions(sf, "wav,lwav,xwav,da,dax,cd,med,snd,adx,adp,xss,xsew,adpcm,adw,wd,,sbv,wvx,str,at3,rws,aud,at9,ckd,saf,ima,nsa,pcm,xvag,ogg,logg,p1d") ) {
;
}
else if ( check_extensions(sf, "mwv") ) {
@ -1012,16 +1013,14 @@ static size_t get_ue4_msadpcm_interleave(STREAMFILE* sf, riff_fmt_chunk* fmt, of
/* last frame is almost always padded, so should at half interleave */
if (!is_blank_half && !is_blank_full) {
VGM_LOG("v1 a\n");
return v1_interleave;
}
/* last frame is padded, and half interleave is not: should be regular interleave*/
if (!is_blank_half && is_blank_full) {
VGM_LOG("v2 a\n");
return v2_interleave;
}
VGM_LOG("i=%i, i=%i\n", is_blank_half, is_blank_full);
/* last frame is silent-ish, so should at half interleave (TSA's SML_DarknessLoop_01, TSA_CAD_YAKATA)
* this doesn't work too well b/c num_samples at 0x36 uses all data, may need adjustment */
{

View File

@ -1,5 +1,6 @@
#include "meta.h"
#include "../coding/coding.h"
#include "../util/endianness.h"
#include "sqex_streamfile.h"
@ -20,65 +21,67 @@ typedef struct {
int sample_rate;
int loop_start;
int loop_end;
off_t mtrl_offset;
off_t extradata_offset;
size_t extradata_size;
size_t stream_size;
uint32_t mtrl_offset;
uint32_t extradata_offset;
uint32_t extradata_size;
uint32_t stream_size;
uint16_t extradata_id;
off_t filename_offset;
size_t filename_size;
off_t muscname_offset;
size_t muscname_size;
off_t sectname_offset;
size_t sectname_size;
off_t modename_offset;
size_t modename_size;
off_t instname_offset;
size_t instname_size;
off_t sndname_offset;
size_t sndname_size;
uint32_t filename_offset;
uint32_t filename_size;
uint32_t muscname_offset;
uint32_t muscname_size;
uint32_t sectname_offset;
uint32_t sectname_size;
uint32_t modename_offset;
uint32_t modename_size;
uint32_t instname_offset;
uint32_t instname_size;
//uint32_t sndname_offset;
//uint32_t sndname_size;
off_t sections_offset;
off_t snd_section_offset;
off_t seq_section_offset;
off_t trk_section_offset;
off_t musc_section_offset;
off_t inst_section_offset;
off_t mtrl_section_offset;
uint32_t sections_offset;
uint32_t snd_section_offset;
uint32_t seq_section_offset;
uint32_t trk_section_offset;
uint32_t musc_section_offset;
uint32_t inst_section_offset;
uint32_t mtrl_section_offset;
char readable_name[STREAM_NAME_SIZE];
} sead_header;
} sead_header_t;
static int parse_sead(sead_header *sead, STREAMFILE *sf);
static int parse_sead(sead_header_t* sead, STREAMFILE* sf);
/* SABF/MABF - Square Enix's "sead" audio games [Dragon Quest Builders (PS3), Dissidia Opera Omnia (mobile), FF XV (PS4)] */
VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
sead_header sead = {0};
sead_header_t sead = {0};
off_t start_offset;
int target_subsong = sf->stream_index;
uint32_t (*read_u32)(off_t,STREAMFILE*) = NULL;
uint16_t (*read_u16)(off_t,STREAMFILE*) = NULL;
read_u32_t read_u32 = NULL;
read_u16_t read_u16 = NULL;
/* checks */
if (is_id32be(0x00, sf, "sabf")) {
sead.is_sab = 1;
}
else if (is_id32be(0x00, sf, "mabf")) {
sead.is_mab = 1;
}
else {
goto fail;
}
/* .sab: sound/bgm
* .mab: music
* .sbin: Dissidia Opera Omnia .sab */
if (!check_extensions(sf,"sab,mab,sbin"))
goto fail;
if (read_u32be(0x00, sf) == 0x73616266) { /* "sabf" */
sead.is_sab = 1;
} else if (read_u32be(0x00, sf) == 0x6D616266) { /* "mabf" */
sead.is_mab = 1;
} else {
goto fail;
}
/* SEAD handles both sab/mab in the same lib (libsead), and other similar files (config, engine, etc).
* Has some chunks pointing to sections, and each section entry (usually starting with section
* version/reserved/size) is always padded to 0x10. Most values are unsigned.
@ -89,7 +92,7 @@ VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
* or is a separate audio lib derived from this "SEAD Engine". */
sead.big_endian = guess_endianness16bit(0x06, sf); /* no flag, use size */
sead.big_endian = guess_endian16(0x06, sf); /* no flag, use size */
if (sead.big_endian) {
read_u32 = read_u32be;
read_u16 = read_u16be;
@ -115,6 +118,14 @@ VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
strcpy(vgmstream->stream_name, sead.readable_name);
switch(sead.codec) {
case 0x00: /* NONE */
vgmstream->coding_type = coding_SILENCE;
vgmstream->layout_type = layout_none;
vgmstream->num_samples = sead.sample_rate;
start_offset = 0;
break;
case 0x01: { /* PCM [Chrono Trigger (PC) sfx] */
start_offset = sead.extradata_offset + sead.extradata_size;
@ -157,7 +168,7 @@ VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
#ifdef VGM_USE_VORBIS
case 0x03: { /* VORBIS (Ogg subfile) [Final Fantasy XV Benchmark sfx (PC)] */
VGMSTREAM *ogg_vgmstream = NULL;
VGMSTREAM* ogg_vgmstream = NULL;
ogg_vorbis_meta_info_t ovmi = {0};
off_t subfile_offset = sead.extradata_offset + sead.extradata_size;
@ -254,8 +265,8 @@ VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
#endif
case 0x07: { /* HCA (subfile) [Dissidia Opera Omnia (Mobile), Final Fantaxy XV (PS4)] */
VGMSTREAM *temp_vgmstream = NULL;
STREAMFILE *temp_sf = NULL;
VGMSTREAM* temp_vgmstream = NULL;
STREAMFILE* temp_sf = NULL;
off_t subfile_offset = sead.extradata_offset + 0x10;
size_t subfile_size = sead.stream_size + sead.extradata_size - 0x10;
@ -299,11 +310,10 @@ VGMSTREAM* init_vgmstream_sqex_sead(STREAMFILE* sf) {
}
}
case 0x00: /* NONE / dummy entry */
case 0x05: /* XMA2 (extradata may be a XMA2 fmt extra chunk) */
case 0x08: /* SWITCHOPUS (no extradata?) */
default:
VGM_LOG("SQEX SEAD: unknown codec %x\n", sead.codec);
vgm_logi("SQEX SEAD: unknown codec %x\n", sead.codec);
goto fail;
}
@ -319,54 +329,76 @@ fail:
return NULL;
}
//todo safeops, avoid recalc lens
static void sead_cat(char* dst, int dst_max, const char* src) {
int dst_len = strlen(dst);
int src_len = strlen(dst);
if (dst_len + src_len > dst_max - 1)
return;
strcat(dst, src);
}
static void build_readable_name(char * buf, size_t buf_size, sead_header *sead, STREAMFILE *sf) {
static void build_readable_sab_name(sead_header_t* sead, STREAMFILE* sf, uint32_t sndname_offset, uint32_t sndname_size) {
char * buf = sead->readable_name;
int buf_size = sizeof(sead->readable_name);
char descriptor[255], name[255];
if (sead->is_sab) {
char descriptor[255], name[255];
if (sead->filename_size > 255 || sndname_size > 255)
goto fail;
if (sead->filename_size > 255 || sead->sndname_size > 255) goto fail;
read_string(descriptor,sead->filename_size+1,sead->filename_offset, sf);
read_string(name,sead->sndname_size+1,sead->sndname_offset, sf);
if (buf[0] == '\0') { /* init */
read_string(descriptor,sead->filename_size+1, sead->filename_offset, sf);
read_string(name, sndname_size+1, sndname_offset, sf);
snprintf(buf,buf_size, "%s/%s", descriptor, name);
}
else {
char descriptor[255], name[255], mode[255];
else { /* add */
read_string(name, sndname_size+1, sndname_offset, sf);
if (sead->filename_size > 255 || sead->muscname_size > 255 || sead->sectname_size > 255 || sead->modename_size > 255) goto fail;
read_string(descriptor,sead->filename_size+1,sead->filename_offset, sf);
//read_string(filename,sead->muscname_size+1,sead->muscname_offset, sf); /* same as filename, not too interesting */
if (sead->sectname_offset)
read_string(name,sead->sectname_size+1,sead->sectname_offset, sf);
else if (sead->instname_offset)
read_string(name,sead->instname_size+1,sead->instname_offset, sf);
else
strcpy(name, "?");
if (sead->modename_offset > 0)
read_string(mode,sead->modename_size+1,sead->modename_offset, sf);
/* default mode in most files */
if (sead->modename_offset == 0 || strcmp(mode, "Mode") == 0 || strcmp(mode, "Mode0") == 0)
snprintf(buf,buf_size, "%s/%s", descriptor, name);
else
snprintf(buf,buf_size, "%s/%s/%s", descriptor, name, mode);
sead_cat(buf, buf_size, "; ");
sead_cat(buf, buf_size, name);
}
return;
fail:
VGM_LOG("SEAD: bad sab name found\n");
}
static void build_readable_mab_name(sead_header_t* sead, STREAMFILE* sf) {
char * buf = sead->readable_name;
int buf_size = sizeof(sead->readable_name);
char descriptor[255], name[255], mode[255];
if (sead->filename_size > 255 || sead->muscname_size > 255 || sead->sectname_size > 255 || sead->modename_size > 255)
goto fail;
read_string(descriptor,sead->filename_size+1,sead->filename_offset, sf);
//read_string(filename,sead->muscname_size+1,sead->muscname_offset, sf); /* same as filename, not too interesting */
if (sead->sectname_offset)
read_string(name,sead->sectname_size+1,sead->sectname_offset, sf);
else if (sead->instname_offset)
read_string(name,sead->instname_size+1,sead->instname_offset, sf);
else
strcpy(name, "?");
if (sead->modename_offset > 0)
read_string(mode,sead->modename_size+1,sead->modename_offset, sf);
/* default mode in most files */
if (sead->modename_offset == 0 || strcmp(mode, "Mode") == 0 || strcmp(mode, "Mode0") == 0)
snprintf(buf,buf_size, "%s/%s", descriptor, name);
else
snprintf(buf,buf_size, "%s/%s/%s", descriptor, name, mode);
return;
fail:
VGM_LOG("SEAD: bad name found\n");
VGM_LOG("SEAD: bad mab name found\n");
}
static void parse_sead_mab_name(sead_header *sead, STREAMFILE *sf) {
uint32_t (*read_u32)(off_t,STREAMFILE*) = sead->big_endian ? read_u32be : read_u32le;
uint16_t (*read_u16)(off_t,STREAMFILE*) = sead->big_endian ? read_u16be : read_u16le;
static void parse_sead_mab_name(sead_header_t* sead, STREAMFILE* sf) {
read_u32_t read_u32 = sead->big_endian ? read_u32be : read_u32le;
read_u16_t read_u16 = sead->big_endian ? read_u16be : read_u16le;
int i, j, k, entries;
off_t target_muscname_offset = 0, target_sectname_offset = 0;
size_t target_muscname_size = 0, target_sectname_size = 0;
uint32_t target_muscname_offset = 0, target_sectname_offset = 0;
uint32_t target_muscname_size = 0, target_sectname_size = 0;
/* find names referencing to our material stream, usually:
* - music > sections > layers (<> meters) > material index
@ -608,9 +640,9 @@ static void parse_sead_mab_name(sead_header *sead, STREAMFILE *sf) {
}
}
static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
uint32_t (*read_u32)(off_t,STREAMFILE*) = sead->big_endian ? read_u32be : read_u32le;
uint16_t (*read_u16)(off_t,STREAMFILE*) = sead->big_endian ? read_u16be : read_u16le;
static void parse_sead_sab_name(sead_header_t* sead, STREAMFILE* sf) {
read_u32_t read_u32 = sead->big_endian ? read_u32be : read_u32le;
read_u16_t read_u16 = sead->big_endian ? read_u16be : read_u16le;
int i, j, entries;
/* find names referencing to our material stream, usually:
@ -627,9 +659,9 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
/* parse sounds */
entries = read_u16(sead->snd_section_offset + 0x04, sf);
for (i = 0; i < entries; i++) {
off_t snd_offset = sead->snd_section_offset + read_u32(sead->snd_section_offset + 0x10 + i*0x04, sf);
size_t snd_size, sndname_size;
off_t seqi_start, seqi_offset, sndname_offset;
uint32_t snd_offset = sead->snd_section_offset + read_u32(sead->snd_section_offset + 0x10 + i*0x04, sf);
uint32_t snd_size, sndname_size;
uint32_t seqi_start, seqi_offset, sndname_offset;
int snd_version, seqi_count;
snd_version = read_u8(snd_offset + 0x00, sf);
@ -677,8 +709,8 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
/* parse sequence */
{
off_t seq_offset = sead->seq_section_offset + read_u32(sead->seq_section_offset + 0x10 + seq_index*0x04, sf);
off_t cmnd_start, cmnd_offset;
uint32_t seq_offset = sead->seq_section_offset + read_u32(sead->seq_section_offset + 0x10 + seq_index*0x04, sf);
uint32_t cmnd_start, cmnd_offset;
int seq_version;
seq_version = read_u8(seq_offset + 0x00, sf);
@ -724,7 +756,7 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
/* parse track */
{
off_t trk_offset = sead->trk_section_offset + read_u32(sead->trk_section_offset + 0x10 + trk_index*0x04, sf);
uint32_t trk_offset = sead->trk_section_offset + read_u32(sead->trk_section_offset + 0x10 + trk_index*0x04, sf);
uint8_t trk_type;
uint16_t mtrl_index;
@ -743,8 +775,9 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
/* assumes same bank, not sure if bank info is even inside .sab */
if (mtrl_index == sead->mtrl_index) {
sead->sndname_offset = sndname_offset;
sead->sndname_size = sndname_size;
build_readable_sab_name(sead, sf, sndname_offset, sndname_size);
//sead->sndname_offset = sndname_offset;
//sead->sndname_size = sndname_size;
}
}
else if (trk_type == 0x02) {
@ -760,8 +793,10 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
/* commands normally end when a type 0=none is found */
if (cmnd_type <= 0x00 || cmnd_type > 0x08)
break;
if (sead->sndname_offset > 0)
break;
/* keep reading names as N sounds may point to current material */
//if (sead->sndname_offset > 0)
// break;
}
}
@ -770,9 +805,9 @@ static void parse_sead_sab_name(sead_header *sead, STREAMFILE *sf) {
}
static int parse_sead(sead_header* sead, STREAMFILE* sf) {
uint32_t (*read_u32)(off_t,STREAMFILE*) = sead->big_endian ? read_u32be : read_u32le;
uint16_t (*read_u16)(off_t,STREAMFILE*) = sead->big_endian ? read_u16be : read_u16le;
static int parse_sead(sead_header_t* sead, STREAMFILE* sf) {
read_u32_t read_u32 = sead->big_endian ? read_u32be : read_u32le;
read_u16_t read_u16 = sead->big_endian ? read_u16be : read_u16le;
/** base header **/
/* 0x00: id */
@ -849,9 +884,9 @@ static int parse_sead(sead_header* sead, STREAMFILE* sf) {
for (i = 0; i < entries; i++) {
off_t entry_offset = sead->mtrl_section_offset + read_u32(sead->mtrl_section_offset + 0x10 + i*0x04, sf);
if (read_u8(entry_offset + 0x05, sf) == 0) {
continue; /* codec 0 when dummy (see stream header) */
}
//if (read_u8(entry_offset + 0x05, sf) == 0) {
// continue; /* codec 0 when dummy (see stream header) */
//}
sead->total_subsongs++;
if (!sead->mtrl_offset && sead->total_subsongs == sead->target_subsong) {
@ -882,17 +917,24 @@ static int parse_sead(sead_header* sead, STREAMFILE* sf) {
sead->extradata_id = read_u16(sead->mtrl_offset + 0x1c, sf);
/* 0x1e: reserved */
if (sead->codec == 0x00) {
/* dummy entries have null fields, put defaults to allow playing them */
sead->channels = 1;
sead->sample_rate = 48000;
}
sead->loop_flag = (sead->loop_end > 0);
sead->extradata_offset = sead->mtrl_offset + 0x20;
if (sead->is_sab) {
parse_sead_sab_name(sead, sf);
/* sab name is added during process */
}
else if (sead->is_mab) {
parse_sead_mab_name(sead, sf);
build_readable_mab_name(sead, sf);
}
build_readable_name(sead->readable_name, sizeof(sead->readable_name), sead, sf);
return 1;
fail:

View File

@ -51,6 +51,7 @@ typedef enum {
IMA_HV,
PCM8_SB,
HEVAG,
YMZ,
UNKNOWN = 99,
} txth_codec_t;
@ -258,6 +259,7 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
case MPEG: coding = coding_MPEG_layer3; break; /* we later find out exactly which */
#endif
case IMA: coding = coding_IMA; break;
case YMZ:
case AICA: coding = coding_AICA; break;
case MSADPCM: coding = coding_MSADPCM; break;
case NGC_DSP: coding = coding_NGC_DSP; break;
@ -386,7 +388,12 @@ VGMSTREAM* init_vgmstream_txth(STREAMFILE* sf) {
vgmstream->codec_config = txth.codec_mode;
}
vgmstream->allow_dual_stereo = 1; /* AICA and PSX */
if (txth.codec == YMZ) {
vgmstream->codec_config = 1; /* CONFIG_HIGH_NIBBLE */
}
//TODO recheck and use only for needed cases
vgmstream->allow_dual_stereo = 1; /* known to be used in: PSX, AICA, YMZ */
break;
case coding_PCFX:
@ -955,6 +962,7 @@ static txth_codec_t parse_codec(txth_header* txth, const char* val) {
else if (is_string(val,"MPEG")) return MPEG;
else if (is_string(val,"IMA")) return IMA;
else if (is_string(val,"AICA")) return AICA;
else if (is_string(val,"YMZ")) return YMZ;
else if (is_string(val,"MSADPCM")) return MSADPCM;
else if (is_string(val,"NGC_DSP")) return NGC_DSP;
else if (is_string(val,"DSP")) return NGC_DSP;
@ -2129,6 +2137,7 @@ static int get_bytes_to_samples(txth_header* txth, uint32_t bytes) {
case IMA_HV:
return ima_bytes_to_samples(bytes, txth->channels);
case AICA:
case YMZ:
case CP_YM:
return yamaha_bytes_to_samples(bytes, txth->channels);
case PCFX:

View File

@ -141,23 +141,23 @@ VGMSTREAM* init_vgmstream_vab(STREAMFILE* sf) {
entry_off = tones_off + program_num * 16 * 0x20 + tone_num * 0x20;
center = read_u8(entry_off + 0x04, sf);
shift = read_u8(entry_off + 0x05, sf);
min_note = read_u8(entry_off + 0x06, sf);
min_note = read_u8(entry_off + 0x06, sf); /* these two may contain garbage */
max_note = read_u8(entry_off + 0x07, sf);
wave_num = read_u16le(entry_off + 0x16, sf);
if (read_vabcfg_file(sf, program_num, tone_num, &note, &fine, &uselimits)) {
if (note == -1)
note = center;
if (shift == -1)
if (fine == -1)
fine = shift;
if (uselimits)
note = VAB_CLAMP(note, min_note, max_note);
} else {
note = VAB_CLAMP(60, min_note, max_note);
/* play default note */
note = 60;
fine = 0;
}
/* play default note */
pitch = SsPitchFromNote(note, fine, center, shift);
data_offset = is_vh ? 0x00 : (waves_off + 256 * 0x02);

View File

@ -2,31 +2,31 @@
#include "../coding/coding.h"
/* .WAV - from Half-Life 2 (Xbox) */
VGMSTREAM *init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
VGMSTREAM *vgmstream = NULL;
VGMSTREAM* init_vgmstream_xbox_hlwav(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t header_size, data_size, start_offset, sample_rate;
int32_t loop_start;
uint8_t format, freq_mode, channels;
int loop_flag;
/* checks */
if (!check_extensions(streamFile, "wav,lwav"))
if (!check_extensions(sf, "wav,lwav"))
goto fail;
/* check header and size */
header_size = read_u32le(0x00, streamFile);
header_size = read_u32le(0x00, sf);
if (header_size != 0x14)
goto fail;
data_size = read_u32le(0x04, streamFile);
start_offset = read_u32le(0x08, streamFile);
if (data_size != get_streamfile_size(streamFile) - start_offset)
data_size = read_u32le(0x04, sf);
start_offset = read_u32le(0x08, sf);
if (data_size != get_streamfile_size(sf) - start_offset)
goto fail;
loop_start = read_s32le(0x0c, streamFile);
format = read_u8(0x12, streamFile);
freq_mode = read_u8(0x13, streamFile) & 0x0F;
channels = (read_u8(0x13, streamFile) >> 4) & 0x0F;
loop_start = read_s32le(0x0c, sf);
format = read_u8(0x12, sf);
freq_mode = read_u8(0x13, sf) & 0x0F;
channels = (read_u8(0x13, sf) >> 4) & 0x0F;
switch (freq_mode) {
case 0x00: sample_rate = 11025; break;
@ -67,7 +67,7 @@ VGMSTREAM *init_vgmstream_xbox_hlwav(STREAMFILE *streamFile) {
goto fail;
}
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
@ -78,8 +78,8 @@ fail:
/* .360.WAV, .PS3.WAV - from Valve games running on Source Engine, evolution of Xbox .WAV format seen above */
/* [The Orange Box (X360), Portal 2 (PS3/X360), Counter-Strike: Global Offensive (PS3/X360)] */
VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
VGMSTREAM *vgmstream = NULL;
VGMSTREAM* init_vgmstream_xmv_valve(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
int32_t loop_start;
uint32_t start_offset, data_size, sample_rate, num_samples;
uint16_t /*loop_block, loop_start_skip,*/ loop_end_skip;
@ -87,30 +87,29 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
int loop_flag;
/* checks */
if (!check_extensions(streamFile, "wav,lwav"))
if (!is_id32be(0x00, sf, "XMV "))
goto fail;
/* check header magic */
if (read_u32be(0x00, streamFile) != 0x58575620) /* "XMV " */
if (!check_extensions(sf, "wav,lwav"))
goto fail;
/* only version 4 is known */
if (read_u32be(0x04, streamFile) != 0x04)
if (read_u32be(0x04, sf) != 0x04)
goto fail;
start_offset = read_u32be(0x10, streamFile);
data_size = read_u32be(0x14, streamFile);
num_samples = read_u32be(0x18, streamFile);
loop_start = read_s32be(0x1c, streamFile);
start_offset = read_u32be(0x10, sf);
data_size = read_u32be(0x14, sf);
num_samples = read_u32be(0x18, sf);
loop_start = read_s32be(0x1c, sf);
/* XMA only */
//loop_block = read_u16be(0x20, streamFile);
//loop_start_skip = read_u16be(0x22, streamFile);
loop_end_skip = read_u16be(0x24, streamFile);
//loop_block = read_u16be(0x20, sf);
//loop_start_skip = read_u16be(0x22, sf);
loop_end_skip = read_u16be(0x24, sf);
format = read_u8(0x28, streamFile);
freq_mode = read_u8(0x2a, streamFile);
channels = read_u8(0x2b, streamFile);
format = read_u8(0x28, sf);
freq_mode = read_u8(0x2a, sf);
channels = read_u8(0x2b, sf);
switch (freq_mode) {
case 0x00: sample_rate = 11025; break;
@ -151,13 +150,13 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
bytes = ffmpeg_make_riff_xma2(buf, 0x100, num_samples, data_size, channels, sample_rate, block_count, block_size);
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf, bytes, start_offset, data_size);
vgmstream->codec_data = init_ffmpeg_header_offset(sf, buf, bytes, start_offset, data_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
vgmstream->loop_end_sample -= loop_end_skip;
xma_fix_raw_samples(vgmstream, streamFile, start_offset, data_size, 0, 1, 1);
xma_fix_raw_samples(vgmstream, sf, start_offset, data_size, 0, 1, 1);
break;
}
#endif
@ -168,7 +167,7 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
if (loop_flag) /* should never happen, Source cannot loop MP3 */
goto fail;
vgmstream->codec_data = init_mpeg(streamFile, start_offset, &mpeg_coding, channels);
vgmstream->codec_data = init_mpeg(sf, start_offset, &mpeg_coding, channels);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = mpeg_coding;
vgmstream->layout_type = layout_none;
@ -183,7 +182,7 @@ VGMSTREAM *init_vgmstream_xmv_valve(STREAMFILE *streamFile) {
goto fail;
}
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;

View File

@ -406,7 +406,6 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
}
else if (strncasecmp(tags->key, "EXACTMATCH", key_len) == 0) {
tags->exact_match = 1;
VGM_LOG("exact\n");
}
continue; /* not an actual tag */

View File

@ -788,7 +788,7 @@ int psb_node_exists(const psb_node_t* node, const char* key) {
static void print_internal(psb_node_t* curr, int depth) {
int i;
psb_node_t node;
psb_node_t node = { 0 };
const char* key;
psb_type_t type;
psb_result_t res;
@ -857,7 +857,7 @@ static void print_internal(psb_node_t* curr, int depth) {
}
void psb_print(psb_context_t* ctx) {
psb_node_t node;
psb_node_t node = { 0 };
psb_get_root(ctx, &node);
print_internal(&node, 0);

View File

@ -1,3 +1,4 @@
#include "miniz.h"
/**************************************************************************
*
* Copyright 2013-2014 RAD Game Tools and Valve Software
@ -24,7 +25,7 @@
*
**************************************************************************/
#include "circus_decoder_miniz.h"
typedef unsigned char mz_validate_uint16[sizeof(mz_uint16) == 2 ? 1 : -1];
typedef unsigned char mz_validate_uint32[sizeof(mz_uint32) == 4 ? 1 : -1];
@ -82,6 +83,12 @@ mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
}
return ~crcu32;
}
#elif defined(USE_EXTERNAL_MZCRC)
/* If USE_EXTERNAL_CRC is defined, an external module will export the
* mz_crc32() symbol for us to use, e.g. an SSE-accelerated version.
* Depending on the impl, it may be necessary to ~ the input/output crc values.
*/
mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len);
#else
/* Faster, but larger CPU cache footprint.
*/
@ -157,17 +164,17 @@ void mz_free(void *p)
MZ_FREE(p);
}
void *miniz_def_alloc_func(void *opaque, size_t items, size_t size)
MINIZ_EXPORT void *miniz_def_alloc_func(void *opaque, size_t items, size_t size)
{
(void)opaque, (void)items, (void)size;
return MZ_MALLOC(items * size);
}
void miniz_def_free_func(void *opaque, void *address)
MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address)
{
(void)opaque, (void)address;
MZ_FREE(address);
}
void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size)
MINIZ_EXPORT void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size)
{
(void)opaque, (void)address, (void)items, (void)size;
return MZ_REALLOC(address, items * size);
@ -546,19 +553,18 @@ int mz_inflateEnd(mz_streamp pStream)
}
return MZ_OK;
}
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len)
{
mz_stream stream;
int status;
memset(&stream, 0, sizeof(stream));
/* In case mz_ulong is 64-bits (argh I hate longs). */
if ((source_len | *pDest_len) > 0xFFFFFFFFU)
if ((*pSource_len | *pDest_len) > 0xFFFFFFFFU)
return MZ_PARAM_ERROR;
stream.next_in = pSource;
stream.avail_in = (mz_uint32)source_len;
stream.avail_in = (mz_uint32)*pSource_len;
stream.next_out = pDest;
stream.avail_out = (mz_uint32)*pDest_len;
@ -567,6 +573,7 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char
return status;
status = mz_inflate(&stream, MZ_FINISH);
*pSource_len = *pSource_len - stream.avail_in;
if (status != MZ_STREAM_END)
{
mz_inflateEnd(&stream);
@ -577,6 +584,11 @@ int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char
return mz_inflateEnd(&stream);
}
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
{
return mz_uncompress2(pDest, pDest_len, pSource, &source_len);
}
const char *mz_error(int err)
{
static struct
@ -654,7 +666,6 @@ const char *mz_error(int err)
#ifdef __cplusplus
extern "C" {
#endif
@ -1703,9 +1714,7 @@ static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match
s0 = s_tdefl_small_dist_sym[match_dist & 511];
s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127];
d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++;
if (match_len >= TDEFL_MIN_MATCH_LEN)
d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++;
d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++;
}
static mz_bool tdefl_compress_normal(tdefl_compressor *d)
@ -1962,6 +1971,7 @@ tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_fun
d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0;
d->m_pLZ_code_buf = d->m_lz_code_buf + 1;
d->m_pLZ_flags = d->m_lz_code_buf;
*d->m_pLZ_flags = 0;
d->m_num_flags_left = 8;
d->m_pOutput_buf = d->m_output_buf;
d->m_pOutput_buf_end = d->m_output_buf;
@ -2205,7 +2215,7 @@ void tdefl_compressor_free(tdefl_compressor *pComp)
#ifdef __cplusplus
}
#endif
/**************************************************************************
/**************************************************************************
*
* Copyright 2013-2014 RAD Game Tools and Valve Software
* Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
@ -2705,7 +2715,7 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
}
dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))
if ((dist == 0 || dist > dist_from_out_buf_start || dist_from_out_buf_start == 0) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))
{
TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED);
}
@ -2945,7 +2955,7 @@ void tinfl_decompressor_free(tinfl_decompressor *pDecomp)
#ifdef __cplusplus
}
#endif
/**************************************************************************
/**************************************************************************
*
* Copyright 2013-2014 RAD Game Tools and Valve Software
* Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
@ -3044,7 +3054,7 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
#define MZ_FFLUSH fflush
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
#define MZ_DELETE_FILE remove
#elif defined(__GNUC__) && defined(_LARGEFILE64_SOURCE)
#elif defined(__USE_LARGEFILE64) /* gcc, clang */
#ifndef MINIZ_NO_TIME
#include <utime.h>
#endif
@ -3224,7 +3234,7 @@ struct mz_zip_internal_state_tag
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
#if defined(DEBUG) || defined(_DEBUG) || defined(NDEBUG)
#if defined(DEBUG) || defined(_DEBUG)
static MZ_FORCEINLINE mz_uint mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index)
{
MZ_ASSERT(index < pArray->m_size);
@ -4592,7 +4602,9 @@ void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFile
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
{
int status = TINFL_STATUS_DONE;
#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
mz_uint file_crc32 = MZ_CRC32_INIT;
#endif
mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
mz_zip_archive_file_stat file_stat;
void *pRead_buf = NULL;
@ -4888,7 +4900,7 @@ mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive
if (!((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!pState->file_stat.m_method)))
{
/* Decompression required, therefore intermediate read buffer required */
pState->read_buf_size = MZ_MIN(pState->file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
pState->read_buf_size = MZ_MIN(pState->file_stat.m_comp_size, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
if (NULL == (pState->pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)pState->read_buf_size)))
{
mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
@ -5246,7 +5258,10 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
if (!mz_zip_array_resize(pZip, &file_data_array, MZ_MAX(local_header_filename_len, local_header_extra_len), MZ_FALSE))
return mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
{
mz_zip_set_error(pZip, MZ_ZIP_ALLOC_FAILED);
goto handle_failure;
}
if (local_header_filename_len)
{
@ -5280,14 +5295,20 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
mz_uint32 field_id, field_data_size, field_total_size;
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
{
mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
goto handle_failure;
}
field_id = MZ_READ_LE16(pExtra_data);
field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
field_total_size = field_data_size + sizeof(mz_uint16) * 2;
if (field_total_size > extra_size_remaining)
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
{
mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
goto handle_failure;
}
if (field_id == MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID)
{
@ -6180,8 +6201,8 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
if (!pState->m_zip64)
{
/* Bail early if the archive would obviously become too large */
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size
+ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len +
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size
+ MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + user_extra_data_len +
pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + user_extra_data_central_len
+ MZ_ZIP_DATA_DESCRIPTER_SIZE32) > 0xFFFFFFFF)
{
@ -6370,20 +6391,20 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
return MZ_TRUE;
}
mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 max_size, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
{
mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
mz_uint16 gen_flags = (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE) ? 0 : MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = size_to_add, comp_size = 0;
mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0;
size_t archive_name_size;
mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
mz_uint8 *pExtra_data = NULL;
mz_uint32 extra_size = 0;
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
mz_zip_internal_state *pState;
mz_uint64 file_ofs = 0;
mz_uint64 file_ofs = 0, cur_archive_header_file_ofs;
if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
@ -6398,7 +6419,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
pState = pZip->m_pState;
if ((!pState->m_zip64) && (uncomp_size > MZ_UINT32_MAX))
if ((!pState->m_zip64) && (max_size > MZ_UINT32_MAX))
{
/* Source file is too large for non-zip64 */
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
@ -6455,7 +6476,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
}
#endif
if (uncomp_size <= 3)
if (max_size <= 3)
level = 0;
if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes))
@ -6471,7 +6492,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
MZ_ASSERT((cur_archive_file_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
}
if (uncomp_size && level)
if (max_size && level)
{
method = MZ_DEFLATED;
}
@ -6479,11 +6500,17 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
MZ_CLEAR_OBJ(local_dir_header);
if (pState->m_zip64)
{
if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
if (max_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
{
pExtra_data = extra_data;
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
if (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE)
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (max_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
(max_size >= MZ_UINT32_MAX) ? &comp_size : NULL,
(local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
else
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, NULL,
NULL,
(local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
}
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len), 0, 0, 0, method, gen_flags, dos_time, dos_date))
@ -6534,9 +6561,8 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
cur_archive_file_ofs += user_extra_data_len;
}
if (uncomp_size)
if (max_size)
{
mz_uint64 uncomp_remaining = uncomp_size;
void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE);
if (!pRead_buf)
{
@ -6545,19 +6571,27 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
if (!level)
{
while (uncomp_remaining)
while (1)
{
mz_uint n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
if ((read_callback(callback_opaque, file_ofs, pRead_buf, n) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
size_t n = read_callback(callback_opaque, file_ofs, pRead_buf, MZ_ZIP_MAX_IO_BUF_SIZE);
if (n == 0)
break;
if ((n > MZ_ZIP_MAX_IO_BUF_SIZE) || (file_ofs + n > max_size))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
}
file_ofs += n;
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
}
file_ofs += n;
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);
uncomp_remaining -= n;
cur_archive_file_ofs += n;
}
uncomp_size = file_ofs;
comp_size = uncomp_size;
}
else
@ -6584,24 +6618,26 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
for (;;)
{
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
tdefl_status status;
tdefl_flush flush = TDEFL_NO_FLUSH;
if (read_callback(callback_opaque, file_ofs, pRead_buf, in_buf_size)!= in_buf_size)
size_t n = read_callback(callback_opaque, file_ofs, pRead_buf, MZ_ZIP_MAX_IO_BUF_SIZE);
if ((n > MZ_ZIP_MAX_IO_BUF_SIZE) || (file_ofs + n > max_size))
{
mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
break;
}
file_ofs += in_buf_size;
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
uncomp_remaining -= in_buf_size;
file_ofs += n;
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);
if (pZip->m_pNeeds_keepalive != NULL && pZip->m_pNeeds_keepalive(pZip->m_pIO_opaque))
flush = TDEFL_FULL_FLUSH;
status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? flush : TDEFL_FINISH);
if (n == 0)
flush = TDEFL_FINISH;
status = tdefl_compress_buffer(pComp, pRead_buf, n, flush);
if (status == TDEFL_STATUS_DONE)
{
result = MZ_TRUE;
@ -6622,6 +6658,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
return MZ_FALSE;
}
uncomp_size = file_ofs;
comp_size = state.m_comp_size;
cur_archive_file_ofs = state.m_cur_archive_file_ofs;
}
@ -6629,6 +6666,7 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
}
if (!(level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE))
{
mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
@ -6656,6 +6694,44 @@ mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pA
cur_archive_file_ofs += local_dir_footer_size;
}
if (level_and_flags & MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE)
{
if (pExtra_data != NULL)
{
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (max_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
(max_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
}
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header,
(mz_uint16)archive_name_size, (mz_uint16)(extra_size + user_extra_data_len),
(max_size >= MZ_UINT32_MAX) ? MZ_UINT32_MAX : uncomp_size,
(max_size >= MZ_UINT32_MAX) ? MZ_UINT32_MAX : comp_size,
uncomp_crc32, method, gen_flags, dos_time, dos_date))
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
cur_archive_header_file_ofs = local_dir_header_ofs;
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
if (pExtra_data != NULL)
{
cur_archive_header_file_ofs += sizeof(local_dir_header);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
{
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
}
cur_archive_header_file_ofs += archive_name_size;
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_header_file_ofs, extra_data, extra_size) != extra_size)
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
cur_archive_header_file_ofs += extra_size;
}
}
if (pExtra_data != NULL)
{
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
@ -6686,10 +6762,10 @@ static size_t mz_file_read_func_stdio(void *pOpaque, mz_uint64 file_ofs, void *p
return MZ_FREAD(pBuf, 1, n, pSrc_file);
}
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 max_size, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
{
return mz_zip_writer_add_read_buf_callback(pZip, pArchive_name, mz_file_read_func_stdio, pSrc_file, size_to_add, pFile_time, pComment, comment_size, level_and_flags,
return mz_zip_writer_add_read_buf_callback(pZip, pArchive_name, mz_file_read_func_stdio, pSrc_file, max_size, pFile_time, pComment, comment_size, level_and_flags,
user_extra_data, user_extra_data_len, user_extra_data_central, user_extra_data_central_len);
}

View File

@ -1,12 +1,20 @@
// vgmstream config
/* ************************************************************************* */
/* vgmstream config for miniz, to avoid some warning and portability issues,
* needed here since we aren't passing external flags to miniz.c.
* Rest of file is unmodified vs official github release */
/* remove .zip handling stuff */
#define MINIZ_NO_STDIO
#define MINIZ_NO_TIME
#define MINIZ_NO_ARCHIVE_APIS
#define MINIZ_NO_ARCHIVE_WRITING_APIS
/* force non-aligned reads to improve compiler warnings (slower tho) */
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 0
/* .zip handling stuff */
#define MINIZ_NO_TIME 1
#define MINIZ_NO_ARCHIVE_APIS 1
#define MINIZ_NO_ARCHIVE_WRITING_APIS 1
/* ************************************************************************* */
/* miniz.c 2.1.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
#define MINIZ_EXPORT
/* miniz.c 2.2.0 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
See "unlicense" statement at the end of this file.
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
@ -103,7 +111,7 @@
possibility that the archive's central directory could be lost with this method if anything goes wrong, though.
- ZIP archive support limitations:
No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
No spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
Requires streams capable of seeking.
* This is a header file library, like stb_image.c. To get only a header file, either cut and paste the
@ -122,8 +130,6 @@
/* Defines to completely disable specific portions of miniz.c:
If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl. */
@ -206,15 +212,15 @@ extern "C" {
typedef unsigned long mz_ulong;
/* mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap. */
void mz_free(void *p);
MINIZ_EXPORT void mz_free(void *p);
#define MZ_ADLER32_INIT (1)
/* mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL. */
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
MINIZ_EXPORT mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
#define MZ_CRC32_INIT (0)
/* mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL. */
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
MINIZ_EXPORT mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
/* Compression strategies. */
enum
@ -230,7 +236,7 @@ enum
#define MZ_DEFLATED 8
/* Heap allocation callbacks.
Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long. */
Note that mz_alloc_func parameter types purposely differ from zlib's: items/size is size_t, not unsigned long. */
typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
typedef void (*mz_free_func)(void *opaque, void *address);
typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
@ -246,10 +252,10 @@ enum
MZ_DEFAULT_COMPRESSION = -1
};
#define MZ_VERSION "10.1.0"
#define MZ_VERSION "10.2.0"
#define MZ_VERNUM 0xA100
#define MZ_VER_MAJOR 10
#define MZ_VER_MINOR 1
#define MZ_VER_MINOR 2
#define MZ_VER_REVISION 0
#define MZ_VER_SUBREVISION 0
@ -312,7 +318,7 @@ typedef struct mz_stream_s
typedef mz_stream *mz_streamp;
/* Returns the version string of miniz.c. */
const char *mz_version(void);
MINIZ_EXPORT const char *mz_version(void);
/* mz_deflateInit() initializes a compressor with default options: */
/* Parameters: */
@ -325,17 +331,17 @@ const char *mz_version(void);
/* MZ_STREAM_ERROR if the stream is bogus. */
/* MZ_PARAM_ERROR if the input parameters are bogus. */
/* MZ_MEM_ERROR on out of memory. */
int mz_deflateInit(mz_streamp pStream, int level);
MINIZ_EXPORT int mz_deflateInit(mz_streamp pStream, int level);
/* mz_deflateInit2() is like mz_deflate(), except with more control: */
/* Additional parameters: */
/* method must be MZ_DEFLATED */
/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer) */
/* mem_level must be between [1, 9] (it's checked but ignored by miniz.c) */
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
MINIZ_EXPORT int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2(). */
int mz_deflateReset(mz_streamp pStream);
MINIZ_EXPORT int mz_deflateReset(mz_streamp pStream);
/* mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible. */
/* Parameters: */
@ -347,34 +353,34 @@ int mz_deflateReset(mz_streamp pStream);
/* MZ_STREAM_ERROR if the stream is bogus. */
/* MZ_PARAM_ERROR if one of the parameters is invalid. */
/* MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.) */
int mz_deflate(mz_streamp pStream, int flush);
MINIZ_EXPORT int mz_deflate(mz_streamp pStream, int flush);
/* mz_deflateEnd() deinitializes a compressor: */
/* Return values: */
/* MZ_OK on success. */
/* MZ_STREAM_ERROR if the stream is bogus. */
int mz_deflateEnd(mz_streamp pStream);
MINIZ_EXPORT int mz_deflateEnd(mz_streamp pStream);
/* mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH. */
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
MINIZ_EXPORT mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
/* Single-call compression functions mz_compress() and mz_compress2(): */
/* Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure. */
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
MINIZ_EXPORT int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
MINIZ_EXPORT int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
/* mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress(). */
mz_ulong mz_compressBound(mz_ulong source_len);
MINIZ_EXPORT mz_ulong mz_compressBound(mz_ulong source_len);
/* Initializes a decompressor. */
int mz_inflateInit(mz_streamp pStream);
MINIZ_EXPORT int mz_inflateInit(mz_streamp pStream);
/* mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer: */
/* window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate). */
int mz_inflateInit2(mz_streamp pStream, int window_bits);
MINIZ_EXPORT int mz_inflateInit2(mz_streamp pStream, int window_bits);
/* Quickly resets a compressor without having to reallocate anything. Same as calling mz_inflateEnd() followed by mz_inflateInit()/mz_inflateInit2(). */
int mz_inflateReset(mz_streamp pStream);
MINIZ_EXPORT int mz_inflateReset(mz_streamp pStream);
/* Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible. */
/* Parameters: */
@ -390,17 +396,18 @@ int mz_inflateReset(mz_streamp pStream);
/* MZ_PARAM_ERROR if one of the parameters is invalid. */
/* MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again */
/* with more input data, or with more room in the output buffer (except when using single call decompression, described above). */
int mz_inflate(mz_streamp pStream, int flush);
MINIZ_EXPORT int mz_inflate(mz_streamp pStream, int flush);
/* Deinitializes a decompressor. */
int mz_inflateEnd(mz_streamp pStream);
MINIZ_EXPORT int mz_inflateEnd(mz_streamp pStream);
/* Single-call decompression. */
/* Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure. */
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
MINIZ_EXPORT int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
MINIZ_EXPORT int mz_uncompress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong *pSource_len);
/* Returns a string description of the specified error code, or NULL if the error code is invalid. */
const char *mz_error(int err);
MINIZ_EXPORT const char *mz_error(int err);
/* Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports. */
/* Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project. */
@ -463,6 +470,7 @@ typedef void *const voidpc;
#define inflate mz_inflate
#define inflateEnd mz_inflateEnd
#define uncompress mz_uncompress
#define uncompress2 mz_uncompress2
#define crc32 mz_crc32
#define adler32 mz_adler32
#define MAX_WBITS 15
@ -483,12 +491,19 @@ typedef void *const voidpc;
#ifdef __cplusplus
}
#endif
#pragma once
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
/* ------------------- Types and macros */
typedef unsigned char mz_uint8;
typedef signed short mz_int16;
@ -564,9 +579,9 @@ typedef struct mz_dummy_time_t_tag
extern "C" {
#endif
extern void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
extern void miniz_def_free_func(void *opaque, void *address);
extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
extern MINIZ_EXPORT void *miniz_def_alloc_func(void *opaque, size_t items, size_t size);
extern MINIZ_EXPORT void miniz_def_free_func(void *opaque, void *address);
extern MINIZ_EXPORT void *miniz_def_realloc_func(void *opaque, void *address, size_t items, size_t size);
#define MZ_UINT16_MAX (0xFFFFU)
#define MZ_UINT32_MAX (0xFFFFFFFFU)
@ -574,7 +589,7 @@ extern void *miniz_def_realloc_func(void *opaque, void *address, size_t items, s
#ifdef __cplusplus
}
#endif
#pragma once
#pragma once
#ifdef __cplusplus
@ -624,11 +639,11 @@ enum
/* Function returns a pointer to the compressed data, or NULL on failure. */
/* *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data. */
/* The caller must free() the returned block when it's no longer needed. */
void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
MINIZ_EXPORT void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
/* tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory. */
/* Returns 0 on failure. */
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
MINIZ_EXPORT size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
/* Compresses an image to a compressed PNG file in memory. */
/* On entry: */
@ -640,14 +655,14 @@ size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void
/* Function returns a pointer to the compressed data, or NULL on failure. */
/* *pLen_out will be set to the size of the PNG image file. */
/* The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed. */
void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
MINIZ_EXPORT void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
/* Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time. */
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
/* tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally. */
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
MINIZ_EXPORT mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
enum
{
@ -735,36 +750,36 @@ typedef struct
/* pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression. */
/* If pBut_buf_func is NULL the user should always call the tdefl_compress() API. */
/* flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.) */
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
MINIZ_EXPORT tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
/* Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible. */
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
MINIZ_EXPORT tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
/* tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr. */
/* tdefl_compress_buffer() always consumes the entire input buffer. */
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
MINIZ_EXPORT tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
MINIZ_EXPORT tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
MINIZ_EXPORT mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
/* Create tdefl_compress() flags given zlib-style compression parameters. */
/* level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files) */
/* window_bits may be -15 (raw deflate) or 15 (zlib) */
/* strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED */
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
MINIZ_EXPORT mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
#ifndef MINIZ_NO_MALLOC
/* Allocate the tdefl_compressor structure in C so that */
/* non-C language bindings to tdefl_ API don't need to worry about */
/* structure size and allocation mechanism. */
tdefl_compressor *tdefl_compressor_alloc(void);
void tdefl_compressor_free(tdefl_compressor *pComp);
MINIZ_EXPORT tdefl_compressor *tdefl_compressor_alloc(void);
MINIZ_EXPORT void tdefl_compressor_free(tdefl_compressor *pComp);
#endif
#ifdef __cplusplus
}
#endif
#pragma once
#pragma once
/* ------------------- Low-level Decompression API Definitions */
@ -792,17 +807,17 @@ enum
/* Function returns a pointer to the decompressed data, or NULL on failure. */
/* *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data. */
/* The caller must call mz_free() on the returned block when it's no longer needed. */
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
MINIZ_EXPORT void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
/* tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory. */
/* Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success. */
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
MINIZ_EXPORT size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
/* tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer. */
/* Returns 1 on success or 0 on failure. */
typedef int (*tinfl_put_buf_func_ptr)(const void *pBuf, int len, void *pUser);
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
MINIZ_EXPORT int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
struct tinfl_decompressor_tag;
typedef struct tinfl_decompressor_tag tinfl_decompressor;
@ -811,8 +826,8 @@ typedef struct tinfl_decompressor_tag tinfl_decompressor;
/* Allocate the tinfl_decompressor structure in C so that */
/* non-C language bindings to tinfl_ API don't need to worry about */
/* structure size and allocation mechanism. */
tinfl_decompressor *tinfl_decompressor_alloc(void);
void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
MINIZ_EXPORT tinfl_decompressor *tinfl_decompressor_alloc(void);
MINIZ_EXPORT void tinfl_decompressor_free(tinfl_decompressor *pDecomp);
#endif
/* Max size of LZ dictionary. */
@ -863,7 +878,7 @@ typedef enum {
/* Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability. */
/* This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output. */
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
MINIZ_EXPORT tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
/* Internal/private bits follow. */
enum
@ -908,7 +923,7 @@ struct tinfl_decompressor_tag
#ifdef __cplusplus
}
#endif
#pragma once
@ -1007,7 +1022,10 @@ typedef enum {
MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY = 0x2000, /* validate the local headers, but don't decompress the entire file and check the crc32 */
MZ_ZIP_FLAG_WRITE_ZIP64 = 0x4000, /* always use the zip64 file format, instead of the original zip file format with automatic switch to zip64. Use as flags parameter with mz_zip_writer_init*_v2 */
MZ_ZIP_FLAG_WRITE_ALLOW_READING = 0x8000,
MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000
MZ_ZIP_FLAG_ASCII_FILENAME = 0x10000,
/*After adding a compressed file, seek back
to local file header and set the correct sizes*/
MZ_ZIP_FLAG_WRITE_HEADER_SET_SIZE = 0x20000
} mz_zip_flags;
typedef enum {
@ -1108,117 +1126,117 @@ typedef struct
/* Inits a ZIP archive reader. */
/* These functions read and validate the archive's central directory. */
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint flags);
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint flags);
#ifndef MINIZ_NO_STDIO
/* Read a archive from a disk file. */
/* file_start_ofs is the file offset where the archive actually begins, or 0. */
/* actual_archive_size is the true total size of the archive, which may be smaller than the file's actual size on disk. If zero the entire file is treated as the archive. */
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
MINIZ_EXPORT mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
MINIZ_EXPORT mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size);
/* Read an archive from an already opened FILE, beginning at the current file position. */
/* The archive is assumed to be archive_size bytes long. If archive_size is < 0, then the entire rest of the file is assumed to contain the archive. */
/* The archive is assumed to be archive_size bytes long. If archive_size is 0, then the entire rest of the file is assumed to contain the archive. */
/* The FILE will NOT be closed when mz_zip_reader_end() is called. */
mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64 archive_size, mz_uint flags);
#endif
/* Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used. */
mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
MINIZ_EXPORT mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
/* -------- ZIP reading or writing */
/* Clears a mz_zip_archive struct to all zeros. */
/* Important: This must be done before passing the struct to any mz_zip functions. */
void mz_zip_zero_struct(mz_zip_archive *pZip);
MINIZ_EXPORT void mz_zip_zero_struct(mz_zip_archive *pZip);
mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
MINIZ_EXPORT mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
MINIZ_EXPORT mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
/* Returns the total number of files in the archive. */
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
MINIZ_EXPORT mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
MINIZ_EXPORT mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
MINIZ_EXPORT mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
MINIZ_EXPORT MZ_FILE *mz_zip_get_cfile(mz_zip_archive *pZip);
/* Reads n bytes of raw archive data, starting at file offset file_ofs, to pBuf. */
size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
MINIZ_EXPORT size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *pBuf, size_t n);
/* All mz_zip funcs set the m_last_error field in the mz_zip_archive struct. These functions retrieve/manipulate this field. */
/* Note that the m_last_error functionality is not thread safe. */
mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip);
mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip);
mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
const char *mz_zip_get_error_string(mz_zip_error mz_err);
MINIZ_EXPORT mz_zip_error mz_zip_set_last_error(mz_zip_archive *pZip, mz_zip_error err_num);
MINIZ_EXPORT mz_zip_error mz_zip_peek_last_error(mz_zip_archive *pZip);
MINIZ_EXPORT mz_zip_error mz_zip_clear_last_error(mz_zip_archive *pZip);
MINIZ_EXPORT mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
MINIZ_EXPORT const char *mz_zip_get_error_string(mz_zip_error mz_err);
/* MZ_TRUE if the archive file entry is a directory entry. */
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
/* MZ_TRUE if the file is encrypted/strong encrypted. */
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
/* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
MINIZ_EXPORT mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
/* Retrieves the filename of an archive file entry. */
/* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
MINIZ_EXPORT mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
/* Attempts to locates a file in the archive's central directory. */
/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
/* Returns -1 if the file cannot be found. */
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
int mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
MINIZ_EXPORT int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
/* Returns detailed information about an archive file entry. */
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
MINIZ_EXPORT mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
/* MZ_TRUE if the file is in zip64 format. */
/* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */
mz_bool mz_zip_is_zip64(mz_zip_archive *pZip);
MINIZ_EXPORT mz_bool mz_zip_is_zip64(mz_zip_archive *pZip);
/* Returns the total central directory size in bytes. */
/* The current max supported size is <= MZ_UINT32_MAX. */
size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
MINIZ_EXPORT size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
/* Extracts a archive file to a memory buffer using no memory allocation. */
/* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
/* Extracts a archive file to a memory buffer. */
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
/* Extracts a archive file to a dynamically allocated heap buffer. */
/* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
/* Returns NULL and sets the last error on failure. */
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
MINIZ_EXPORT void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
MINIZ_EXPORT void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
/* Extracts a archive file using a callback function to output the file's data. */
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
/* Extract a file iteratively */
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size);
mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState);
MINIZ_EXPORT mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
MINIZ_EXPORT mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
MINIZ_EXPORT size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState);
#ifndef MINIZ_NO_STDIO
/* Extracts a archive file to a disk file and sets its last accessed and modified times. */
/* This function only extracts files, not archive directory records. */
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
/* Extracts a archive file starting at the current position in the destination FILE stream. */
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
#endif
#if 0
@ -1234,17 +1252,17 @@ mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pA
/* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */
/* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
/* Validates an entire archive by calling mz_zip_validate_file() on each file. */
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
/* Misc utils/helpers, valid for ZIP reading or writing */
mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr);
mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr);
MINIZ_EXPORT mz_bool mz_zip_validate_mem_archive(const void *pMem, size_t size, mz_uint flags, mz_zip_error *pErr);
MINIZ_EXPORT mz_bool mz_zip_validate_file_archive(const char *pFilename, mz_uint flags, mz_zip_error *pErr);
/* Universal end function - calls either mz_zip_reader_end() or mz_zip_writer_end(). */
mz_bool mz_zip_end(mz_zip_archive *pZip);
MINIZ_EXPORT mz_bool mz_zip_end(mz_zip_archive *pZip);
/* -------- ZIP writing */
@ -1253,16 +1271,16 @@ mz_bool mz_zip_end(mz_zip_archive *pZip);
/* Inits a ZIP archive writer. */
/*Set pZip->m_pWrite (and pZip->m_pIO_opaque) before calling mz_zip_writer_init or mz_zip_writer_init_v2*/
/*The output is streamable, i.e. file_ofs in mz_file_write_func always increases only by n*/
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
MINIZ_EXPORT mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags);
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
MINIZ_EXPORT mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags);
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
MINIZ_EXPORT mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags);
#endif
/* Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive. */
@ -1271,56 +1289,57 @@ mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint f
/* Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL. */
/* Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before */
/* the archive is finalized the file's central directory will be hosed. */
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
MINIZ_EXPORT mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
/* Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive. */
/* To add a directory entry, call this method with an archive name ending in a forwardslash with an empty buffer. */
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
MINIZ_EXPORT mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
/* Like mz_zip_writer_add_mem(), except you can specify a file comment field, and optionally supply the function with already compressed data. */
/* uncomp_size/uncomp_crc32 are only used if the MZ_ZIP_FLAG_COMPRESSED_DATA flag is specified. */
mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
MINIZ_EXPORT mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
/* Adds the contents of a file to an archive. This function also records the disk file's modified time into the archive. */
/* File data is supplied via a read callback function. User mz_zip_writer_add_(c)file to add a file directly.*/
mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 size_to_add,
MINIZ_EXPORT mz_bool mz_zip_writer_add_read_buf_callback(mz_zip_archive *pZip, const char *pArchive_name, mz_file_read_func read_callback, void* callback_opaque, mz_uint64 max_size,
const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
#ifndef MINIZ_NO_STDIO
/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
MINIZ_EXPORT mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
/* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add,
MINIZ_EXPORT mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 max_size,
const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
#endif
/* Adds a file to an archive by fully cloning the data from another archive. */
/* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
MINIZ_EXPORT mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
/* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
/* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
/* An archive must be manually finalized by calling this function for it to be valid. */
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
MINIZ_EXPORT mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
/* Finalizes a heap archive, returning a poiner to the heap block and its size. */
/* The heap block will be allocated using the mz_zip_archive's alloc/realloc callbacks. */
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize);
MINIZ_EXPORT mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **ppBuf, size_t *pSize);
/* Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used. */
/* Note for the archive to be valid, it *must* have been finalized before ending (this function will not do it for you). */
mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
MINIZ_EXPORT mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
/* -------- Misc. high-level helper functions: */
@ -1328,14 +1347,14 @@ mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
/* Note this is NOT a fully safe operation. If it crashes or dies in some way your archive can be left in a screwed up state (without a central directory). */
/* level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION. */
/* TODO: Perhaps add an option to leave the existing central dir in place in case the add dies? We could then truncate the file (so the old central dir would be at the end) if something goes wrong. */
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr);
MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
MINIZ_EXPORT mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_zip_error *pErr);
/* Reads a single file from an archive into a heap block. */
/* If pComment is not NULL, only the file with the specified comment will be extracted. */
/* Returns NULL on failure. */
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr);
MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags);
MINIZ_EXPORT void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr);
#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */

View File

@ -129,7 +129,6 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
init_vgmstream_idsp_ie,
init_vgmstream_ngc_ymf,
init_vgmstream_sadl,
init_vgmstream_ps2_ccc,
init_vgmstream_fag,
init_vgmstream_ps2_mihb,
init_vgmstream_ngc_pdt_split,
@ -526,10 +525,10 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
init_vgmstream_bw_riff_mp3,
init_vgmstream_sndz,
init_vgmstream_vab,
init_vgmstream_bigrp,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_agsc,
init_vgmstream_dtk,
init_vgmstream_rsf,
init_vgmstream_ps2_wmus,
init_vgmstream_mib_mih,
@ -542,6 +541,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
init_vgmstream_dtk,
init_vgmstream_mpeg, /* semi-raw MP3 */
init_vgmstream_encrypted, /* encrypted stuff */
init_vgmstream_btsnd, /* semi-headerless */
@ -555,6 +555,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
init_vgmstream_ngc_ulw, /* .ulw raw u-Law */
init_vgmstream_exakt_sc, /* .sc raw PCM */
init_vgmstream_zwdsp, /* fake format */
init_vgmstream_ps2_ccc, /* fake format, to be removed */
init_vgmstream_ps2_adm, /* weird non-constant PSX blocks */
init_vgmstream_baf_badrip, /* crap, to be removed */
init_vgmstream_rxws_badrip, /* crap, to be removed */

View File

@ -7,7 +7,10 @@
/* reasonable limits */
enum {
PATH_LIMIT = 32768,
/* Windows generally only allows 260 chars in path, but other OSs have higher limits, and we handle
* UTF-8 (that typically uses 2-bytes for common non-latin codepages) plus player may append protocols
* to paths, so it should be a bit higher. Most people wouldn't use huge paths though. */
PATH_LIMIT = 4096, /* (256 * 8) * 2 = ~max_path * (other_os+extra) * codepage_bytes */
STREAM_NAME_SIZE = 255,
VGMSTREAM_MAX_CHANNELS = 64,
VGMSTREAM_MIN_SAMPLE_RATE = 300, /* 300 is Wwise min */
@ -191,6 +194,8 @@ typedef enum {
coding_RELIC, /* Relic Codec (DCT-based) */
coding_CRI_HCA, /* CRI High Compression Audio (MDCT-based) */
coding_TAC, /* tri-Ace Codec (MDCT-based) */
coding_ICE_RANGE, /* Inti Creates "range" codec */
coding_ICE_DCT, /* Inti Creates "DCT" codec */
#ifdef VGM_USE_VORBIS
coding_OGG_VORBIS, /* Xiph Vorbis with Ogg layer (MDCT-based) */
@ -771,6 +776,7 @@ typedef enum {
meta_TT_AD,
meta_SNDZ,
meta_VAB,
meta_BIGRP,
} meta_t;