Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Macros | Typedefs | Functions | Variables
aifc_decode.c File Reference
#include <unistd.h>
#include <assert.h>
#include <math.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

Data Structures

struct  ChunkHeader
 
struct  Chunk
 
struct  CommonChunk
 
struct  Marker
 
struct  Loop
 
struct  InstrumentChunk
 
struct  SoundDataChunk
 
struct  CodeChunk
 
struct  ALADPCMloop
 

Macros

#define bswap16(x)   __builtin_bswap16(x)
 
#define bswap32(x)   __builtin_bswap32(x)
 
#define BSWAP16(x)   x = __builtin_bswap16(x)
 
#define BSWAP32(x)   x = __builtin_bswap32(x)
 
#define BSWAP16_MANY(x, n)   for (s32 _i = 0; _i < n; _i++) BSWAP16((x)[_i])
 
#define NORETURN   __attribute__((noreturn))
 
#define UNUSED   __attribute__((unused))
 
#define checked_fread(a, b, c, d)   if (fread(a, b, c, d) != c) fail_parse("error parsing file")
 

Typedefs

typedef signed char s8
 Bruteforcing decoder for converting ADPCM-encoded AIFC into AIFF, in a way that roundtrips with vadpcm_enc. More...
 
typedef short s16
 
typedef int s32
 
typedef unsigned char u8
 
typedef unsigned short u16
 
typedef unsigned int u32
 
typedef unsigned long long u64
 
typedef float f32
 

Functions

NORETURN void fail_parse (const char *fmt,...)
 
s32 myrand ()
 
s16 qsample (s32 x, s32 scale)
 
s16 clamp_to_s16 (s32 x)
 
s32 toi4 (s32 x)
 
s32 readaifccodebook (FILE *fhandle, s32 ****table, s16 *order, s16 *npredictors)
 
ALADPCMloopreadlooppoints (FILE *ifile, s16 *nloops)
 
s32 inner_product (s32 length, s32 *v1, s32 *v2)
 
void my_decodeframe (u8 *frame, s32 *state, s32 order, s32 ***coefTable)
 
void my_encodeframe (u8 *out, s16 *inBuffer, s32 *state, s32 ***coefTable, s32 order, s32 npredictors)
 
void permute (s16 *out, s32 *in, s32 scale)
 
void write_header (FILE *ofile, const char *id, s32 size)
 
int main (int argc, char **argv)
 

Variables

static char usage [] = "input.aifc output.aiff"
 
static const charprogname
 
static const charinfilename
 

Macro Definition Documentation

◆ bswap16

#define bswap16 (   x)    __builtin_bswap16(x)

◆ BSWAP16

#define BSWAP16 (   x)    x = __builtin_bswap16(x)

◆ BSWAP16_MANY

#define BSWAP16_MANY (   x,
 
)    for (s32 _i = 0; _i < n; _i++) BSWAP16((x)[_i])

◆ bswap32

#define bswap32 (   x)    __builtin_bswap32(x)

◆ BSWAP32

#define BSWAP32 (   x)    x = __builtin_bswap32(x)

◆ checked_fread

#define checked_fread (   a,
  b,
  c,
 
)    if (fread(a, b, c, d) != c) fail_parse("error parsing file")

◆ NORETURN

#define NORETURN   __attribute__((noreturn))

◆ UNUSED

#define UNUSED   __attribute__((unused))

Typedef Documentation

◆ f32

typedef float f32

◆ s16

typedef short s16

◆ s32

◆ s8

typedef signed char s8

Bruteforcing decoder for converting ADPCM-encoded AIFC into AIFF, in a way that roundtrips with vadpcm_enc.

◆ u16

typedef unsigned short u16

◆ u32

typedef unsigned int u32

◆ u64

typedef unsigned long long u64

◆ u8

typedef unsigned char u8

Function Documentation

◆ clamp_to_s16()

s16 clamp_to_s16 ( s32  x)

◆ fail_parse()

NORETURN void fail_parse ( const char fmt,
  ... 
)

◆ inner_product()

s32 inner_product ( s32  length,
s32 v1,
s32 v2 
)

◆ main()

int main ( int  argc,
char **  argv 
)

◆ my_decodeframe()

void my_decodeframe ( u8 frame,
s32 state,
s32  order,
s32 ***  coefTable 
)

◆ my_encodeframe()

void my_encodeframe ( u8 out,
s16 inBuffer,
s32 state,
s32 ***  coefTable,
s32  order,
s32  npredictors 
)

◆ myrand()

s32 myrand ( )

◆ permute()

void permute ( s16 out,
s32 in,
s32  scale 
)

◆ qsample()

s16 qsample ( s32  x,
s32  scale 
)

◆ readaifccodebook()

s32 readaifccodebook ( FILE *  fhandle,
s32 ****  table,
s16 order,
s16 npredictors 
)

◆ readlooppoints()

ALADPCMloop* readlooppoints ( FILE *  ifile,
s16 nloops 
)

◆ toi4()

s32 toi4 ( s32  x)

◆ write_header()

void write_header ( FILE *  ofile,
const char id,
s32  size 
)

Variable Documentation

◆ infilename

const char * infilename
static

◆ progname

const char* progname
static

◆ usage

char usage[] = "input.aifc output.aiff"
static