Fix seg faulting issue with MinGW build system, most likely caused by use of execl (#812)
This commit is contained in:
1 parent
750ba10cb1
commit
a6782e6912
6 files changed
+108
-24
No files matched your search
@@ -780,7 +780,7 @@ endif
|
|||||||
|
|
||||||
$(BUILD_DIR)/%.table: %.aiff
|
$(BUILD_DIR)/%.table: %.aiff
|
||||||
$(call print,Extracting codebook:,$<,$@)
|
$(call print,Extracting codebook:,$<,$@)
|
||||||
$(V)$(AIFF_EXTRACT_CODEBOOK) $< >$@
|
$(V)$(AIFF_EXTRACT_CODEBOOK) $< $@
|
||||||
|
|
||||||
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
|
$(BUILD_DIR)/%.aifc: $(BUILD_DIR)/%.table %.aiff
|
||||||
$(call print,Encoding ADPCM:,$(word 2,$^),$@)
|
$(call print,Encoding ADPCM:,$(word 2,$^),$@)
|
||||||
|
|||||||
+4
-1
@@ -49,7 +49,10 @@ textconv_SOURCES := textconv.c utf8.c hashtable.c
|
|||||||
|
|
||||||
aifc_decode_SOURCES := aifc_decode.c
|
aifc_decode_SOURCES := aifc_decode.c
|
||||||
|
|
||||||
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c
|
aiff_extract_codebook: $(LIBAUDIOFILE)
|
||||||
|
aiff_extract_codebook_SOURCES := aiff_extract_codebook.c sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
|
||||||
|
aiff_extract_codebook_CFLAGS := -DEXTRACT_CODEBOOK -Iaudiofile -Wno-uninitialized
|
||||||
|
aiff_extract_codebook_LDFLAGS := -Laudiofile -laudiofile -lstdc++
|
||||||
|
|
||||||
tabledesign$(EXT): $(LIBAUDIOFILE)
|
tabledesign$(EXT): $(LIBAUDIOFILE)
|
||||||
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
|
tabledesign_SOURCES := sdk-tools/tabledesign/codebook.c sdk-tools/tabledesign/estimate.c sdk-tools/tabledesign/print.c sdk-tools/tabledesign/tabledesign.c
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include "sdk-tools/tabledesign/tabledesign.h"
|
||||||
|
|
||||||
typedef short s16;
|
typedef short s16;
|
||||||
typedef int s32;
|
typedef int s32;
|
||||||
typedef unsigned char u8;
|
typedef unsigned char u8;
|
||||||
@@ -28,8 +30,9 @@ typedef struct
|
|||||||
s16 state[16];
|
s16 state[16];
|
||||||
} ALADPCMloop;
|
} ALADPCMloop;
|
||||||
|
|
||||||
static const char usage[] = "input.aiff";
|
static const char usage[] = "input.aiff, output.table";
|
||||||
static const char *progname, *infilename;
|
static const char *progname;
|
||||||
|
static char *infilename, *outfilename;
|
||||||
|
|
||||||
#define checked_fread(a, b, c, d) if (fread(a, b, c, d) != c) fail_parse("error parsing file")
|
#define checked_fread(a, b, c, d) if (fread(a, b, c, d) != c) fail_parse("error parsing file")
|
||||||
|
|
||||||
@@ -115,12 +118,13 @@ int main(int argc, char **argv)
|
|||||||
FILE *ifile;
|
FILE *ifile;
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 3) {
|
||||||
fprintf(stderr, "%s %s\n", progname, usage);
|
fprintf(stderr, "%s %s\n", progname, usage);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
infilename = argv[1];
|
infilename = argv[1];
|
||||||
|
outfilename = argv[2];
|
||||||
|
|
||||||
if ((ifile = fopen(infilename, "rb")) == NULL) {
|
if ((ifile = fopen(infilename, "rb")) == NULL) {
|
||||||
fail_parse("AIFF file could not be opened");
|
fail_parse("AIFF file could not be opened");
|
||||||
@@ -168,17 +172,33 @@ int main(int argc, char **argv)
|
|||||||
fclose(ifile);
|
fclose(ifile);
|
||||||
|
|
||||||
if (coefTable == NULL) {
|
if (coefTable == NULL) {
|
||||||
execl("./tools/tabledesign", "tabledesign", "-s", "1", infilename, NULL);
|
char* arguments[] = {
|
||||||
|
"tabledesign",
|
||||||
|
"-s",
|
||||||
|
"1",
|
||||||
|
"-p",
|
||||||
|
outfilename,
|
||||||
|
infilename
|
||||||
|
};
|
||||||
|
return tabledesign_entry(6, arguments);
|
||||||
} else {
|
} else {
|
||||||
printf("%d\n%d\n", order, npredictors);
|
FILE *fp;
|
||||||
|
if ((fp = fopen(outfilename, "w")) == NULL) {
|
||||||
|
fprintf(stderr, "%s: could not write to file: %s", progname, outfilename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "%d\n%d\n", order, npredictors);
|
||||||
for (s32 i = 0; i < npredictors; i++) {
|
for (s32 i = 0; i < npredictors; i++) {
|
||||||
for (s32 j = 0; j < order; j++) {
|
for (s32 j = 0; j < order; j++) {
|
||||||
for (s32 k = 0; k < 8; k++) {
|
for (s32 k = 0; k < 8; k++) {
|
||||||
printf("% 5d ", coefTable[i][k][j]);
|
fprintf(fp, "% 5d ", coefTable[i][k][j]);
|
||||||
}
|
}
|
||||||
puts("");
|
fprintf(fp, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,18 @@ int print_entry(FILE *out, double *row, int order)
|
|||||||
int overflows;
|
int overflows;
|
||||||
|
|
||||||
table = malloc(8 * sizeof(double*));
|
table = malloc(8 * sizeof(double*));
|
||||||
|
if (table == NULL) {
|
||||||
|
fprintf(stderr, "print_entry: could not allocate memory for table\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
table[i] = malloc(order * sizeof(double));
|
table[i] = malloc(order * sizeof(double));
|
||||||
|
if (table[i] == NULL) {
|
||||||
|
fprintf(stderr, "print_entry: could not allocate memory for table[%d]\n", i);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < order; i++)
|
for (i = 0; i < order; i++)
|
||||||
|
|||||||
@@ -30,9 +30,21 @@ typedef int SampleFormat;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char usage[80] = "[-o order -s bits -t thresh -i refine_iter -f frame_size] aifcfile";
|
#define mallocErr(var, size, msg) \
|
||||||
|
var = malloc(size); \
|
||||||
|
if (var == NULL) { \
|
||||||
|
fprintf(stderr, "%s: malloc failed at %s\n", programName, msg); \
|
||||||
|
exit(1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
char filename[1024] = "";
|
||||||
|
char usage[80] = "[-o order -s bits -t thresh -i refine_iter -f frame_size -p filename] aifcfile";
|
||||||
|
|
||||||
|
#ifndef EXTRACT_CODEBOOK
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
#else
|
||||||
|
int tabledesign_entry(int argc, char **argv)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
const char *programName; // sp118
|
const char *programName; // sp118
|
||||||
double thresh; // sp110
|
double thresh; // sp110
|
||||||
@@ -64,6 +76,7 @@ int main(int argc, char **argv)
|
|||||||
short *temp_s3;
|
short *temp_s3;
|
||||||
int i;
|
int i;
|
||||||
int dataSize; // s4
|
int dataSize; // s4
|
||||||
|
FILE *outfile;
|
||||||
|
|
||||||
order = 2;
|
order = 2;
|
||||||
bits = 2;
|
bits = 2;
|
||||||
@@ -79,7 +92,7 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "o:s:t:i:f:")) != -1)
|
while ((opt = getopt(argc, argv, "o:s:t:i:f:p:")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
@@ -103,9 +116,25 @@ int main(int argc, char **argv)
|
|||||||
if (sscanf(optarg, "%lf", &thresh) != 1)
|
if (sscanf(optarg, "%lf", &thresh) != 1)
|
||||||
thresh = 10.0;
|
thresh = 10.0;
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
if (sscanf(optarg, "%s", filename) != 1) {
|
||||||
|
fprintf(stderr, "%s: No valid out file!\n", programName);
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
if ((outfile = fopen(filename, "w")) == NULL) {
|
||||||
|
fprintf(stderr, "%s: Could not open %s for writing\n", programName, filename);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outfile == NULL) {
|
||||||
|
fprintf(stderr, "%s: No out file!\n", programName);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
argv = &argv[optind - 1];
|
argv = &argv[optind - 1];
|
||||||
|
|
||||||
afFile = AFopenfile(argv[1], MODE_READ, NULL);
|
afFile = AFopenfile(argv[1], MODE_READ, NULL);
|
||||||
@@ -114,6 +143,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: input AIFC file [%s] could not be opened.\n",
|
"%s: input AIFC file [%s] could not be opened.\n",
|
||||||
programName, argv[1]);
|
programName, argv[1]);
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,6 +156,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: file [%s] contains %d channels, only 1 channel supported.\n",
|
"%s: file [%s] contains %d channels, only 1 channel supported.\n",
|
||||||
programName, argv[1], channels);
|
programName, argv[1], channels);
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +169,10 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: file [%s] contains %d tracks, only 1 track supported.\n",
|
"%s: file [%s] contains %d tracks, only 1 track supported.\n",
|
||||||
programName, argv[1], tracks);
|
programName, argv[1], tracks);
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,34 +182,38 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: file [%s] contains %d bit samples, only 16 bit samples supported.\n",
|
"%s: file [%s] contains %d bit samples, only 16 bit samples supported.\n",
|
||||||
programName, argv[1], (int)sampleWidth);
|
programName, argv[1], (int)sampleWidth);
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_s1 = malloc((1 << bits) * sizeof(double*));
|
mallocErr(temp_s1, (1 << bits) * sizeof(double*), "temp_s1");
|
||||||
for (i = 0; i < (1 << bits); i++)
|
for (i = 0; i < (1 << bits); i++)
|
||||||
{
|
{
|
||||||
temp_s1[i] = malloc((order + 1) * sizeof(double));
|
mallocErr(temp_s1[i], (order + 1) * sizeof(double), "temp_si[i]");
|
||||||
}
|
}
|
||||||
|
|
||||||
splitDelta = malloc((order + 1) * sizeof(double));
|
mallocErr(splitDelta, (order + 1) * sizeof(double), "splitDelta");
|
||||||
temp_s3 = malloc(frameSize * 2 * sizeof(short));
|
mallocErr(temp_s3, frameSize * 2 * sizeof(short), "temp_s3");
|
||||||
for (i = 0; i < frameSize * 2; i++)
|
for (i = 0; i < frameSize * 2; i++)
|
||||||
{
|
{
|
||||||
temp_s3[i] = 0;
|
temp_s3[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec = malloc((order + 1) * sizeof(double));
|
mallocErr(vec, (order + 1) * sizeof(double), "vec");
|
||||||
spF4 = malloc((order + 1) * sizeof(double));
|
mallocErr(spF4, (order + 1) * sizeof(double), "spF4");
|
||||||
mat = malloc((order + 1) * sizeof(double*));
|
mallocErr(mat, (order + 1) * sizeof(double*), "mat");
|
||||||
for (i = 0; i <= order; i++)
|
for (i = 0; i <= order; i++)
|
||||||
{
|
{
|
||||||
mat[i] = malloc((order + 1) * sizeof(double));
|
mallocErr(mat[i], (order + 1) * sizeof(double), "mat[i]");
|
||||||
}
|
}
|
||||||
|
|
||||||
perm = malloc((order + 1) * sizeof(int));
|
mallocErr(perm, (order + 1) * sizeof(int), "perm");
|
||||||
frameCount = AFgetframecnt(afFile, AF_DEFAULT_TRACK);
|
frameCount = AFgetframecnt(afFile, AF_DEFAULT_TRACK);
|
||||||
rate = AFgetrate(afFile, AF_DEFAULT_TRACK);
|
rate = AFgetrate(afFile, AF_DEFAULT_TRACK);
|
||||||
data = malloc(frameCount * sizeof(double*));
|
mallocErr(data, frameCount * sizeof(double*), "data");
|
||||||
dataSize = 0;
|
dataSize = 0;
|
||||||
|
|
||||||
while (AFreadframes(afFile, AF_DEFAULT_TRACK, temp_s3 + frameSize, frameSize) == frameSize)
|
while (AFreadframes(afFile, AF_DEFAULT_TRACK, temp_s3 + frameSize, frameSize) == frameSize)
|
||||||
@@ -183,7 +228,7 @@ int main(int argc, char **argv)
|
|||||||
vec[0] = 1.0;
|
vec[0] = 1.0;
|
||||||
if (kfroma(vec, spF4, order) == 0)
|
if (kfroma(vec, spF4, order) == 0)
|
||||||
{
|
{
|
||||||
data[dataSize] = malloc((order + 1) * sizeof(double));
|
mallocErr(data[dataSize], (order + 1) * sizeof(double), "data[dataSize]");
|
||||||
data[dataSize][0] = 1.0;
|
data[dataSize][0] = 1.0;
|
||||||
|
|
||||||
for (i = 1; i <= order; i++)
|
for (i = 1; i <= order; i++)
|
||||||
@@ -247,16 +292,20 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
npredictors = 1 << curBits;
|
npredictors = 1 << curBits;
|
||||||
fprintf(stdout, "%d\n%d\n", order, npredictors);
|
fprintf(outfile, "%d\n%d\n", order, npredictors);
|
||||||
|
|
||||||
for (i = 0; i < npredictors; i++)
|
for (i = 0; i < npredictors; i++)
|
||||||
{
|
{
|
||||||
numOverflows += print_entry(stdout, temp_s1[i], order);
|
numOverflows += print_entry(outfile, temp_s1[i], order);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numOverflows > 0)
|
if (numOverflows > 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "There was overflow - check the table\n");
|
fprintf(stderr, "There was overflow - check the table\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fclose(outfile);
|
||||||
|
outfile = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -27,4 +27,8 @@ void refine(double **table, int order, int npredictors, double **data, int dataS
|
|||||||
// print.c
|
// print.c
|
||||||
int print_entry(FILE *out, double *row, int order);
|
int print_entry(FILE *out, double *row, int order);
|
||||||
|
|
||||||
|
#ifdef EXTRACT_CODEBOOK
|
||||||
|
int tabledesign_entry(int, char**);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Reference in new issue
Block a user