From 1ca6207b465b9f02b357b699ee7fa3b0b0efb661 Mon Sep 17 00:00:00 2001 From: bnnm Date: Thu, 25 Jul 2024 18:21:23 +0200 Subject: [PATCH] cleanup: misc fixes --- .github/formats-info.py | 2 +- cli/Makefile | 8 +++++++- cli/vgmstream_cli.c | 5 +++-- doc/DEV.md | 8 +++++--- doc/FORMATS.md | 9 +++++---- src/base/decode.c | 2 +- src/coding/coding.h | 24 ++++++++++++------------ src/vgmstream.h | 8 ++++---- 8 files changed, 38 insertions(+), 28 deletions(-) diff --git a/.github/formats-info.py b/.github/formats-info.py index 1cadab65..a5ffdfa9 100644 --- a/.github/formats-info.py +++ b/.github/formats-info.py @@ -13,7 +13,7 @@ import glob, os, re META_SRC = '../**/meta/*.c' FORMAT_SRC = '../**/formats.c' -SORT_SRC = '../**/vgmstream.c' +SORT_SRC = '../**/vgmstream_init.c' FORMAT_DOC = '../**/FORMATS.md' DUMP_DOC = 'formats-info.md' IS_SORT = True #sorts metas lines based on LIST_SRC diff --git a/cli/Makefile b/cli/Makefile index 75ec3745..fa6d773f 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -22,6 +22,12 @@ ifeq ($(TARGET_OS),Windows_NT) LIBAO_INC = -I$(LIBAO_IPATH) LIBAO_LIB = -L$(LIBAO_LPATH) -lao + + # strip needs full name + OUTPUT_CLI = vgmstream-cli.exe + OUTPUT_123 = vgmstream123.exe + OUTPUT_API = api_example.exe + else #todo move to subfolders and remove CFLAGS += -I../ext_includes @@ -50,7 +56,7 @@ vgmstream123: libvgmstream.a $(TARGET_EXT_LIBS) api_example: libvgmstream.a $(TARGET_EXT_LIBS) $(CC) $(CFLAGS) api_example.c $(LDFLAGS) -o $(OUTPUT_API) - $(STRIP) api_example + $(STRIP) $(OUTPUT_API) libvgmstream.a: $(MAKE) -C ../src $@ diff --git a/cli/vgmstream_cli.c b/cli/vgmstream_cli.c index 524a7e51..ca6c71dd 100644 --- a/cli/vgmstream_cli.c +++ b/cli/vgmstream_cli.c @@ -4,8 +4,6 @@ #define POSIXLY_CORRECT #include -#include "vgmstream_cli.h" -#include "wav_utils.h" #ifdef WIN32 #include @@ -19,6 +17,9 @@ #endif +#include "vgmstream_cli.h" +#include "wav_utils.h" + #include "../version.h" #ifndef VGMSTREAM_VERSION #define VGMSTREAM_VERSION "unknown version " __DATE__ diff --git a/doc/DEV.md b/doc/DEV.md index f330ff3e..c54b84a1 100644 --- a/doc/DEV.md +++ b/doc/DEV.md @@ -10,16 +10,17 @@ There are no hard coding rules but for consistency one should follow the style u - 4 spaces instead of tabs - `\n` breaks (LF, Linux style), instead of `\r\n` (CRLF, Windows style) - `underscore_and_lowercase_names` instead of `CamelCase` -- `/* C89 comments */` for general comments, `//C99 comments` for special comments (like disabling code but leaving it there for visibility) +- `/* C89 comments */` for general comments, `//C99 comments` for other comments - brackets starting in the same line - ex. `if (..) { LF ... LF }` - line length ~100, more is ok for 'noise code' (uninteresting calcs or function defs) - offsets/sizes in hex, counts/numbers in decimal - test functions may return 1=ok, 0=ko for simplicity - `free(ptr)` no need to NULL-check per standard, `close_stuff(ptr)` should follow when possible -- `lowercase_helper_structs_t`, `UPPERCASE_MAIN_STRUCTS` +- `lowercase_helper_structs_t`, `UPPERCASE_INTERNAL_STRUCTS` - spaces in calcs/ifs/etc may be added as desired for clarity - ex. `if (simple_check)` or `if ( complex_and_important_stuff(weird + weird) )` + - though generally you should split steps if readibility is impaired - `goto` are used to abort and reach "fail" sections (typical C cleanup style), beware vars should be defined first - pointer definitions should keep the `*` together for consistency - ex. `VGMSTREAM* init_x() { ... }` `STREAMFILE* sf = ...` @@ -79,7 +80,8 @@ Some of the code can be inefficient or duplicated at places, but it isn't that m ./ext_includes/ external includes for compiling ./ext_libs/ external libs/DLLs for linking ./fb2k/ foobar2000 plugin -./src/ main vgmstream code +./src/ initial vgmstream code +./src/base/ core vgmstream features ./src/coding/ format data decoders ./src/layout/ format data demuxers ./src/meta/ format header parsers diff --git a/doc/FORMATS.md b/doc/FORMATS.md index f5882f57..be5cddeb 100644 --- a/doc/FORMATS.md +++ b/doc/FORMATS.md @@ -830,9 +830,9 @@ different internally (encrypted, different versions, etc) and not always can be - Sony MSF header [*MSF*] - *msf*: `.msf .msa .at3 .mp3 .str .snd` - Codecs: PCM16BE PCM16LE PSX ATRAC3 FFmpeg(various) -- **ps3_past.c** - - SNDP header [*PS3_PAST*] - - *ps3_past*: `.past` +- **sndp.c** + - Premium Agency SNDP header [*SNDP*] + - *sndp*: `.past` - Codecs: PCM16LE - **sgxd.c** - Sony SGXD header [*SGXD*] @@ -1262,7 +1262,7 @@ different internally (encrypted, different versions, etc) and not always can be - *smc_smh*: `.smc + .smh` - Codecs: PSX - **ppst.c** - - Parappa PPST header [*PPST*] + - epics PPST header [*PPST*] - *ppst*: `.sng` - Subfiles: *riff* - **ubi_bao.c** @@ -2033,6 +2033,7 @@ are used in few games. - Paradigm MC3 ADPCM - Ocean DSA ADPCM - lsf ADPCM + - Ongakukan ADPCM - ITU-T G.721 - CompressWave (CWav) Huffman ADPCM - Perceptual/transform-based diff --git a/src/base/decode.c b/src/base/decode.c index d600ebaf..b6ed6fab 100644 --- a/src/base/decode.c +++ b/src/base/decode.c @@ -1679,7 +1679,7 @@ int decode_do_loop(VGMSTREAM* vgmstream) { vgmstream->loop_next_block_offset = vgmstream->next_block_offset; //vgmstream->lstate = vgmstream->pstate; /* play state is applied over loops */ - vgmstream->hit_loop = 1; /* info that loop is now ready to use */ + vgmstream->hit_loop = true; /* info that loop is now ready to use */ } return 0; /* not looped */ diff --git a/src/coding/coding.h b/src/coding/coding.h index edbf6256..c98a1a63 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -13,7 +13,7 @@ void adx_next_key(VGMSTREAMCHANNEL* stream); /* g721_decoder */ -void decode_g721(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_g721(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void g72x_init_state(struct g72x_state* state_ptr); @@ -126,14 +126,14 @@ size_t xa_bytes_to_samples(size_t bytes, int channels, int is_blocked, int is_fo /* ea_xa_decoder */ -void decode_ea_xa(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo); -void decode_ea_xa_v2(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); -void decode_maxis_xa(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); +void decode_ea_xa(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel, int is_stereo); +void decode_ea_xa_v2(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_maxis_xa(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); int32_t ea_xa_bytes_to_samples(size_t bytes, int channels); /* ea_xas_decoder */ -void decode_ea_xas_v0(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_ea_xas_v0(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_ea_xas_v1(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); @@ -145,7 +145,7 @@ void decode_cbd2_int(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspac /* ws_decoder */ -void decode_ws(VGMSTREAM* vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_ws(VGMSTREAM* vgmstream, int channel, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); /* acm_decoder */ @@ -197,11 +197,11 @@ void decode_nds_procyon(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channels /* l5_555_decoder */ -void decode_l5_555(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_l5_555(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); /* sassc_decoder */ -void decode_sassc(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_sassc(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); /* lsf_decode */ @@ -217,7 +217,7 @@ void decode_mta2(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, /* mc3_decoder */ -void decode_mc3(VGMSTREAM* vgmstream, VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); +void decode_mc3(VGMSTREAM* vgmstream, VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do, int channel); /* fadpcm_decoder */ @@ -243,7 +243,7 @@ int32_t tantalus_bytes_to_samples(size_t bytes, int channels); /* derf_decoder */ -void decode_derf(VGMSTREAMCHANNEL* stream, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_derf(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); /* wady_decoder */ void decode_wady(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); @@ -322,7 +322,7 @@ typedef struct ea_mt_codec_data ea_mt_codec_data; ea_mt_codec_data* init_ea_mt(int channels, int pcm_blocks); ea_mt_codec_data* init_ea_mt_loops(int channels, int pcm_blocks, int loop_sample, off_t* loop_offsets); ea_mt_codec_data* init_ea_mt_cbx(int channels); -void decode_ea_mt(VGMSTREAM* vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel); +void decode_ea_mt(VGMSTREAM* vgmstream, sample_t* outbuf, int channelspacing, int32_t samples_to_do, int channel); void reset_ea_mt(VGMSTREAM* vgmstream); void flush_ea_mt(VGMSTREAM* vgmstream); void seek_ea_mt(VGMSTREAM* vgmstream, int32_t num_sample); @@ -560,7 +560,7 @@ void free_g719(g719_codec_data* data, int channels); #if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) /* mp4_aac_decoder */ -void decode_mp4_aac(mp4_aac_codec_data* data, sample * outbuf, int32_t samples_to_do, int channels); +void decode_mp4_aac(mp4_aac_codec_data* data, sample_t* outbuf, int32_t samples_to_do, int channels); void reset_mp4_aac(VGMSTREAM* vgmstream); void seek_mp4_aac(VGMSTREAM* vgmstream, int32_t num_sample); void free_mp4_aac(mp4_aac_codec_data* data); diff --git a/src/vgmstream.h b/src/vgmstream.h index 3377b444..4e86fc2c 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -164,7 +164,7 @@ typedef struct { layout_t layout_type; /* type of layout */ meta_t meta_type; /* type of metadata */ - /* loopin config */ + /* loop config */ int loop_flag; /* is this stream looped? */ int32_t loop_start_sample; /* first sample of the loop (included in the loop) */ int32_t loop_end_sample; /* last sample of the loop (not included in the loop) */ @@ -186,7 +186,7 @@ typedef struct { uint32_t channel_layout; /* order: FL FR FC LFE BL BR FLC FRC BC SL SR etc (WAVEFORMATEX flags where FL=lowest bit set) */ /* other config */ - int allow_dual_stereo; /* search for dual stereo (file_L.ext + file_R.ext = single stereo file) */ + bool allow_dual_stereo; /* search for dual stereo (file_L.ext + file_R.ext = single stereo file) */ /* layout/block state */ @@ -205,7 +205,7 @@ typedef struct { size_t loop_block_size; /* saved from current_block_size */ int32_t loop_block_samples; /* saved from current_block_samples */ off_t loop_next_block_offset; /* saved from next_block_offset */ - int hit_loop; /* save config when loop is hit, but first time only */ + bool hit_loop; /* save config when loop is hit, but first time only */ /* decoder config/state */ @@ -233,7 +233,7 @@ typedef struct { /* play config/state */ - int config_enabled; /* config can be used */ + bool config_enabled; /* config can be used */ play_config_t config; /* player config (applied over decoding) */ play_state_t pstate; /* player state (applied over decoding) */ int loop_count; /* counter of complete loops (1=looped once) */