From caa08029b9292da1a621401b49e73d7a7f479423 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 19 Nov 2021 22:50:16 +1000 Subject: [PATCH] Move mp3 code into its own folder --- Makefile | 10 +-- ld/libfiles.ntsc-beta.inc | 16 ++-- ld/libfiles.ntsc-final.inc | 16 ++-- ld/libfiles.pal-final.inc | 16 ++-- src/include/lib/lib_3e8c0.h | 10 +-- src/include/lib/lib_43dd0.h | 13 --- src/include/lib/lib_45ed0.h | 9 -- src/include/lib/lib_461c0.h | 13 --- src/include/lib/lib_46650.h | 9 -- src/include/lib/lib_47550.h | 9 -- src/include/lib/lib_47d20.h | 10 --- src/include/types.h | 101 ---------------------- src/lib/lib_39c80.c | 1 - src/lib/mp3.c | 8 +- src/lib/{lib_3f8a0.c => mp3/decoder.c} | 114 ++++++++++++------------- src/lib/mp3/internal.h | 26 ++++++ src/lib/{ => mp3}/lib_45ed0.c | 6 +- src/lib/{ => mp3}/lib_46650.s | 0 src/lib/{ => mp3}/lib_47550.s | 0 src/lib/{ => mp3}/lib_47d20.c | 5 +- src/lib/{ => mp3}/lib_47ef0.c | 5 +- src/lib/{lib_43dd0.c => mp3/main.c} | 52 ++++++----- src/lib/mp3/mp3.h | 103 ++++++++++++++++++++++ src/lib/{lib_461c0.s => mp3/util.s} | 20 ++--- 24 files changed, 259 insertions(+), 313 deletions(-) delete mode 100644 src/include/lib/lib_43dd0.h delete mode 100644 src/include/lib/lib_45ed0.h delete mode 100644 src/include/lib/lib_461c0.h delete mode 100644 src/include/lib/lib_46650.h delete mode 100644 src/include/lib/lib_47550.h delete mode 100644 src/include/lib/lib_47d20.h rename src/lib/{lib_3f8a0.c => mp3/decoder.c} (96%) create mode 100644 src/lib/mp3/internal.h rename src/lib/{ => mp3}/lib_45ed0.c (85%) rename src/lib/{ => mp3}/lib_46650.s (100%) rename src/lib/{ => mp3}/lib_47550.s (100%) rename src/lib/{ => mp3}/lib_47d20.c (89%) rename src/lib/{ => mp3}/lib_47ef0.c (86%) rename src/lib/{lib_43dd0.c => mp3/main.c} (71%) create mode 100644 src/lib/mp3/mp3.h rename src/lib/{lib_461c0.s => mp3/util.s} (96%) diff --git a/Makefile b/Makefile index 6f9faa62d..dc9bdec72 100644 --- a/Makefile +++ b/Makefile @@ -108,15 +108,11 @@ MIPS3_C_FILES := \ G_C_FILES := \ $(shell find src/lib/ultra/audio -name '*.c') \ $(shell find src/lib/naudio -name '*.c') \ + $(shell find src/lib/mp3 -name '*.c') \ src/lib/lib_2fc60.c \ src/lib/lib_317f0.c \ src/lib/lib_39c80.c \ src/lib/lib_3e3e0.c \ - src/lib/lib_3f8a0.c \ - src/lib/lib_43dd0.c \ - src/lib/lib_45ed0.c \ - src/lib/lib_47d20.c \ - src/lib/lib_47ef0.c \ src/lib/mp3.c \ src/lib/speaker.c @@ -180,9 +176,9 @@ O3_C_FILES := \ IDO71_C_FILES := \ $(shell find src/lib/ultra/audio -name '*.c') \ $(shell find src/lib/naudio -name '*.c') \ + $(shell find src/lib/mp3 -name '*.c') \ src/lib/lib_2fc60.c \ - src/lib/lib_39c80.c \ - src/lib/lib_3f8a0.c + src/lib/lib_39c80.c LOOPUNROLL_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(LOOPUNROLL_C_FILES)) MIPS3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(MIPS3_C_FILES)) diff --git a/ld/libfiles.ntsc-beta.inc b/ld/libfiles.ntsc-beta.inc index 9f5e483eb..917c797aa 100644 --- a/ld/libfiles.ntsc-beta.inc +++ b/ld/libfiles.ntsc-beta.inc @@ -108,21 +108,21 @@ build/ROMID/lib/naudio/n_synfilter11.o (section); \ build/ROMID/lib/ultra/audio/cseq.o (section); \ build/ROMID/lib/naudio/n_env.o (section); \ - build/ROMID/lib/lib_3f8a0.o (section); \ - build/ROMID/lib/lib_43dd0.o (section); \ + build/ROMID/lib/mp3/decoder.o (section); \ + build/ROMID/lib/mp3/main.o (section); \ build/ROMID/lib/naudio/n_cspsendmidi.o (section); \ build/ROMID/lib/naudio/n_auxbus.o (section); \ build/ROMID/lib/naudio/n_mainbus.o (section); \ build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/naudio/n_load.o (section); \ build/ROMID/lib/naudio/n_resample2.o (section); \ - build/ROMID/lib/lib_45ed0.o (section); \ - build/ROMID/lib/lib_461c0.o (section); \ - build/ROMID/lib/lib_46650.o (section); \ - build/ROMID/lib/lib_47550.o (section); \ + build/ROMID/lib/mp3/lib_45ed0.o (section); \ + build/ROMID/lib/mp3/util.o (section); \ + build/ROMID/lib/mp3/lib_46650.o (section); \ + build/ROMID/lib/mp3/lib_47550.o (section); \ build/ROMID/lib/naudio/n_resample.o (section); \ - build/ROMID/lib/lib_47d20.o (section); \ - build/ROMID/lib/lib_47ef0.o (section); \ + build/ROMID/lib/mp3/lib_47d20.o (section); \ + build/ROMID/lib/mp3/lib_47ef0.o (section); \ build/ROMID/lib/ultra/io/vitbl.o (section); \ build/ROMID/lib/ultra/os/writebackdcacheall.o (section); \ build/ROMID/lib/ultra/os/invalicache.o (section); \ diff --git a/ld/libfiles.ntsc-final.inc b/ld/libfiles.ntsc-final.inc index 44cbb2dc0..422dd2b97 100644 --- a/ld/libfiles.ntsc-final.inc +++ b/ld/libfiles.ntsc-final.inc @@ -105,21 +105,21 @@ build/ROMID/lib/naudio/n_synfilter11.o (section); \ build/ROMID/lib/ultra/audio/cseq.o (section); \ build/ROMID/lib/naudio/n_env.o (section); \ - build/ROMID/lib/lib_3f8a0.o (section); \ - build/ROMID/lib/lib_43dd0.o (section); \ + build/ROMID/lib/mp3/decoder.o (section); \ + build/ROMID/lib/mp3/main.o (section); \ build/ROMID/lib/naudio/n_cspsendmidi.o (section); \ build/ROMID/lib/naudio/n_auxbus.o (section); \ build/ROMID/lib/naudio/n_mainbus.o (section); \ build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/naudio/n_load.o (section); \ build/ROMID/lib/naudio/n_resample2.o (section); \ - build/ROMID/lib/lib_45ed0.o (section); \ - build/ROMID/lib/lib_461c0.o (section); \ - build/ROMID/lib/lib_46650.o (section); \ - build/ROMID/lib/lib_47550.o (section); \ + build/ROMID/lib/mp3/lib_45ed0.o (section); \ + build/ROMID/lib/mp3/util.o (section); \ + build/ROMID/lib/mp3/lib_46650.o (section); \ + build/ROMID/lib/mp3/lib_47550.o (section); \ build/ROMID/lib/naudio/n_resample.o (section); \ - build/ROMID/lib/lib_47d20.o (section); \ - build/ROMID/lib/lib_47ef0.o (section); \ + build/ROMID/lib/mp3/lib_47d20.o (section); \ + build/ROMID/lib/mp3/lib_47ef0.o (section); \ build/ROMID/lib/ultra/io/vitbl.o (section); \ build/ROMID/lib/ultra/os/writebackdcacheall.o (section); \ build/ROMID/lib/ultra/os/invalicache.o (section); \ diff --git a/ld/libfiles.pal-final.inc b/ld/libfiles.pal-final.inc index a342d094d..7ff48dc43 100644 --- a/ld/libfiles.pal-final.inc +++ b/ld/libfiles.pal-final.inc @@ -105,21 +105,21 @@ build/ROMID/lib/naudio/n_synfilter11.o (section); \ build/ROMID/lib/ultra/audio/cseq.o (section); \ build/ROMID/lib/naudio/n_env.o (section); \ - build/ROMID/lib/lib_3f8a0.o (section); \ - build/ROMID/lib/lib_43dd0.o (section); \ + build/ROMID/lib/mp3/decoder.o (section); \ + build/ROMID/lib/mp3/main.o (section); \ build/ROMID/lib/naudio/n_cspsendmidi.o (section); \ build/ROMID/lib/naudio/n_auxbus.o (section); \ build/ROMID/lib/naudio/n_mainbus.o (section); \ build/ROMID/lib/naudio/n_synsetpriority.o (section); \ build/ROMID/lib/naudio/n_load.o (section); \ build/ROMID/lib/naudio/n_resample2.o (section); \ - build/ROMID/lib/lib_45ed0.o (section); \ - build/ROMID/lib/lib_461c0.o (section); \ - build/ROMID/lib/lib_46650.o (section); \ - build/ROMID/lib/lib_47550.o (section); \ + build/ROMID/lib/mp3/lib_45ed0.o (section); \ + build/ROMID/lib/mp3/util.o (section); \ + build/ROMID/lib/mp3/lib_46650.o (section); \ + build/ROMID/lib/mp3/lib_47550.o (section); \ build/ROMID/lib/naudio/n_resample.o (section); \ - build/ROMID/lib/lib_47d20.o (section); \ - build/ROMID/lib/lib_47ef0.o (section); \ + build/ROMID/lib/mp3/lib_47d20.o (section); \ + build/ROMID/lib/mp3/lib_47ef0.o (section); \ build/ROMID/lib/ultra/io/vitbl.o (section); \ build/ROMID/lib/ultra/os/writebackdcacheall.o (section); \ build/ROMID/lib/ultra/os/invalicache.o (section); \ diff --git a/src/include/lib/lib_3e8c0.h b/src/include/lib/lib_3e8c0.h index 1c9a5e2a4..8b0ef8f9e 100644 --- a/src/include/lib/lib_3e8c0.h +++ b/src/include/lib/lib_3e8c0.h @@ -4,12 +4,12 @@ #include "data.h" #include "types.h" -bool func0003f8a0(void); -bool func00040164(struct asistream *stream, u32 gr, u32 ch); +bool mp3decInit(void); +bool mp3dec00040164(struct asistream *stream, u32 gr, u32 ch); bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch); -bool func00041600(struct asistream *stream, u32 gr, u32 ch); -bool func00042238(struct asistream *stream, u32 gr, u32 ch); -bool func000427d8(struct asistream *stream, u32 gr); +bool mp3dec00041600(struct asistream *stream, u32 gr, u32 ch); +bool mp3dec00042238(struct asistream *stream, u32 gr, u32 ch); +bool mp3dec000427d8(struct asistream *stream, u32 gr); bool mp3decReduceAliases(struct asistream *stream, u32 gr, u32 ch); bool mp3decSetSideInfo(struct asistream *stream); bool mp3decDecodeFrame(struct asistream *stream); diff --git a/src/include/lib/lib_43dd0.h b/src/include/lib/lib_43dd0.h deleted file mode 100644 index efbebc2a0..000000000 --- a/src/include/lib/lib_43dd0.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _IN_LIB_LIB_43DD0_H -#define _IN_LIB_LIB_43DD0_H -#include -#include "data.h" -#include "types.h" - -s32 func00043dd0(struct asistream *stream); -bool func00043ef8(struct asistream *stream, s32 arg1); -u32 func00044404(void); -struct asistream *func00044460(s32 arg0, void *arg1, s32 arg2); -s32 func0004453c(struct asistream *stream, struct mp3thing **arg1, s32 *arg2); - -#endif diff --git a/src/include/lib/lib_45ed0.h b/src/include/lib/lib_45ed0.h deleted file mode 100644 index 5981af429..000000000 --- a/src/include/lib/lib_45ed0.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _IN_LIB_LIB_45ED0_H -#define _IN_LIB_LIB_45ED0_H -#include -#include "data.h" -#include "types.h" - -f32 func00045ed0(f32 arg0, f32 arg1); - -#endif diff --git a/src/include/lib/lib_461c0.h b/src/include/lib/lib_461c0.h deleted file mode 100644 index d42253d94..000000000 --- a/src/include/lib/lib_461c0.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _IN_LIB_LIB_461C0_H -#define _IN_LIB_LIB_461C0_H -#include -#include "data.h" -#include "types.h" - -u32 func000461c0(void); -u32 func00046290(void); -s32 mp3decGetBits(u8 *buffer, s32 *count, s32 numbits); -s32 func000462f8(u8 *arg0, s32 *arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s16 **arg6, u8 **arg7); -s32 func000464a8(u8 *arg0, s32 *arg1, s32 arg2, s32 arg3, s32 arg4, s16 **arg5, u8 **arg6); - -#endif diff --git a/src/include/lib/lib_46650.h b/src/include/lib/lib_46650.h deleted file mode 100644 index 33ff9eb99..000000000 --- a/src/include/lib/lib_46650.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _IN_LIB_LIB_46650_H -#define _IN_LIB_LIB_46650_H -#include -#include "data.h" -#include "types.h" - -void func00046650(struct asistream_4f64 *arg0, s32 arg1, struct asistream_4f64 *arg2, struct asistream_4f64 *arg3, void *arg4); - -#endif diff --git a/src/include/lib/lib_47550.h b/src/include/lib/lib_47550.h deleted file mode 100644 index 8145fe5a0..000000000 --- a/src/include/lib/lib_47550.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _IN_LIB_LIB_47550_H -#define _IN_LIB_LIB_47550_H -#include -#include "data.h" -#include "types.h" - -void func00047550(struct asistream_4f64 *arg0, s32 arg1, struct asistream_4f64 *arg2, struct asistream_4f64 *arg3); - -#endif diff --git a/src/include/lib/lib_47d20.h b/src/include/lib/lib_47d20.h deleted file mode 100644 index 9a0adc825..000000000 --- a/src/include/lib/lib_47d20.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _IN_LIB_LIB_47D20_H -#define _IN_LIB_LIB_47D20_H -#include -#include "data.h" -#include "types.h" - -f32 func00047d20(f32 arg0); -f32 func00047ef0(f32 arg0); - -#endif diff --git a/src/include/types.h b/src/include/types.h index b73fe1828..52e65da14 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -7344,105 +7344,4 @@ struct var8007f8dc { /*0x100*/ u32 unk100; }; -struct asistream_scalefac { - /*0x3d08*/ u32 l[22]; - /*0x3d60*/ u32 unk3d60; - /*0x3d64*/ u32 s[3][13]; -}; - -struct asistream_4f64 { - f32 unk00[18]; -}; - -struct asistream { - /*0x0000*/ s32 unk00; - /*0x0004*/ s32 (*unk04)(s32 arg0, void *arg1, s32 arg2, s32 arg3); - /*0x0008*/ s32 unk08; - /*0x000c*/ s32 unk0c; - /*0x0010*/ s32 unk10; - /*0x0014*/ s32 unk14; - /*0x0018*/ s32 unk18; - /*0x2000*/ u8 unk1c[0x2000]; - /*0x201c*/ s32 unk201c; - /*0x2020*/ s32 unk2020; - /*0x2024*/ u8 buffer[0x40]; - /*0x2064*/ s32 count; - /*0x2068*/ u32 unk2068; - /*0x206c*/ u32 unk206c; - /*0x2070*/ struct mp3thing unk2070[6]; - /*0x3ba0*/ s32 unk3ba0; - /*0x3ba4*/ u32 version; - /*0x3ba8*/ u32 layer; - /*0x3bac*/ u32 crctype; - /*0x3bb0*/ u32 bitrateindex; - /*0x3bb4*/ u32 samplerateindex; - /*0x3bb8*/ u32 haspadding; - /*0x3bbc*/ u32 privatebit; - /*0x3bc0*/ u32 channelmode; - /*0x3bc4*/ u32 unk3bc4; - /*0x3bc8*/ u32 unk3bc8; - /*0x3bcc*/ u32 unk3bcc; - /*0x3bd0*/ u32 unk3bd0; - /*0x3bd4*/ bool doneinitial; - /*0x3bd8*/ u32 initialversion; - /*0x3bdc*/ u32 initiallayer; - /*0x3be0*/ u32 initialcrctype; - /*0x3be4*/ u32 initialsamplerateindex; - /*0x3be8*/ u32 initialchannelmode; - /*0x3bec*/ u32 unk3bec; - /*0x3bf0*/ u32 unk3bf0; - /*0x3bf4*/ u32 main_data_begin; - /*0x3bf8*/ u32 scfsi[1][32]; - /*0x3c78*/ u32 part2_3_length[2][1]; - /*0x3c80*/ u32 big_value[2][1]; - /*0x3c88*/ s32 global_gain[2][1]; - /*0x3c90*/ u32 scalefac_compress[2][1]; - /*0x3c98*/ u32 window_switching[2][1]; - /*0x3ca0*/ u32 block_type[2][1]; - /*0x3ca8*/ u32 mixed_block_flag[2][1]; - /*0x3cb0*/ u32 table_select[2][1][3]; - /*0x3cc8*/ u32 subblock_gain[2][1][3]; - /*0x3ce0*/ u32 region0_count[2][1]; - /*0x3ce8*/ u32 region1_count[2][1]; - /*0x3cf0*/ u32 preflag[2][1]; - /*0x3cf8*/ u32 scalefac_scale[2][1]; - /*0x3d00*/ u32 count1table_select[2][1]; - struct asistream_scalefac scalefac[2][1]; - /*0x3ef8*/ u32 unk3ef8; - /*0x3efc*/ u32 unk3efc[6]; - /*0x3f14*/ u32 unk3f14[26]; - /*0x3f7c*/ s32 unk3f7c; - /*0x3f80*/ s32 unk3f80; - /*0x3f84*/ s32 unk3f84; - /*0x3f88*/ s32 unk3f88; - /*0x3f8c*/ s32 numchannels; - /*0x3f90*/ s32 numgranules; - /*0x3f94*/ s16 unk3f94[1][578]; - /*0x4418*/ u8 unk4418[1][578]; - /*0x465c*/ s32 unk465c[1]; - /*0x4660*/ s32 unk4660[1]; - /*0x4664*/ struct asistream_4f64 unk4664[1][32]; - /*0x4f64*/ struct asistream_4f64 unk4f64[2][32]; - /*0x6164*/ u8 unk6164[0x900]; - /*0x6a64*/ struct asistream_4f64 unk6a64[2][32]; - /*0x7c64*/ u8 unk7c64[0x810]; - /*0x8474*/ s32 unk8474; - /*0x8478*/ bool (*unk8478)(struct asistream *stream); - /*0x847c*/ bool (*unk847c)(struct asistream *stream); -}; - -struct mp3decfourbytes { - u8 bytes[2]; - s8 unk02; - s8 unk03; -}; - -struct mp3decthing { - u8 unk00; - u8 unk01; - u8 unk02; - u8 unk03; - u32 unk04; -}; - #endif diff --git a/src/lib/lib_39c80.c b/src/lib/lib_39c80.c index ccf4287cb..8e1859b51 100644 --- a/src/lib/lib_39c80.c +++ b/src/lib/lib_39c80.c @@ -2,7 +2,6 @@ #include #include "constants.h" #include "bss.h" -#include "lib/lib_43dd0.h" #include "data.h" #include "types.h" diff --git a/src/lib/mp3.c b/src/lib/mp3.c index 65eae9e2d..ed83f7b8a 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -2,8 +2,8 @@ #include #include "naudio/n_abi.h" #include "bss.h" -#include "lib/lib_43dd0.h" #include "lib/mp3.h" +#include "mp3/mp3.h" #include "types.h" /** @@ -47,7 +47,7 @@ void mp3Init(ALHeap *heap) var8009c640 = alHeapAlloc(heap, 10500 * sizeof(struct mp3decfourbytes), 1); var8009c644 = alHeapAlloc(heap, 8192 * sizeof(f32), 1); - func00044404(); + mp3mainInit(); g_Mp3Vars.var8009c398 = alHeapAlloc(heap, 1, 0x50); *(u8 **)((u32)&g_Mp3Vars+0x44) = alHeapAlloc(heap, 1, 0x440); @@ -185,7 +185,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) func00038cac(); if (g_Mp3Vars.var8009c3f0 == 0) { - g_Mp3Vars.var8009c394 = func00044460(0, g_Mp3Vars.var8009c3dc, g_Mp3Vars.var8009c3c0); + g_Mp3Vars.var8009c394 = mp3main00044460(0, g_Mp3Vars.var8009c3dc, g_Mp3Vars.var8009c3c0); if (g_Mp3Vars.var8009c394 == NULL) { g_Mp3Vars.var8009c3e0 = 0; @@ -227,7 +227,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) g_Mp3Vars.var8009c3d0 = 0; g_Mp3Vars.var8009c3cc = 0; - if (func0004453c(g_Mp3Vars.var8009c394, &sp58, &sp5c)) { + if (mp3main0004453c(g_Mp3Vars.var8009c394, &sp58, &sp5c)) { g_Mp3Vars.var8009c3c8 = sp58; for (i = 0; i < sp5c; i++) { diff --git a/src/lib/lib_3f8a0.c b/src/lib/mp3/decoder.c similarity index 96% rename from src/lib/lib_3f8a0.c rename to src/lib/mp3/decoder.c index 0a12e69ac..fd0094c98 100644 --- a/src/lib/lib_3f8a0.c +++ b/src/lib/mp3/decoder.c @@ -1,14 +1,6 @@ #include -#include "constants.h" -#include "lib/lib_3e8c0.h" -#include "lib/lib_43dd0.h" -#include "lib/lib_45ed0.h" -#include "lib/lib_461c0.h" -#include "lib/lib_46650.h" -#include "lib/lib_47550.h" -#include "lib/libc/ll.h" -#include "data.h" -#include "types.h" +#include "internal.h" +#include "mp3.h" #define CHANNELMODE_STEREO 0 #define CHANNELMODE_JOINTSTEREO 1 @@ -18,6 +10,14 @@ #define VERSION_2 0x0 #define VERSION_1 0x1 +struct mp3decthing { + u8 unk00; + u8 unk01; + u8 unk02; + u8 unk03; + u32 unk04; +}; + extern const struct mp3decthing var70054b40[]; f32 sine_block[4][36]; @@ -2078,7 +2078,7 @@ extern struct mp3decfourbytes *var8009c650[]; extern f32 *var8009c6d8; extern f32 *var8009c6dc; -bool func0003f8a0(void) +bool mp3decInit(void) { s32 i; s32 sp268; @@ -2242,7 +2242,7 @@ bool func0003f8a0(void) return true; } -bool func00040164(struct asistream *stream, u32 gr, u32 ch) +bool mp3dec00040164(struct asistream *stream, u32 gr, u32 ch) { s32 sp1bc; s32 sp1b8; @@ -2393,7 +2393,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) for (sfb = 0; sfb < 8; sfb++) { stream->scalefac[gr][ch].l[sfb] = var70057b7c[0][stream->scalefac_compress[gr][ch]] - ? mp3decGetBits(stream->unk1c, &stream->unk2020, var70057b7c[0][stream->scalefac_compress[gr][ch]]) + ? mp3utilGetBits(stream->unk1c, &stream->unk2020, var70057b7c[0][stream->scalefac_compress[gr][ch]]) : 0; } @@ -2401,7 +2401,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) for (window = 0; window < 3; window++) { stream->scalefac[gr][ch].s[window][sfb] = var70057b7c[0][stream->scalefac_compress[gr][ch]] - ? mp3decGetBits(stream->unk1c, &stream->unk2020, var70057b7c[0][stream->scalefac_compress[gr][ch]]) + ? mp3utilGetBits(stream->unk1c, &stream->unk2020, var70057b7c[0][stream->scalefac_compress[gr][ch]]) : 0; } } @@ -2410,7 +2410,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) for (window = 0; window < 3; window++) { stream->scalefac[gr][ch].s[window][sfb] = var70057b7c[1][stream->scalefac_compress[gr][ch]] - ? mp3decGetBits(stream->unk1c, &stream->unk2020, var70057b7c[1][stream->scalefac_compress[gr][ch]]) + ? mp3utilGetBits(stream->unk1c, &stream->unk2020, var70057b7c[1][stream->scalefac_compress[gr][ch]]) : 0; } } @@ -2420,7 +2420,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) for (window = 0; window < 3; window++) { stream->scalefac[gr][ch].s[window][sfb] = var70057b7c[i][stream->scalefac_compress[gr][ch]] - ? mp3decGetBits(stream->unk1c, &stream->unk2020, var70057b7c[i][stream->scalefac_compress[gr][ch]]) + ? mp3utilGetBits(stream->unk1c, &stream->unk2020, var70057b7c[i][stream->scalefac_compress[gr][ch]]) : 0; } } @@ -2436,7 +2436,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) for (sfb = var70057b74[i]; sfb < var70057b74[i + 1]; sfb++) { stream->scalefac[gr][ch].l[sfb] = var70057b7c[i < 2 ? 0 : 1][stream->scalefac_compress[gr][ch]] - ? mp3decGetBits(stream->unk1c, &stream->unk2020, var70057b7c[i < 2 ? 0 : 1][stream->scalefac_compress[gr][ch]]) + ? mp3utilGetBits(stream->unk1c, &stream->unk2020, var70057b7c[i < 2 ? 0 : 1][stream->scalefac_compress[gr][ch]]) : 0; } } else { @@ -2452,7 +2452,7 @@ bool mp3decUnpackScaleFac(struct asistream *stream, u32 gr, u32 ch) return true; } -bool func00041600(struct asistream *stream, u32 gr, u32 ch) +bool mp3dec00041600(struct asistream *stream, u32 gr, u32 ch) { const s32 sp70[2][3][3][4] = { { @@ -2560,7 +2560,7 @@ bool func00041600(struct asistream *stream, u32 gr, u32 ch) sp1c = (1 << sp20) - 1; for (j = 0; j < sp28[i]; j++) { - stream->scalefac[0][ch].l[sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].l[sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; if (ch != 0) { stream->unk3efc[sfb] = sp1c; @@ -2576,9 +2576,9 @@ bool func00041600(struct asistream *stream, u32 gr, u32 ch) sp1c = (1 << sp20) - 1; for (j = 0; j < sp28[i]; j += 3) { - stream->scalefac[0][ch].s[0][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; - stream->scalefac[0][ch].s[1][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; - stream->scalefac[0][ch].s[2][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[0][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[1][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[2][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; if (ch != 0) { stream->unk3f14[sfb] = sp1c; @@ -2592,7 +2592,7 @@ bool func00041600(struct asistream *stream, u32 gr, u32 ch) sp1c = (1 << sp20) - 1; for (j = 0; j < 6; j++) { - stream->scalefac[0][ch].l[sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].l[sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; if (ch != 0) { stream->unk3efc[sfb] = sp1c; @@ -2609,9 +2609,9 @@ bool func00041600(struct asistream *stream, u32 gr, u32 ch) sp1c = (1 << sp20) - 1; for (j = 0; j < sp28[i]; j += 3) { - stream->scalefac[0][ch].s[0][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; - stream->scalefac[0][ch].s[1][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; - stream->scalefac[0][ch].s[2][sfb] = sp20 ? mp3decGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[0][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[1][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; + stream->scalefac[0][ch].s[2][sfb] = sp20 ? mp3utilGetBits(stream->unk1c, &stream->unk2020, sp20) : 0; if (ch != 0) { stream->unk3f14[sfb] = sp1c; @@ -2626,7 +2626,7 @@ bool func00041600(struct asistream *stream, u32 gr, u32 ch) return true; } -bool func00042238(struct asistream *stream, u32 gr, u32 ch) +bool mp3dec00042238(struct asistream *stream, u32 gr, u32 ch) { s32 sp64 = stream->unk2020; s32 sp60; @@ -2646,7 +2646,7 @@ bool func00042238(struct asistream *stream, u32 gr, u32 ch) if (stream->version != VERSION_2) { mp3decUnpackScaleFac(stream, gr, ch); } else { - func00041600(stream, gr, ch); + mp3dec00041600(stream, gr, ch); } sp60 = stream->big_value[gr][ch] * 2; @@ -2698,13 +2698,13 @@ bool func00042238(struct asistream *stream, u32 gr, u32 ch) sp40 += sp2c; sp48 = sp30; } else { - sp48 = func000462f8(stream->unk1c, &stream->unk2020, sp38, sp48, sp34, sp30, &sp44, &sp40); + sp48 = mp3util000462f8(stream->unk1c, &stream->unk2020, sp38, sp48, sp34, sp30, &sp44, &sp40); } } sp38 = stream->count1table_select[gr][ch] + 32; sp28 = stream->part2_3_length[gr][ch] + sp64; - sp48 = func000464a8(stream->unk1c, &stream->unk2020, sp38, sp48, sp28, &sp44, &sp40); + sp48 = mp3util000464a8(stream->unk1c, &stream->unk2020, sp38, sp48, sp28, &sp44, &sp40); stream->unk2020 = sp28; if (sp48 > 576) { @@ -2723,7 +2723,7 @@ bool func00042238(struct asistream *stream, u32 gr, u32 ch) return true; } -bool func000427d8(struct asistream *stream, u32 gr) +bool mp3dec000427d8(struct asistream *stream, u32 gr) { const s16 *sp14 = var70057b9c[stream->version][stream->samplerateindex]; f32 *sp10 = stream->unk4f64[0][0].unk00; @@ -2834,24 +2834,24 @@ bool mp3decSetSideInfo(struct asistream *stream) stream->numgranules = stream->version != VERSION_2 ? 2 : 1; if (stream->version != VERSION_2) { - stream->main_data_begin = mp3decGetBits(stream->buffer, &stream->count, 9); + stream->main_data_begin = mp3utilGetBits(stream->buffer, &stream->count, 9); // skip private bits stream->numchannels == 1 - ? mp3decGetBits(stream->buffer, &stream->count, 5) - : mp3decGetBits(stream->buffer, &stream->count, 3); + ? mp3utilGetBits(stream->buffer, &stream->count, 5) + : mp3utilGetBits(stream->buffer, &stream->count, 3); } else { - stream->main_data_begin = mp3decGetBits(stream->buffer, &stream->count, 8); + stream->main_data_begin = mp3utilGetBits(stream->buffer, &stream->count, 8); stream->numchannels == 1 - ? mp3decGetBits(stream->buffer, &stream->count, 1) - : mp3decGetBits(stream->buffer, &stream->count, 2); + ? mp3utilGetBits(stream->buffer, &stream->count, 1) + : mp3utilGetBits(stream->buffer, &stream->count, 2); } if (stream->version != VERSION_2) { for (ch = 0; ch < stream->numchannels; ch++) { for (scfsi_band = 0; scfsi_band < 4; scfsi_band++) { - stream->scfsi[ch][scfsi_band] = mp3decGetBits(stream->buffer, &stream->count, 1); + stream->scfsi[ch][scfsi_band] = mp3utilGetBits(stream->buffer, &stream->count, 1); } } } @@ -2864,43 +2864,43 @@ bool mp3decSetSideInfo(struct asistream *stream) for (gr = 0; gr < stream->numgranules; gr++) { for (ch = 0; ch < stream->numchannels; ch++) { - stream->part2_3_length[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 12); - stream->big_value[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 9); - stream->global_gain[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 8); - stream->scalefac_compress[gr][ch] = sp28 ? mp3decGetBits(stream->buffer, &stream->count, sp28) : 0; - stream->window_switching[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 1); + stream->part2_3_length[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 12); + stream->big_value[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 9); + stream->global_gain[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 8); + stream->scalefac_compress[gr][ch] = sp28 ? mp3utilGetBits(stream->buffer, &stream->count, sp28) : 0; + stream->window_switching[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 1); if (stream->window_switching[gr][ch]) { - stream->block_type[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 2); - stream->mixed_block_flag[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 1); + stream->block_type[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 2); + stream->mixed_block_flag[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 1); for (region = 0; region < 2; region++) { - stream->table_select[gr][ch][region] = mp3decGetBits(stream->buffer, &stream->count, 5); + stream->table_select[gr][ch][region] = mp3utilGetBits(stream->buffer, &stream->count, 5); } stream->table_select[gr][ch][2] = 0; for (window = 0; window < 3; window++) { - stream->subblock_gain[gr][ch][window] = mp3decGetBits(stream->buffer, &stream->count, 3); + stream->subblock_gain[gr][ch][window] = mp3utilGetBits(stream->buffer, &stream->count, 3); } } else { stream->block_type[gr][ch] = 0; stream->mixed_block_flag[gr][ch] = false; for (region = 0; region < 3; region++) { - stream->table_select[gr][ch][region] = mp3decGetBits(stream->buffer, &stream->count, 5); + stream->table_select[gr][ch][region] = mp3utilGetBits(stream->buffer, &stream->count, 5); } - stream->region0_count[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 4); - stream->region1_count[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 3); + stream->region0_count[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 4); + stream->region1_count[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 3); } if (stream->version != VERSION_2) { - stream->preflag[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 1); + stream->preflag[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 1); } - stream->scalefac_scale[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->count1table_select[gr][ch] = mp3decGetBits(stream->buffer, &stream->count, 1); + stream->scalefac_scale[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->count1table_select[gr][ch] = mp3utilGetBits(stream->buffer, &stream->count, 1); } } @@ -2937,7 +2937,7 @@ bool mp3decDecodeFrame(struct asistream *stream) s32 sp20; sp934 = stream->unk2070[stream->unk3ba0].unk00; - sp954 = func00043dd0(stream); + sp954 = mp3main00043dd0(stream); if (sp954 == -1) { return false; @@ -2950,11 +2950,11 @@ bool mp3decDecodeFrame(struct asistream *stream) } for (ch = 0; ch < stream->numchannels; ch++) { - func00042238(stream, gr, ch); - func00040164(stream, gr, ch); + mp3dec00042238(stream, gr, ch); + mp3dec00040164(stream, gr, ch); } - func000427d8(stream, gr); + mp3dec000427d8(stream, gr); if (stream->window_switching[gr][0] != 0 && stream->block_type[gr][0] == 2) { sp948 = 32; diff --git a/src/lib/mp3/internal.h b/src/lib/mp3/internal.h new file mode 100644 index 000000000..7a2d87be1 --- /dev/null +++ b/src/lib/mp3/internal.h @@ -0,0 +1,26 @@ +#ifndef _IN_LIB_MP3_INTERNAL_H +#define _IN_LIB_MP3_INTERNAL_H +#include +#include "mp3.h" + +bool mp3decInit(void); +bool mp3decSetSideInfo(struct asistream *stream); +bool mp3decDecodeFrame(struct asistream *stream); + +s32 mp3main00043dd0(struct asistream *stream); + +f32 func00045ed0(f32 arg0, f32 arg1); + +s32 mp3utilGetBits(u8 *buffer, s32 *count, s32 numbits); +s32 mp3util000462f8(u8 *arg0, s32 *arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s16 **arg6, u8 **arg7); +s32 mp3util000464a8(u8 *arg0, s32 *arg1, s32 arg2, s32 arg3, s32 arg4, s16 **arg5, u8 **arg6); + +void func00046650(struct asistream_4f64 *arg0, s32 arg1, struct asistream_4f64 *arg2, struct asistream_4f64 *arg3, void *arg4); + +void func00047550(struct asistream_4f64 *arg0, s32 arg1, struct asistream_4f64 *arg2, struct asistream_4f64 *arg3); + +f32 func00047d20(f32 arg0); + +f32 func00047ef0(f32 arg0); + +#endif diff --git a/src/lib/lib_45ed0.c b/src/lib/mp3/lib_45ed0.c similarity index 85% rename from src/lib/lib_45ed0.c rename to src/lib/mp3/lib_45ed0.c index a1043ce1e..43f4d35cd 100644 --- a/src/lib/lib_45ed0.c +++ b/src/lib/mp3/lib_45ed0.c @@ -1,9 +1,5 @@ #include -#include "constants.h" -#include "bss.h" -#include "lib/lib_47d20.h" -#include "data.h" -#include "types.h" +#include "internal.h" f32 func00045ed0(f32 arg0, f32 arg1) { diff --git a/src/lib/lib_46650.s b/src/lib/mp3/lib_46650.s similarity index 100% rename from src/lib/lib_46650.s rename to src/lib/mp3/lib_46650.s diff --git a/src/lib/lib_47550.s b/src/lib/mp3/lib_47550.s similarity index 100% rename from src/lib/lib_47550.s rename to src/lib/mp3/lib_47550.s diff --git a/src/lib/lib_47d20.c b/src/lib/mp3/lib_47d20.c similarity index 89% rename from src/lib/lib_47d20.c rename to src/lib/mp3/lib_47d20.c index 11a4c7234..85ad79e6f 100644 --- a/src/lib/lib_47d20.c +++ b/src/lib/mp3/lib_47d20.c @@ -1,8 +1,5 @@ #include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include "internal.h" f32 fabsf(f32 value); diff --git a/src/lib/lib_47ef0.c b/src/lib/mp3/lib_47ef0.c similarity index 86% rename from src/lib/lib_47ef0.c rename to src/lib/mp3/lib_47ef0.c index cba667d87..4b5749c19 100644 --- a/src/lib/lib_47ef0.c +++ b/src/lib/mp3/lib_47ef0.c @@ -1,8 +1,5 @@ #include -#include "constants.h" -#include "bss.h" -#include "data.h" -#include "types.h" +#include "internal.h" f32 func00047ef0(f32 arg0) { diff --git a/src/lib/lib_43dd0.c b/src/lib/mp3/main.c similarity index 71% rename from src/lib/lib_43dd0.c rename to src/lib/mp3/main.c index 8fe722f00..479087509 100644 --- a/src/lib/lib_43dd0.c +++ b/src/lib/mp3/main.c @@ -1,10 +1,6 @@ #include -#include "constants.h" -#include "lib/lib_3e8c0.h" -#include "lib/lib_43dd0.h" -#include "lib/lib_461c0.h" -#include "data.h" -#include "types.h" +#include "internal.h" +#include "mp3.h" #define LAYER_3 1 #define LAYER_2 2 @@ -23,7 +19,7 @@ f32 *var8009c6dc; u32 var8005f700 = 0; u32 var8005f704 = 0; -s32 func00043dd0(struct asistream *stream) +s32 mp3main00043dd0(struct asistream *stream) { s32 sp1c = 0x1000; s32 sp18; @@ -46,7 +42,7 @@ s32 func00043dd0(struct asistream *stream) return stream->unk201c - stream->unk3f88; } -bool func00043ef8(struct asistream *stream, s32 arg1) +bool mp3main00043ef8(struct asistream *stream, s32 arg1) { s32 sp24; s32 sp20; @@ -95,22 +91,22 @@ bool func00043ef8(struct asistream *stream, s32 arg1) stream->unk18 += 2; stream->count = 12; - stream->version = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->layer = mp3decGetBits(stream->buffer, &stream->count, 2); - stream->crctype = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->bitrateindex = mp3decGetBits(stream->buffer, &stream->count, 4); - stream->samplerateindex = mp3decGetBits(stream->buffer, &stream->count, 2); - stream->haspadding = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->privatebit = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->channelmode = mp3decGetBits(stream->buffer, &stream->count, 2); + stream->version = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->layer = mp3utilGetBits(stream->buffer, &stream->count, 2); + stream->crctype = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->bitrateindex = mp3utilGetBits(stream->buffer, &stream->count, 4); + stream->samplerateindex = mp3utilGetBits(stream->buffer, &stream->count, 2); + stream->haspadding = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->privatebit = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->channelmode = mp3utilGetBits(stream->buffer, &stream->count, 2); - stream->unk3bc4 = mp3decGetBits(stream->buffer, &stream->count, 2); - stream->unk3bc8 = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->unk3bcc = mp3decGetBits(stream->buffer, &stream->count, 1); - stream->unk3bd0 = mp3decGetBits(stream->buffer, &stream->count, 2); + stream->unk3bc4 = mp3utilGetBits(stream->buffer, &stream->count, 2); + stream->unk3bc8 = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->unk3bcc = mp3utilGetBits(stream->buffer, &stream->count, 1); + stream->unk3bd0 = mp3utilGetBits(stream->buffer, &stream->count, 2); if (stream->bitrateindex == 15 || stream->samplerateindex == 3) { - return func00043ef8(stream, -1); + return mp3main00043ef8(stream, -1); } if (!stream->doneinitial) { @@ -129,7 +125,7 @@ bool func00043ef8(struct asistream *stream, s32 arg1) || stream->samplerateindex != stream->initialsamplerateindex || stream->channelmode != stream->initialchannelmode || stream->unk3bcc != stream->unk3bf0) { - return func00043ef8(stream, -1); + return mp3main00043ef8(stream, -1); } stream->unk2068 = 4; @@ -162,17 +158,17 @@ bool func00043ef8(struct asistream *stream, s32 arg1) return true; } -u32 func00044404(void) +u32 mp3mainInit(void) { if (var8005f704++) { return 2; } - func0003f8a0(); + mp3decInit(); return 0; } -struct asistream *func00044460(s32 arg0, void *arg1, s32 arg2) +struct asistream *mp3main00044460(s32 arg0, void *arg1, s32 arg2) { struct asistream *stream = g_AsiStream; @@ -192,7 +188,7 @@ struct asistream *func00044460(s32 arg0, void *arg1, s32 arg2) stream->unk2020 = 0; stream->unk3ba0 = 0; - func00043ef8(stream, 0); + mp3main00043ef8(stream, 0); stream->unk8474 = 0; @@ -201,7 +197,7 @@ struct asistream *func00044460(s32 arg0, void *arg1, s32 arg2) return stream; } -s32 func0004453c(struct asistream *streamptr, struct mp3thing **arg1, s32 *arg2) +s32 mp3main0004453c(struct asistream *streamptr, struct mp3thing **arg1, s32 *arg2) { struct asistream *stream = streamptr; s32 result; @@ -212,7 +208,7 @@ s32 func0004453c(struct asistream *streamptr, struct mp3thing **arg1, s32 *arg2) stream->unk3ba0 = 0; } - if (!func00043ef8(stream, stream->unk8474)) { + if (!mp3main00043ef8(stream, stream->unk8474)) { g_Mp3Vars.var8009c3e0 = 3; return 0; } diff --git a/src/lib/mp3/mp3.h b/src/lib/mp3/mp3.h new file mode 100644 index 000000000..14ac2c6f6 --- /dev/null +++ b/src/lib/mp3/mp3.h @@ -0,0 +1,103 @@ +#ifndef _IN_LIB_MP3_MP3_H +#define _IN_LIB_MP3_MP3_H +#include +#include "types.h" + +struct mp3decfourbytes { + u8 bytes[2]; + s8 unk02; + s8 unk03; +}; + +struct asistream_scalefac { + /*0x3d08*/ u32 l[22]; + /*0x3d60*/ u32 unk3d60; + /*0x3d64*/ u32 s[3][13]; +}; + +struct asistream_4f64 { + f32 unk00[18]; +}; + +struct asistream { + /*0x0000*/ s32 unk00; + /*0x0004*/ s32 (*unk04)(s32 arg0, void *arg1, s32 arg2, s32 arg3); + /*0x0008*/ s32 unk08; + /*0x000c*/ s32 unk0c; + /*0x0010*/ s32 unk10; + /*0x0014*/ s32 unk14; + /*0x0018*/ s32 unk18; + /*0x2000*/ u8 unk1c[0x2000]; + /*0x201c*/ s32 unk201c; + /*0x2020*/ s32 unk2020; + /*0x2024*/ u8 buffer[0x40]; + /*0x2064*/ s32 count; + /*0x2068*/ u32 unk2068; + /*0x206c*/ u32 unk206c; + /*0x2070*/ struct mp3thing unk2070[6]; + /*0x3ba0*/ s32 unk3ba0; + /*0x3ba4*/ u32 version; + /*0x3ba8*/ u32 layer; + /*0x3bac*/ u32 crctype; + /*0x3bb0*/ u32 bitrateindex; + /*0x3bb4*/ u32 samplerateindex; + /*0x3bb8*/ u32 haspadding; + /*0x3bbc*/ u32 privatebit; + /*0x3bc0*/ u32 channelmode; + /*0x3bc4*/ u32 unk3bc4; + /*0x3bc8*/ u32 unk3bc8; + /*0x3bcc*/ u32 unk3bcc; + /*0x3bd0*/ u32 unk3bd0; + /*0x3bd4*/ bool doneinitial; + /*0x3bd8*/ u32 initialversion; + /*0x3bdc*/ u32 initiallayer; + /*0x3be0*/ u32 initialcrctype; + /*0x3be4*/ u32 initialsamplerateindex; + /*0x3be8*/ u32 initialchannelmode; + /*0x3bec*/ u32 unk3bec; + /*0x3bf0*/ u32 unk3bf0; + /*0x3bf4*/ u32 main_data_begin; + /*0x3bf8*/ u32 scfsi[1][32]; + /*0x3c78*/ u32 part2_3_length[2][1]; + /*0x3c80*/ u32 big_value[2][1]; + /*0x3c88*/ s32 global_gain[2][1]; + /*0x3c90*/ u32 scalefac_compress[2][1]; + /*0x3c98*/ u32 window_switching[2][1]; + /*0x3ca0*/ u32 block_type[2][1]; + /*0x3ca8*/ u32 mixed_block_flag[2][1]; + /*0x3cb0*/ u32 table_select[2][1][3]; + /*0x3cc8*/ u32 subblock_gain[2][1][3]; + /*0x3ce0*/ u32 region0_count[2][1]; + /*0x3ce8*/ u32 region1_count[2][1]; + /*0x3cf0*/ u32 preflag[2][1]; + /*0x3cf8*/ u32 scalefac_scale[2][1]; + /*0x3d00*/ u32 count1table_select[2][1]; + struct asistream_scalefac scalefac[2][1]; + /*0x3ef8*/ u32 unk3ef8; + /*0x3efc*/ u32 unk3efc[6]; + /*0x3f14*/ u32 unk3f14[26]; + /*0x3f7c*/ s32 unk3f7c; + /*0x3f80*/ s32 unk3f80; + /*0x3f84*/ s32 unk3f84; + /*0x3f88*/ s32 unk3f88; + /*0x3f8c*/ s32 numchannels; + /*0x3f90*/ s32 numgranules; + /*0x3f94*/ s16 unk3f94[1][578]; + /*0x4418*/ u8 unk4418[1][578]; + /*0x465c*/ s32 unk465c[1]; + /*0x4660*/ s32 unk4660[1]; + /*0x4664*/ struct asistream_4f64 unk4664[1][32]; + /*0x4f64*/ struct asistream_4f64 unk4f64[2][32]; + /*0x6164*/ u8 unk6164[0x900]; + /*0x6a64*/ struct asistream_4f64 unk6a64[2][32]; + /*0x7c64*/ u8 unk7c64[0x810]; + /*0x8474*/ s32 unk8474; + /*0x8478*/ bool (*unk8478)(struct asistream *stream); + /*0x847c*/ bool (*unk847c)(struct asistream *stream); +}; + +u32 mp3mainInit(void); +struct asistream *mp3main00044460(s32 arg0, void *arg1, s32 arg2); +s32 mp3main0004453c(struct asistream *stream, struct mp3thing **arg1, s32 *arg2); + +#endif diff --git a/src/lib/lib_461c0.s b/src/lib/mp3/util.s similarity index 96% rename from src/lib/lib_461c0.s rename to src/lib/mp3/util.s index 31dea2260..eebaaf773 100644 --- a/src/lib/lib_461c0.s +++ b/src/lib/mp3/util.s @@ -4,7 +4,7 @@ .text -glabel func000461c0 +glabel mp3util000461c0 andi $t4, $t0, 0x7 addiu $t3, $zero, 0x8 lbu $t5, 0x0($a0) @@ -62,7 +62,7 @@ glabel func000461c0 jr $ra lb $t1, 0x3($t7) -glabel func00046290 +glabel mp3util00046290 lwl $t1, 0x0($a0) lwr $t1, 0x3($a0) andi $t2, $t0, 0x7 @@ -77,7 +77,7 @@ glabel func00046290 jr $ra add $t0, $t0, $s1 -glabel mp3decGetBits +glabel mp3utilGetBits lw $t0, 0x0($a1) srl $t1, $t0, 0x3 add $a0, $a0, $t1 @@ -92,7 +92,7 @@ glabel mp3decGetBits jr $ra sw $t0, 0x0($a1) -glabel func000462f8 +glabel mp3util000462f8 addiu $sp, $sp, -48 sw $ra, 0x0($sp) sw $s0, 0x4($sp) @@ -124,14 +124,14 @@ glabel func000462f8 blez $t1, .L00046458 nop .L00046370: - jal func000461c0 + jal mp3util000461c0 nop beqz $s1, .L00046398 add $s6, $zero, $t1 addiu $t2, $zero, 0xf bne $v0, $t2, .L00046398 nop - jal func00046290 + jal mp3util00046290 nop addi $v0, $v0, 0xf .L00046398: @@ -157,7 +157,7 @@ glabel func000462f8 addiu $t2, $zero, 0xf bne $s6, $t2, .L000463fc nop - jal func00046290 + jal mp3util00046290 nop addi $s6, $v0, 0xf add $v0, $zero, $s7 @@ -208,7 +208,7 @@ glabel func000462f8 jr $ra add $v0, $zero, $a3 -glabel func000464a8 +glabel mp3util000464a8 addiu $sp, $sp, -48 sw $ra, 0x0($sp) sw $s0, 0x4($sp) @@ -242,7 +242,7 @@ glabel func000464a8 bgez $t1, .L000465f4 nop .L00046528: - jal func000461c0 + jal mp3util000461c0 nop srl $t3, $v0, 0x3 andi $t3, $t3, 0x1 @@ -255,7 +255,7 @@ glabel func000464a8 sh $t4, 0x2($s3) sh $t5, 0x4($s3) sh $t6, 0x6($s3) - jal func00046290 + jal mp3util00046290 addiu $s1, $zero, 0x4 addiu $s1, $zero, 0x3 sb $v0, 0x0($s4)