123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- Index: a52dec-0.7.4/liba52/bit_allocate.c
- ===================================================================
- --- a52dec-0.7.4.orig/liba52/bit_allocate.c
- +++ a52dec-0.7.4/liba52/bit_allocate.c
- @@ -28,7 +28,7 @@
- #include "a52.h"
- #include "a52_internal.h"
-
- -static int hthtab[3][50] = {
- +static const int hthtab[3][50] = {
- {0x730, 0x730, 0x7c0, 0x800, 0x820, 0x840, 0x850, 0x850, 0x860, 0x860,
- 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x890, 0x890,
- 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900,
- @@ -46,7 +46,7 @@ static int hthtab[3][50] = {
- 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
- };
-
- -static int8_t baptab[305] = {
- +static const int8_t baptab[305] = {
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- @@ -71,11 +71,11 @@ static int8_t baptab[305] = {
- 0, 0, 0, 0 /* 148 padding elems */
- };
-
- -static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
- +static const int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
- 37, 40, 43, 46, 49, 55, 61, 67, 73, 79,
- 85, 97, 109, 121, 133, 157, 181, 205, 229, 253};
-
- -static int8_t latab[256] = {
- +static const int8_t latab[256] = {
- -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53,
- -52, -52, -51, -50, -49, -48, -47, -47, -46, -45, -44, -44,
- -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -36, -35,
- @@ -125,9 +125,9 @@ void a52_bit_allocate (a52_state_t * sta
- int start, int end, int fastleak, int slowleak,
- expbap_t * expbap)
- {
- - static int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
- - static int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
- - static int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
- + static const int slowgain[4] = {0x540, 0x4d8, 0x478, 0x410};
- + static const int dbpbtab[4] = {0xc00, 0x500, 0x300, 0x100};
- + static const int floortab[8] = {0x910, 0x950, 0x990, 0x9d0,
- 0xa10, 0xa90, 0xb10, 0x1400};
-
- int i, j;
- @@ -135,8 +135,8 @@ void a52_bit_allocate (a52_state_t * sta
- int8_t * bap;
- int fdecay, fgain, sdecay, sgain, dbknee, floor, snroffset;
- int psd, mask;
- - int8_t * deltba;
- - int * hth;
- + const int8_t * deltba;
- + const int * hth;
- int halfrate;
-
- halfrate = state->halfrate;
- Index: a52dec-0.7.4/liba52/imdct.c
- ===================================================================
- --- a52dec-0.7.4.orig/liba52/imdct.c
- +++ a52dec-0.7.4/liba52/imdct.c
- @@ -56,6 +56,7 @@ static uint8_t fftorder[] = {
- 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86
- };
-
- +#ifndef HARDCODED_TABLES
- /* Root values for IFFT */
- static sample_t roots16[3];
- static sample_t roots32[7];
- @@ -69,6 +70,13 @@ static complex_t pre2[64];
- static complex_t post2[32];
-
- static sample_t a52_imdct_window[256];
- +#else
- +# ifdef LIBA52_DOUBLE
- +# include "imdct_tables_double.h"
- +# else
- +# include "imdct_tables_float.h"
- +# endif
- +#endif
-
- static void (* ifft128) (complex_t * buf);
- static void (* ifft64) (complex_t * buf);
- @@ -178,7 +186,7 @@ static inline void ifft8 (complex_t * bu
- BUTTERFLY_HALF (buf[1], buf[3], buf[5], buf[7], roots16[1]);
- }
-
- -static void ifft_pass (complex_t * buf, sample_t * weight, int n)
- +static void ifft_pass (complex_t * buf, const sample_t * weight, int n)
- {
- complex_t * buf1;
- complex_t * buf2;
- @@ -351,6 +359,7 @@ void a52_imdct_256(sample_t * data, samp
- }
- }
-
- +#ifndef HARDCODED_TABLES
- static double besselI0 (double x)
- {
- double bessel = 1;
- @@ -361,9 +370,11 @@ static double besselI0 (double x)
- while (--i);
- return bessel;
- }
- +#endif
-
- void a52_imdct_init (uint32_t mm_accel)
- {
- +#ifndef HARDCODED_TABLES
- int i, k;
- double sum;
-
- @@ -416,6 +427,7 @@ void a52_imdct_init (uint32_t mm_accel)
- post2[i].real = cos ((M_PI / 128) * (i + 0.5));
- post2[i].imag = sin ((M_PI / 128) * (i + 0.5));
- }
- +#endif
-
- #ifdef LIBA52_DJBFFT
- if (mm_accel & MM_ACCEL_DJBFFT) {
- Index: a52dec-0.7.4/liba52/imdct-gentables.c
- ===================================================================
- --- /dev/null
- +++ a52dec-0.7.4/liba52/imdct-gentables.c
- @@ -0,0 +1,139 @@
- +#include <stdint.h>
- +#include <stdio.h>
- +#include <math.h>
- +
- +#ifndef LIBA52_DOUBLE
- +typedef float sample_t;
- +#else
- +typedef double sample_t;
- +#endif
- +
- +typedef struct complex_s {
- + sample_t real;
- + sample_t imag;
- +} complex_t;
- +
- +static uint8_t fftorder[] = {
- + 0,128, 64,192, 32,160,224, 96, 16,144, 80,208,240,112, 48,176,
- + 8,136, 72,200, 40,168,232,104,248,120, 56,184, 24,152,216, 88,
- + 4,132, 68,196, 36,164,228,100, 20,148, 84,212,244,116, 52,180,
- + 252,124, 60,188, 28,156,220, 92, 12,140, 76,204,236,108, 44,172,
- + 2,130, 66,194, 34,162,226, 98, 18,146, 82,210,242,114, 50,178,
- + 10,138, 74,202, 42,170,234,106,250,122, 58,186, 26,154,218, 90,
- + 254,126, 62,190, 30,158,222, 94, 14,142, 78,206,238,110, 46,174,
- + 6,134, 70,198, 38,166,230,102,246,118, 54,182, 22,150,214, 86
- +};
- +
- +/* Root values for IFFT */
- +static sample_t roots16[3];
- +static sample_t roots32[7];
- +static sample_t roots64[15];
- +static sample_t roots128[31];
- +
- +/* Twiddle factors for IMDCT */
- +static complex_t pre1[128];
- +static complex_t post1[64];
- +static complex_t pre2[64];
- +static complex_t post2[32];
- +
- +static sample_t a52_imdct_window[256];
- +
- +static double besselI0 (double x)
- +{
- + double bessel = 1;
- + int i = 100;
- +
- + do
- + bessel = bessel * x / (i * i) + 1;
- + while (--i);
- + return bessel;
- +}
- +
- +int main() {
- + int i, k;
- + double sum;
- +
- + /* compute imdct window - kaiser-bessel derived window, alpha = 5.0 */
- + sum = 0;
- + for (i = 0; i < 256; i++) {
- + sum += besselI0 (i * (256 - i) * (5 * M_PI / 256) * (5 * M_PI / 256));
- + a52_imdct_window[i] = sum;
- + }
- + sum++;
- + for (i = 0; i < 256; i++)
- + a52_imdct_window[i] = sqrt (a52_imdct_window[i] / sum);
- +
- + for (i = 0; i < 3; i++)
- + roots16[i] = cos ((M_PI / 8) * (i + 1));
- +
- + for (i = 0; i < 7; i++)
- + roots32[i] = cos ((M_PI / 16) * (i + 1));
- +
- + for (i = 0; i < 15; i++)
- + roots64[i] = cos ((M_PI / 32) * (i + 1));
- +
- + for (i = 0; i < 31; i++)
- + roots128[i] = cos ((M_PI / 64) * (i + 1));
- +
- + for (i = 0; i < 64; i++) {
- + k = fftorder[i] / 2 + 64;
- + pre1[i].real = cos ((M_PI / 256) * (k - 0.25));
- + pre1[i].imag = sin ((M_PI / 256) * (k - 0.25));
- + }
- +
- + for (i = 64; i < 128; i++) {
- + k = fftorder[i] / 2 + 64;
- + pre1[i].real = -cos ((M_PI / 256) * (k - 0.25));
- + pre1[i].imag = -sin ((M_PI / 256) * (k - 0.25));
- + }
- +
- + for (i = 0; i < 64; i++) {
- + post1[i].real = cos ((M_PI / 256) * (i + 0.5));
- + post1[i].imag = sin ((M_PI / 256) * (i + 0.5));
- + }
- +
- + for (i = 0; i < 64; i++) {
- + k = fftorder[i] / 4;
- + pre2[i].real = cos ((M_PI / 128) * (k - 0.25));
- + pre2[i].imag = sin ((M_PI / 128) * (k - 0.25));
- + }
- +
- + for (i = 0; i < 32; i++) {
- + post2[i].real = cos ((M_PI / 128) * (i + 0.5));
- + post2[i].imag = sin ((M_PI / 128) * (i + 0.5));
- + }
- +
- +#define print_table_samples(name, size) \
- + do { \
- + int i; \
- + printf("static const sample_t " #name "[" #size "] = {\n"); \
- + for(i = 0; i < size; i++) { \
- + printf(" %a%s\n", name[i], i < size-1 ? ", " : ""); \
- + } \
- + printf("\n};\n\n"); \
- + } while(0);
- +
- +#define print_table_complex(name, size) \
- + do { \
- + int i; \
- + printf("static const complex_t " #name "[" #size "] = {\n"); \
- + for(i = 0; i < size; i++) { \
- + printf(" { %a, %a }%s\n", name[i].real, name[i].imag, i < size-1 ? ", " : ""); \
- + } \
- + printf("\n};\n\n"); \
- + } while(0);
- +
- + print_table_samples(roots16, 3);
- + print_table_samples(roots32, 7);
- + print_table_samples(roots64, 15);
- + print_table_samples(roots128, 31);
- +
- + print_table_complex(pre1, 128);
- + print_table_complex(post1, 64);
- + print_table_complex(pre2, 64);
- + print_table_complex(post2, 32);
- +
- + print_table_samples(a52_imdct_window, 256);
- +
- + return 0;
- +}
- Index: a52dec-0.7.4/liba52/Makefile.am
- ===================================================================
- --- a52dec-0.7.4.orig/liba52/Makefile.am
- +++ a52dec-0.7.4/liba52/Makefile.am
- @@ -2,8 +2,26 @@ CFLAGS = @CFLAGS@ @LIBA52_CFLAGS@
-
- lib_LTLIBRARIES = liba52.la
-
- -liba52_la_SOURCES = bitstream.c imdct.c bit_allocate.c parse.c downmix.c
- +liba52_la_SOURCES = bitstream.c imdct.c bit_allocate.c parse.c downmix.c imdct_tables_double.h imdct_tables_float.h
- liba52_la_LIBADD = @LIBA52_LIBS@ -lm
- liba52_la_LDFLAGS = -no-undefined
-
- +noinst_PROGRAMS = imdct-gentables-double imdct-gentables-float
- +
- +imdct_gentables_double_SOURCES = imdct-gentables.c
- +imdct_gentables_double_CFLAGS = $(CFLAGS) -DLIBA52_DOUBLE
- +imdct_gentables_double_LDADD = -lm
- +
- +imdct_gentables_float_SOURCES = imdct-gentables.c
- +imdct_gentables_float_CFLAGS = $(CFLAGS) -ULIBA52_DOUBLE
- +imdct_gentables_float_LDADD = -lm
- +
- +imdct_tables_double.h: imdct-gentables-double
- + ./$^ > $@
- +
- +imdct_tables_float.h: imdct-gentables-float
- + ./$^ > $@
- +
- +imdct.c: imdct_tables_double.h imdct_tables_float.h
- +
- EXTRA_DIST = configure.incl a52_internal.h bitstream.h tables.h
|