Sloppy fixes to adpcm
Stopped ignoring warnings in the makefile. Made warnings an error. Sanity checked nsequences to prevent allocating gigantic tables.
This commit is contained in:
parent
73da8ee434
commit
79e21271e9
|
@ -1,6 +1,6 @@
|
|||
CC := gcc
|
||||
CXX := g++
|
||||
CFLAGS := -I../include -I. -Wall -Wextra -Wno-unused-parameter -Wno-error=implicit-function-declaration -pedantic -std=c99 -O2 -s
|
||||
CFLAGS := -I../include -I. -Wall -Wextra -Wno-unused-parameter -Wno-error=implicit-function-declaration -pedantic -std=c99 -O2
|
||||
LDFLAGS := -lm
|
||||
PROGRAMS := n64graphics n64graphics_ci mio0 n64cksum textconv patch_libultra_math aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
|
||||
|
||||
|
@ -29,7 +29,7 @@ tabledesign_CFLAGS := -Iaudiofile -Wno-uninitialized
|
|||
tabledesign_LDFLAGS := -Laudiofile -laudiofile -lstdc++ -lm
|
||||
|
||||
vadpcm_enc_SOURCES := sdk-tools/adpcm/vadpcm_enc.c sdk-tools/adpcm/vpredictor.c sdk-tools/adpcm/quant.c sdk-tools/adpcm/util.c sdk-tools/adpcm/vencode.c
|
||||
vadpcm_enc_CFLAGS := -Wno-unused-result -Wno-uninitialized -Wno-sign-compare -Wno-absolute-value
|
||||
vadpcm_enc_CFLAGS := -Werror -g
|
||||
|
||||
extract_data_for_mio_SOURCES := extract_data_for_mio.c
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@ static u32 getshort(FILE *ifile)
|
|||
u32 c1;
|
||||
u32 c2;
|
||||
|
||||
if ((c1 = getc(ifile)) == -1)
|
||||
if ((c1 = (u32)getc(ifile)) == (u32)-1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((c2 = getc(ifile)) == -1)
|
||||
if ((c2 = (u32)getc(ifile)) == (u32)-1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ u32 readbits(u32 nbits, FILE *ifile)
|
|||
u32 left;
|
||||
u32 mask;
|
||||
|
||||
if (nbits <= in_bit_pos + 1)
|
||||
if (nbits <= (u32)(in_bit_pos + 1))
|
||||
{
|
||||
mask = (1U << nbits) - 1;
|
||||
b = ((u32) input_word >> (in_bit_pos - nbits + 1)) & mask;
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef double f64;
|
|||
#else
|
||||
# define BSWAP16(x) x = __builtin_bswap16(x);
|
||||
# define BSWAP32(x) x = __builtin_bswap32(x);
|
||||
# define BSWAP16_MANY(x, n) { s32 _i; for (_i = 0; _i < n; _i++) BSWAP16((x)[_i]) }
|
||||
# define BSWAP16_MANY(x, n) { s32 _i; for (_i = 0; _i < (s32)n; _i++) BSWAP16((x)[_i]) }
|
||||
#endif
|
||||
|
||||
#ifdef __sgi
|
||||
|
|
|
@ -11,30 +11,30 @@ int main(int argc, char **argv)
|
|||
{
|
||||
s32 c;
|
||||
char *progname = argv[0];
|
||||
s16 nloops = 0;
|
||||
u16 nloops = 0;
|
||||
s16 numMarkers;
|
||||
s16 *inBuffer;
|
||||
s16 ts;
|
||||
s32 minLoopLength = 800;
|
||||
u32 minLoopLength = 800;
|
||||
s32 ***coefTable = NULL;
|
||||
s32 *state;
|
||||
s32 *state; // has to be signed
|
||||
s32 order;
|
||||
s32 npredictors;
|
||||
s32 done = 0;
|
||||
s32 truncate = 0;
|
||||
s32 num;
|
||||
s32 tableSize;
|
||||
s32 nsam;
|
||||
u32 nsam;
|
||||
s32 left;
|
||||
u32 newEnd;
|
||||
s32 nRepeats;
|
||||
s32 i;
|
||||
s32 j;
|
||||
s32 k;
|
||||
s32 nFrames;
|
||||
u32 nFrames;
|
||||
s32 offset;
|
||||
s32 cChunkPos;
|
||||
s32 currentPos;
|
||||
u32 currentPos = 0;
|
||||
s32 soundPointer = 0;
|
||||
s32 startPointer = 0;
|
||||
s32 startSoundPointer = 0;
|
||||
|
@ -53,8 +53,8 @@ int main(int argc, char **argv)
|
|||
SoundDataChunk SndDChunk;
|
||||
InstrumentChunk InstChunk;
|
||||
Loop *loops = NULL;
|
||||
ALADPCMloop *aloops;
|
||||
Marker *markers;
|
||||
ALADPCMloop *aloops = NULL;
|
||||
Marker *markers = NULL;
|
||||
CodeChunk cChunk;
|
||||
char filename[1024];
|
||||
FILE *fhandle;
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char **argv)
|
|||
break;
|
||||
|
||||
case 'l':
|
||||
sscanf(optarg, "%d", &minLoopLength);
|
||||
sscanf(optarg, "%u", &minLoopLength);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -353,11 +353,11 @@ int main(int argc, char **argv)
|
|||
startSoundPointer = ftell(ifile);
|
||||
for (i = 0; i < nloops; i++)
|
||||
{
|
||||
if (lookupMarker(&aloops[i].start, loops[i].beginLoop, markers, numMarkers) != 0)
|
||||
if (aloops == NULL || markers == NULL || lookupMarker(&aloops[i].start, loops[i].beginLoop, markers, numMarkers) != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: Start loop marker not found\n", progname);
|
||||
}
|
||||
else if (lookupMarker(&aloops[i].end, loops[i].endLoop, markers, numMarkers) != 0)
|
||||
else if (aloops == NULL || markers == NULL || lookupMarker(&aloops[i].end, loops[i].endLoop, markers, numMarkers) != 0)
|
||||
{
|
||||
fprintf(stderr, "%s: End loop marker not found\n", progname);
|
||||
}
|
||||
|
@ -487,6 +487,7 @@ int main(int argc, char **argv)
|
|||
BSWAP16(nloops)
|
||||
for (i = 0; i < nloops; i++)
|
||||
{
|
||||
if (aloops == NULL) { continue; }
|
||||
BSWAP32(aloops[i].start)
|
||||
BSWAP32(aloops[i].end)
|
||||
BSWAP32(aloops[i].count)
|
||||
|
|
|
@ -100,6 +100,7 @@ void vencodeframe(FILE *ofile, s16 *inBuffer, s32 *state, s32 ***coefTable, s32
|
|||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (coefTable == NULL || coefTable[optimalp] == NULL) { continue; }
|
||||
prediction[i] = inner_product(order + i, coefTable[optimalp][i], inVector);
|
||||
inVector[i + order] = inBuffer[i] - prediction[i];
|
||||
e[i] = (f32) inVector[i + order];
|
||||
|
@ -126,7 +127,7 @@ void vencodeframe(FILE *ofile, s16 *inBuffer, s32 *state, s32 ***coefTable, s32
|
|||
max = 0;
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
if (fabs(ie[i]) > fabs(max))
|
||||
if (fabs((f64)ie[i]) > fabs((f64)max))
|
||||
{
|
||||
max = ie[i];
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ s32 readcodebook(FILE *fhandle, s32 ****table, s32 *order, s32 *npredictors)
|
|||
|
||||
fscanf(fhandle, "%d", order);
|
||||
fscanf(fhandle, "%d", npredictors);
|
||||
if (*npredictors > 500) {
|
||||
fprintf(stderr, "Way too many predictors: %d\n", *npredictors);
|
||||
return 1;
|
||||
}
|
||||
*table = malloc(*npredictors * sizeof(s32 **));
|
||||
for (i = 0; i < *npredictors; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue