ref: a7b9a593d6149b7f5cbe3e37fe96aa5d488475f2
parent: eb19fa58e08ffad79fe4af09abc0b5a584b4e6e6
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Jun 30 08:26:36 EDT 2020
plan 9 port, initial version
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,5 @@
libfaad/win32_ver.h
*.user
/libfaad/faad2.pc
+[a0125678vqki].out
+*.[o0125678vqki]
--- /dev/null
+++ b/config_plan9.h
@@ -1,0 +1,3 @@
+//#define DRM_SUPPORT 1
+#define HAVE_STRCHR 1
+#define HAVE_MEMCPY 1
--- a/frontend/audio.c
+++ b/frontend/audio.c
@@ -31,14 +31,21 @@
#ifdef _WIN32
#include <io.h>
#endif
+
+#ifdef __plan9__
+#include <u.h>
+#include <libc.h>
+typedef s32int int32_t;
+#else
#include <stdlib.h>
-#include <stdio.h>
#include <fcntl.h>
#include <math.h>
-#include <neaacdec.h>
#include <stdint.h>
-
+#endif
+#include <stdio.h>
#include "unicode_support.h"
+#include <neaacdec.h>
+
#include "audio.h"
--- a/frontend/getopt.c
+++ b/frontend/getopt.c
@@ -36,7 +36,9 @@
#define _NO_PROTO
#endif
+#ifndef __plan9__
#include <stdio.h>
+#endif
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -39,20 +39,25 @@
#ifndef __MINGW32__
#define off_t __int64
#endif
-#else
+#elif !defined(__plan9__)
#include <time.h>
#endif
+#ifdef __plan9__
+#include <u.h>
+#include <libc.h>
+#else
#include <fcntl.h>
-#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
+#endif
+#include <stdio.h>
+#include "unicode_support.h"
#include <neaacdec.h>
-#include "unicode_support.h"
#include "audio.h"
#include "mp4read.h"
--- /dev/null
+++ b/frontend/mkfile
@@ -1,0 +1,19 @@
+</$objtype/mkfile
+
+TARG=aacdec
+CFLAGS=$CFLAGS -p -D__plan9__
+BIN=/$objtype/bin/audio
+MAN=/sys/man/1
+
+HFILES=\
+
+OFILES=\
+ main.$O\
+ mp4read.$O\
+ audio.$O\
+
+default:V: all
+
+</sys/src/cmd/mkone
+
+install:V: $MAN/$TARG
--- a/frontend/mp4read.c
+++ b/frontend/mp4read.c
@@ -17,14 +17,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
+#ifdef __plan9__
+#include <u.h>
+#include <libc.h>
+#else
#include <stdlib.h>
-#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <limits.h>
-
+#endif
+#include <stdio.h>
#include "unicode_support.h"
+
#include "mp4read.h"
enum ATOM_TYPE
@@ -156,7 +161,11 @@
if (!(y & 3))
t -= SECSINDAY;
}
+#ifdef __plan9__
+ return ctime(t);
+#else
return ctime(&t);
+#endif
}
static int mdhdin(int size)
--- a/frontend/mp4read.h
+++ b/frontend/mp4read.h
@@ -17,7 +17,18 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
-#include <stdint.h>
+#ifdef __plan9__
+typedef u8int uint8_t;
+typedef u16int uint16_t;
+typedef u32int uint32_t;
+typedef u64int uint64_t;
+typedef s64int int64_t;
+typedef long time_t;
+typedef long clock_t;
+#define clock() (nsec()/1000000ULL)
+#define CLOCKS_PER_SEC 1000ULL
+#define INT_MAX 0x7fffffff
+#endif
typedef struct
{
--- a/frontend/unicode_support.h
+++ b/frontend/unicode_support.h
@@ -30,8 +30,6 @@
#ifndef UNICODE_SUPPORT_H_INCLUDED
#define UNICODE_SUPPORT_H_INCLUDED
-#include <stdio.h>
-
#if defined WIN32 || defined _WIN32 || defined WIN64 || defined _WIN64
char *utf16_to_utf8(const wchar_t *input);
char *utf16_to_ansi(const wchar_t *input);
--- a/include/neaacdec.h
+++ b/include/neaacdec.h
@@ -31,6 +31,8 @@
#ifndef __NEAACDEC_H__
#define __NEAACDEC_H__
+#pragma lib "libfaad.a"
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
--- a/libfaad/bits.c
+++ b/libfaad/bits.c
@@ -31,7 +31,6 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
#include "bits.h"
/* initialize buffer, call once before first getbits or showbits */
--- a/libfaad/cfft.c
+++ b/libfaad/cfft.c
@@ -40,8 +40,6 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
-
#include "cfft.h"
#include "cfft_tab.h"
--- a/libfaad/common.c
+++ b/libfaad/common.c
@@ -33,7 +33,6 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
#include "syntax.h"
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -31,6 +31,20 @@
#ifndef __COMMON_H__
#define __COMMON_H__
+#ifdef __plan9__
+#include <u.h>
+#include <libc.h>
+#define INLINE
+typedef usize size_t;
+#include "../config_plan9.h"
+#else
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -41,11 +55,13 @@
#include "neaacdec.h"
+#ifndef INLINE
#if 1
#define INLINE __inline
#else
#define INLINE inline
#endif
+#endif
#if 0 //defined(_WIN32) && !defined(_WIN32_WCE)
#define ALIGN __declspec(align(16))
@@ -85,7 +101,7 @@
/* Allow decoding of MAIN profile AAC */
#define MAIN_DEC
/* Allow decoding of SSR profile AAC */
-//#define SSR_DEC
+#define SSR_DEC
/* Allow decoding of LTP profile AAC */
#define LTP_DEC
/* Allow decoding of LD profile AAC */
@@ -369,8 +385,6 @@
# define __USE_ISOC9X 1
# define __USE_ISOC99 1
#endif
-
- #include <math.h>
#ifdef HAVE_SINF
# define sin sinf
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -30,11 +30,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
#include "mp4.h"
#include "syntax.h"
#include "error.h"
@@ -47,6 +42,7 @@
#endif
#ifdef SSR_DEC
#include "ssr.h"
+#include "ssr_fb.h"
#endif
#ifdef ANALYSIS
--- a/libfaad/drc.c
+++ b/libfaad/drc.c
@@ -31,8 +31,6 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
-#include <string.h>
#include "syntax.h"
#include "drc.h"
--- a/libfaad/drm_dec.c
+++ b/libfaad/drm_dec.c
@@ -28,10 +28,6 @@
** $Id: drm_dec.c,v 1.9 2007/11/01 12:33:30 menno Exp $
**/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <math.h>
#include "common.h"
#ifdef DRM
--- a/libfaad/filtbank.c
+++ b/libfaad/filtbank.c
@@ -31,12 +31,8 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
-#include <string.h>
#ifdef _WIN32_WCE
#define assert(x)
-#else
-#include <assert.h>
#endif
#include "filtbank.h"
--- a/libfaad/hcr.c
+++ b/libfaad/hcr.c
@@ -30,10 +30,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-#include <string.h>
-
#include "specrec.h"
#include "huffman.h"
--- a/libfaad/huffman.c
+++ b/libfaad/huffman.c
@@ -30,12 +30,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-#ifdef ANALYSIS
-#include <stdio.h>
-#endif
-
#include "bits.h"
#include "huffman.h"
#include "codebook/hcb.h"
--- a/libfaad/lt_predict.c
+++ b/libfaad/lt_predict.c
@@ -34,7 +34,6 @@
#ifdef LTP_DEC
-#include <stdlib.h>
#include "syntax.h"
#include "lt_predict.h"
#include "filtbank.h"
--- a/libfaad/mdct.c
+++ b/libfaad/mdct.c
@@ -36,7 +36,7 @@
* As described in:
* P. Duhamel, Y. Mahieux, and J.P. Petit, "A Fast Algorithm for the
* Implementation of Filter Banks Based on 'Time Domain Aliasing
- * Cancellation�," IEEE Proc. on ICASSP�91, 1991, pp. 2209-2212.
+ * Cancellation�," IEEE Proc. on ICASSP�91, 1991, pp. 2209-2212.
*
*
* As of April 6th 2002 completely rewritten.
@@ -47,11 +47,8 @@
#include "common.h"
#include "structs.h"
-#include <stdlib.h>
#ifdef _WIN32_WCE
#define assert(x)
-#else
-#include <assert.h>
#endif
#include "cfft.h"
--- /dev/null
+++ b/libfaad/mkfile
@@ -1,0 +1,53 @@
+</$objtype/mkfile
+
+</$objtype/mkfile
+LIB=/$objtype/lib/libfaad.a
+CFLAGS=$CFLAGS -I../include -DPACKAGE_VERSION="2.9.2" -p -D__plan9__
+
+HFILES=\
+ /sys/include/neaacdec.h\
+
+OFILES=\
+ bits.$O\
+ cfft.$O\
+ common.$O\
+ decoder.$O\
+ drc.$O\
+ drm_dec.$O\
+ error.$O\
+ filtbank.$O\
+ hcr.$O\
+ huffman.$O\
+ ic_predict.$O\
+ is.$O\
+ lt_predict.$O\
+ mdct.$O\
+ mp4.$O\
+ ms.$O\
+ output.$O\
+ pns.$O\
+ ps_dec.$O\
+ ps_syntax.$O\
+ pulse.$O\
+ rvlc.$O\
+ sbr_dct.$O\
+ sbr_dec.$O\
+ sbr_e_nf.$O\
+ sbr_fbt.$O\
+ sbr_hfadj.$O\
+ sbr_hfgen.$O\
+ sbr_huff.$O\
+ sbr_qmf.$O\
+ sbr_syntax.$O\
+ sbr_tf_grid.$O\
+ specrec.$O\
+ ssr.$O\
+ ssr_fb.$O\
+ ssr_ipqf.$O\
+ syntax.$O\
+ tns.$O\
+
+/sys/include/%.h:
+ cp ../include/$stem.h /sys/include/$stem.h
+
+</sys/src/cmd/mksyslib
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -30,9 +30,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-
#include "mp4.h"
#include "syntax.h"
--- a/libfaad/ps_dec.c
+++ b/libfaad/ps_dec.c
@@ -32,8 +32,6 @@
#ifdef PS_DEC
-#include <stdlib.h>
-#include <stdio.h>
#include "ps_dec.h"
#include "ps_tables.h"
--- a/libfaad/rvlc.c
+++ b/libfaad/rvlc.c
@@ -43,9 +43,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-
#include "syntax.h"
#include "bits.h"
#include "rvlc.h"
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -34,9 +34,6 @@
#ifdef SBR_DEC
-#include <string.h>
-#include <stdlib.h>
-
#include "syntax.h"
#include "bits.h"
#include "sbr_syntax.h"
--- a/libfaad/sbr_e_nf.c
+++ b/libfaad/sbr_e_nf.c
@@ -33,8 +33,6 @@
#ifdef SBR_DEC
-#include <stdlib.h>
-
#include "sbr_syntax.h"
#include "sbr_e_nf.h"
--- a/libfaad/sbr_fbt.c
+++ b/libfaad/sbr_fbt.c
@@ -35,8 +35,6 @@
#ifdef SBR_DEC
-#include <stdlib.h>
-
#include "sbr_syntax.h"
#include "sbr_fbt.h"
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -34,8 +34,6 @@
#ifdef SBR_DEC
-#include <stdlib.h>
-#include <string.h>
#include "sbr_dct.h"
#include "sbr_qmf.h"
#include "sbr_qmf_c.h"
--- a/libfaad/sbr_tf_grid.c
+++ b/libfaad/sbr_tf_grid.c
@@ -35,8 +35,6 @@
#ifdef SBR_DEC
-#include <stdlib.h>
-
#include "sbr_syntax.h"
#include "sbr_tf_grid.h"
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -38,8 +38,6 @@
#include "common.h"
#include "structs.h"
-#include <string.h>
-#include <stdlib.h>
#include "specrec.h"
#include "filtbank.h"
#include "syntax.h"
@@ -856,29 +854,29 @@
#ifdef SSR_DEC
if (hDecoder->object_type == SSR)
{
- if (hDecoder->ssr_overlap[cpe->channel] == NULL)
+ if (hDecoder->ssr_overlap[channel] == NULL)
{
- hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
+ hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
+ memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
}
- if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL)
+ if (hDecoder->ssr_overlap[paired_channel] == NULL)
{
- hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
- memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
+ hDecoder->ssr_overlap[paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
+ memset(hDecoder->ssr_overlap[paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
}
- if (hDecoder->prev_fmd[cpe->channel] == NULL)
+ if (hDecoder->prev_fmd[channel] == NULL)
{
uint16_t k;
- hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
+ hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
for (k = 0; k < 2*hDecoder->frameLength; k++)
- hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
+ hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
}
- if (hDecoder->prev_fmd[cpe->paired_channel] == NULL)
+ if (hDecoder->prev_fmd[paired_channel] == NULL)
{
uint16_t k;
- hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
+ hDecoder->prev_fmd[paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
for (k = 0; k < 2*hDecoder->frameLength; k++)
- hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
+ hDecoder->prev_fmd[paired_channel][k] = REAL_CONST(-1);
}
}
#endif
--- a/libfaad/ssr.c
+++ b/libfaad/ssr.c
@@ -37,6 +37,7 @@
#include "filtbank.h"
#include "ssr.h"
#include "ssr_fb.h"
+#include "ssr_ipqf.h"
void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence,
uint8_t window_shape, uint8_t window_shape_prev,
@@ -112,7 +113,7 @@
uint16_t frame_len16 = frame_len/16;
ssr_gc_function(ssr, &prev_fmd[band*frame_len*2 + w*frame_len*2/8],
- gc_function, window_sequence, frame_len);
+ gc_function, window_sequence, 0, frame_len);
for (i = 0; i < frame_len8*2; i++)
data[band*frame_len*2 + w*frame_len8*2+i] *= gc_function[i];
--- a/libfaad/ssr.h
+++ b/libfaad/ssr.h
@@ -50,7 +50,7 @@
uint8_t window_sequence, uint16_t frame_len);
static void ssr_gc_function(ssr_info *ssr, real_t *prev_fmd,
real_t *gc_function, uint8_t window_sequence,
- uint16_t frame_len);
+ uint8_t band, uint16_t frame_len);
#ifdef __cplusplus
--- a/libfaad/ssr_fb.c
+++ b/libfaad/ssr_fb.c
@@ -33,8 +33,9 @@
#ifdef SSR_DEC
-#include <string.h>
-#include <stdlib.h>
+// FIXME is this correct?
+#define MUL_R_C(a,b) MUL_R(a,b)
+
#include "syntax.h"
#include "filtbank.h"
#include "mdct.h"
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -34,11 +34,6 @@
#include "common.h"
#include "structs.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
#include "syntax.h"
#include "specrec.h"
#include "huffman.h"
@@ -2179,11 +2174,11 @@
return n;
case EXT_FILL_DATA:
/* fill_nibble = */ faad_getbits(ld, 4
- DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be �0000� */
+ DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be �0000� */
for (i = 0; i < count-1; i++)
{
/* fill_byte[i] = */ faad_getbits(ld, 8
- DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be �10100101� */
+ DEBUGVAR(1,88,"extension_payload(): fill_byte")); /* must be �10100101� */
}
return count;
case EXT_DATA_ELEMENT: