ref: 01560a054a836e332c41e69486d9a79f1ede2497
parent: 1664484e81aa123b419319e5f8f69c999f66274b
author: oxygene2000 <oxygene2000>
date: Sun Feb 4 12:50:47 EST 2001
- new Makefiles - .cvsignore for a cleaner cvs-output - // xyz -> /* xyz */ for ansi-c compliance - minor fixes to work on linux
--- /dev/null
+++ b/Makefile
@@ -1,0 +1,7 @@
+all:
+ make -C libfaac
+ make -C frontend
+
+clean:
+ make -C libfaac clean
+ make -C frontend clean
--- /dev/null
+++ b/frontend/.cvsignore
@@ -1,0 +1,3 @@
+*.o
+*.so
+*.a
--- /dev/null
+++ b/frontend/Makefile
@@ -1,0 +1,12 @@
+prefix=/usr/local/bin
+CFLAGS=-I../include
+
+faac: main.o
+ gcc main.o -o faac -L../libfaac -lfaac -lsndfile
+
+install: faac
+ mkdir -p $(prefix)/bin
+ cp faac $(prefix)/bin
+
+clean:
+ rm faac *.o
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,12 +16,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: main.c,v 1.2 2001/01/17 15:51:15 menno Exp $
+ * $Id: main.c,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifdef _WIN32
#include <windows.h>
#endif
+
+#ifdef LINUX
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
--- /dev/null
+++ b/libfaac/.cvsignore
@@ -1,0 +1,3 @@
+*.o
+*.so
+*.a
--- /dev/null
+++ b/libfaac/Makefile
@@ -1,0 +1,37 @@
+prefix=/usr/local/lib
+
+CFLAGS=-ansi -pedantic
+
+SRC= \
+aacquant.c\
+bitstream.c\
+channels.c\
+fft.c\
+filtbank.c\
+frame.c\
+huffman.c\
+joint.c\
+psych.c\
+util.c
+
+OBJ := $(SRC:.c=.o)
+
+all: libfaac.a libfaac.so
+
+libfaac.so: $(OBJ)
+ gcc -shared -o libfaac.so $(OBJ) -lm
+
+libfaac.a: $(OBJ)
+ ar rcs $@ $(OBJ)
+ ranlib $@
+
+install: libfaac.so libfaac.a
+ mkdir -p $(prefix)/include
+ mkdir -p $(prefix)/lib
+ cp ../include/faac.h $(prefix)/include/faac.h
+ cp libfaac.so $(prefix)/lib/libfaac.so
+ cp libfaac.a $(prefix)/lib/libfaac.a
+
+clean:
+ rm -f $(OBJ)
+ rm -f libfaac.a libfaac.so
--- a/libfaac/aacquant.c
+++ b/libfaac/aacquant.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: aacquant.c,v 1.2 2001/01/19 14:59:23 menno Exp $
+ * $Id: aacquant.c,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#include <math.h>
@@ -211,7 +211,7 @@
return nBits;
}
-#if 1 // TAKEHIRO_IEEE754_HACK
+#if 1 /* TAKEHIRO_IEEE754_HACK */
#pragma warning( disable : 4244 4307 )
--- a/libfaac/bitstream.c
+++ b/libfaac/bitstream.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: bitstream.c,v 1.2 2001/01/23 13:46:18 menno Exp $
+ * $Id: bitstream.c,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#include <stdlib.h>
@@ -179,24 +179,24 @@
{
if (writeFlag) {
/* Fixed ADTS header */
- PutBit(bitStream, 0xFFFF, 12); // 12 bit Syncword
- PutBit(bitStream, 1, 1); // ID
- PutBit(bitStream, 0, 2); // layer
- PutBit(bitStream, 1, 1); // protection absent
- PutBit(bitStream, hEncoder->aacProfile, 2); // profile
- PutBit(bitStream, hEncoder->sampleRateIdx, 4); // sampling rate
- PutBit(bitStream, 0, 1); // private bit
- PutBit(bitStream, 1, 3); // ch. config (must be > 0)
- PutBit(bitStream, 0, 1); // original/copy
- PutBit(bitStream, 0, 1); // home
- PutBit(bitStream, 0, 2); // emphasis
+ PutBit(bitStream, 0xFFFF, 12); /* 12 bit Syncword */
+ PutBit(bitStream, 1, 1); /* ID */
+ PutBit(bitStream, 0, 2); /* layer */
+ PutBit(bitStream, 1, 1); /* protection absent */
+ PutBit(bitStream, hEncoder->aacProfile, 2); /* profile */
+ PutBit(bitStream, hEncoder->sampleRateIdx, 4); /* sampling rate */
+ PutBit(bitStream, 0, 1); /* private bit */
+ PutBit(bitStream, 1, 3); /* ch. config (must be > 0) */
+ PutBit(bitStream, 0, 1); /* original/copy */
+ PutBit(bitStream, 0, 1); /* home */
+ PutBit(bitStream, 0, 2); /* emphasis */
/* Variable ADTS header */
- PutBit(bitStream, 0, 1); // copyr. id. bit
- PutBit(bitStream, 0, 1); // copyr. id. start
+ PutBit(bitStream, 0, 1); /* copyr. id. bit */
+ PutBit(bitStream, 0, 1); /* copyr. id. start */
PutBit(bitStream, hEncoder->usedBytes, 13);
- PutBit(bitStream, 0x7FF, 11); // buffer fullness (0x7FF for VBR)
- PutBit(bitStream, 0, 2); // raw data blocks (0+1=1)
+ PutBit(bitStream, 0x7FF, 11); /* buffer fullness (0x7FF for VBR) */
+ PutBit(bitStream, 0, 2); /* raw data blocks (0+1=1) */
}
return 58;
}
--- a/libfaac/channels.h
+++ b/libfaac/channels.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: channels.h,v 1.1 2001/01/17 11:21:40 menno Exp $
+ * $Id: channels.h,v 1.2 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifndef CHANNEL_H
@@ -52,4 +52,4 @@
}
#endif /* __cplusplus */
-#endif /* CHANNEL_H */
\ No newline at end of file
+#endif /* CHANNEL_H */
--- a/libfaac/coder.h
+++ b/libfaac/coder.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: coder.h,v 1.1 2001/01/17 11:21:40 menno Exp $
+ * $Id: coder.h,v 1.2 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifndef CODER_H
@@ -41,7 +41,7 @@
ONLY_LONG_WINDOW,
LONG_SHORT_WINDOW,
ONLY_SHORT_WINDOW,
- SHORT_LONG_WINDOW,
+ SHORT_LONG_WINDOW
};
typedef struct {
@@ -87,4 +87,4 @@
}
#endif /* __cplusplus */
-#endif /* CODER_H */
\ No newline at end of file
+#endif /* CODER_H */
--- a/libfaac/fft.c
+++ b/libfaac/fft.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: fft.c,v 1.1 2001/01/17 11:21:40 menno Exp $
+ * $Id: fft.c,v 1.2 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#include <math.h>
@@ -43,10 +43,12 @@
/* Allocate memory for tables */
nel = m4 - 2;
tabr[logm-4] = (double *) calloc(3 * nel, sizeof(double));
-// if ((tab[logm-4] = (double *) calloc(3 * nel, sizeof(double))) == NULL) {
-// printf("Error : RSFFT : not enough memory for cosine tables.\n");
-// error_exit();
-// }
+/*
+ if ((tab[logm-4] = (double *) calloc(3 * nel, sizeof(double))) == NULL) {
+ printf("Error : RSFFT : not enough memory for cosine tables.\n");
+ error_exit();
+ }
+*/
/* Initialize pointers */
cn = tabr[logm-4]; spcn = cn + nel; smcn = spcn + nel;
@@ -286,9 +288,11 @@
/* Allocate memory for tables */
nel = m4 - 2;
tab[logm-4] = (double *) calloc(6 * nel, sizeof(double));
-// if ((tab[logm-4] = (double *) calloc(6 * nel, sizeof(double))) == NULL) {
-// error_exit();
-// }
+/*
+ if ((tab[logm-4] = (double *) calloc(6 * nel, sizeof(double))) == NULL) {
+ error_exit();
+ }
+*/
/* Initialize pointers */
cn = tab[logm-4]; spcn = cn + nel; smcn = spcn + nel;
--- a/libfaac/filtbank.h
+++ b/libfaac/filtbank.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: filtbank.h,v 1.2 2001/01/17 15:51:15 menno Exp $
+ * $Id: filtbank.h,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifndef FILTBANK_H
@@ -66,4 +66,4 @@
}
#endif /* __cplusplus */
-#endif /* FILTBANK_H */
\ No newline at end of file
+#endif /* FILTBANK_H */
--- a/libfaac/frame.h
+++ b/libfaac/frame.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: frame.h,v 1.3 2001/01/23 13:46:18 menno Exp $
+ * $Id: frame.h,v 1.4 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifndef FRAME_H
@@ -113,7 +113,7 @@
int FAACAPI faacEncEncode(faacEncHandle hEncoder,
short *inputBuffer,
unsigned int samplesInput,
- void *outputBuffer,
+ unsigned char *outputBuffer,
unsigned int bufferSize
);
@@ -128,4 +128,4 @@
}
#endif /* __cplusplus */
-#endif /* FRAME_H */
\ No newline at end of file
+#endif /* FRAME_H */
--- a/libfaac/huffman.c
+++ b/libfaac/huffman.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: huffman.c,v 1.2 2001/01/19 14:59:23 menno Exp $
+ * $Id: huffman.c,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#include <math.h>
@@ -94,7 +94,8 @@
levels = (int) ((log((double)coderInfo->nr_of_sfb)/log((double)2.0))+1);
fraction = (pow(2,levels)+coderInfo->nr_of_sfb)/(double)(pow(2,levels));
-//#define SLOW
+/* #define SLOW */
+
#ifdef SLOW
for(i=0;i<5;i++){
hop = 1 << i;
--- a/libfaac/psych.c
+++ b/libfaac/psych.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: psych.c,v 1.4 2001/02/01 20:22:47 menno Exp $
+ * $Id: psych.c,v 1.5 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#include <stdlib.h>
@@ -603,7 +603,9 @@
/* Actual energy threshold */
psyInfo->nb[b] = NS_INTERP(min(ecb, 2*psyInfo->lastNb[b]), ecb, 1/*pcfact*/);
-// psyInfo->nb[b] = max(psyInfo->nb[b], gpsyInfo->ath[b]);
+/*
+ psyInfo->nb[b] = max(psyInfo->nb[b], gpsyInfo->ath[b]);
+*/
psyInfo->lastNb[b] = ecb;
/* Perceptual entropy */
@@ -685,7 +687,9 @@
/* Actual energy threshold */
psyInfo->nbS[j][b] = max(1e-6, ecb);
-// psyInfo->nbS[j][b] = max(psyInfo->nbS[j][b], gpsyInfo->athS[b]);
+/*
+ psyInfo->nbS[j][b] = max(psyInfo->nbS[j][b], gpsyInfo->athS[b]);
+*/
estot[j] += e[b];
}
@@ -825,7 +829,9 @@
/* Actual energy threshold */
nbM[b] = NS_INTERP(min(ecb, 2*psyInfoL->lastNbMS[b]), ecb, 1/*pcfact*/);
-// nbM[b] = max(nbM[b], gpsyInfo->ath[b]);
+/*
+ nbM[b] = max(nbM[b], gpsyInfo->ath[b]);
+*/
psyInfoL->lastNbMS[b] = ecb;
@@ -840,7 +846,9 @@
/* Actual energy threshold */
nbS[b] = NS_INTERP(min(ecb, 2*psyInfoR->lastNbMS[b]), ecb, 1/*pcfact*/);
-// nbS[b] = max(nbS[b], gpsyInfo->ath[b]);
+/*
+ nbS[b] = max(nbS[b], gpsyInfo->ath[b]);
+*/
psyInfoR->lastNbMS[b] = ecb;
if (psyInfoL->nb[b] <= 1.58*psyInfoR->nb[b]
@@ -986,9 +994,10 @@
/* Actual energy threshold */
nbM[b] = max(1e-6, ecb);
-// nbM[b] = max(nbM[b], gpsyInfo->athS[b]);
+/*
+ nbM[b] = max(nbM[b], gpsyInfo->athS[b]);
+*/
-
/* Side channel */
/* Get power ratio */
@@ -1000,7 +1009,9 @@
/* Actual energy threshold */
nbS[b] = max(1e-6, ecb);
-// nbS[b] = max(nbS[b], gpsyInfo->athS[b]);
+/*
+ nbS[b] = max(nbS[b], gpsyInfo->athS[b]);
+*/
if (psyInfoL->nbS[j][b] <= 1.58*psyInfoR->nbS[j][b]
&& psyInfoR->nbS[j][b] <= 1.58*psyInfoL->nbS[j][b]) {
--- a/libfaac/psych.h
+++ b/libfaac/psych.h
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: psych.h,v 1.2 2001/01/31 23:40:05 menno Exp $
+ * $Id: psych.h,v 1.3 2001/02/04 17:50:47 oxygene2000 Exp $
*/
#ifndef PSYCH_H
@@ -146,4 +146,4 @@
}
#endif /* __cplusplus */
-#endif /* PSYCH_H */
\ No newline at end of file
+#endif /* PSYCH_H */
--- a/libfaac/util.c
+++ b/libfaac/util.c
@@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * $Id: util.c,v 1.1 2001/01/17 11:21:40 menno Exp $
+ * $Id: util.c,v 1.2 2001/02/04 17:50:47 oxygene2000 Exp $
*/
/* Returns the sample rate index */
@@ -35,4 +35,12 @@
if (9391 <= sampleRate) return 10;
return 11;
-}
\ No newline at end of file
+}
+
+int max(a, b){
+ return (((a) > (b)) ? (a) : (b));
+}
+
+int min(a, b){
+ return (((a) < (b)) ? (a) : (b));
+}