Commit 68d90163 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

contribs: add a52dec library

parent b5d38779
4b26fe9492f218b775fb190b76ecf06edaeb656adfe6dcbd24d0a0f86871c3ba917edb88a398eb12dccedaa1605b6f0a0be06b09f9fddd9a46e457b7dd244848 a52dec-0.7.4.tar.gz
diff -ruN liba52.orig/a52_internal.h liba52/a52_internal.h
--- liba52.orig/a52_internal.h 2002-07-28 03:52:06.000000000 +0200
+++ liba52/a52_internal.h 2008-07-23 14:03:02.000000000 +0200
@@ -1,6 +1,6 @@
/*
* a52_internal.h
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
@@ -37,24 +37,24 @@
uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */
uint8_t lfeon; /* coded lfe channel */
- sample_t clev; /* centre channel mix level */
- sample_t slev; /* surround channels mix level */
+ level_t clev; /* centre channel mix level */
+ level_t slev; /* surround channels mix level */
int output; /* type of output */
- sample_t level; /* output level */
+ level_t level; /* output level */
sample_t bias; /* output bias */
int dynrnge; /* apply dynamic range */
- sample_t dynrng; /* dynamic range */
+ level_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */
- sample_t (* dynrngcall) (sample_t range, void * dynrngdata);
+ level_t (* dynrngcall) (level_t range, void * dynrngdata);
uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */
uint8_t cplstrtmant; /* coupling channel start mantissa */
uint8_t cplendmant; /* coupling channel end mantissa */
uint32_t cplbndstrc; /* coupling band structure */
- sample_t cplco[5][18]; /* coupling coordinates */
+ level_t cplco[5][18]; /* coupling coordinates */
/* derived information */
uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
@@ -107,14 +107,79 @@
int start, int end, int fastleak, int slowleak,
expbap_t * expbap);
-int a52_downmix_init (int input, int flags, sample_t * level,
- sample_t clev, sample_t slev);
-int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
- sample_t clev, sample_t slev);
+int a52_downmix_init (int input, int flags, level_t * level,
+ level_t clev, level_t slev);
+int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+ level_t clev, level_t slev);
void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
- sample_t clev, sample_t slev);
+ level_t clev, level_t slev);
void a52_upmix (sample_t * samples, int acmod, int output);
void a52_imdct_init (uint32_t mm_accel);
void a52_imdct_256 (sample_t * data, sample_t * delay, sample_t bias);
void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias);
+
+#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
+
+#ifndef LIBA52_FIXED
+
+typedef sample_t quantizer_t;
+#define SAMPLE(x) (x)
+#define LEVEL(x) (x)
+#define MUL(a,b) ((a) * (b))
+#define MUL_L(a,b) ((a) * (b))
+#define MUL_C(a,b) ((a) * (b))
+#define DIV(a,b) ((a) / (b))
+#define BIAS(x) ((x) + bias)
+
+#else /* LIBA52_FIXED */
+
+typedef int16_t quantizer_t;
+#define SAMPLE(x) (sample_t)((x) * (1 << 30))
+#define LEVEL(x) (level_t)((x) * (1 << 26))
+
+#if 0
+#define MUL(a,b) ((int)(((int64_t)(a) * (b) + (1 << 29)) >> 30))
+#define MUL_L(a,b) ((int)(((int64_t)(a) * (b) + (1 << 25)) >> 26))
+#elif defined(CPU_COLDFIRE)
+/* loses 1 bit of accuracy */
+#define MUL(a, b) \
+({ \
+ int32_t t; \
+ asm volatile ( \
+ "mac.l %[A], %[B], %%acc0\n\t" \
+ "movclr.l %%acc0, %[t]\n\t" \
+ "asl.l #1, %[t]" \
+ : [t] "=d" (t) \
+ : [A] "r" ((a)), [B] "r" ((b))); \
+ t; \
+})
+/* loses 5 bits of accuracy */
+#define MUL_L(a, b) \
+({ \
+ int32_t t; \
+ asm volatile ( \
+ "mac.l %[A], %[B], %%acc0\n\t" \
+ "movclr.l %%acc0, %[t]\n\t" \
+ "asl.l #5, %[t]" \
+ : [t] "=d" (t) \
+ : [A] "r" ((a)), [B] "r" ((b))); \
+ t; \
+})
+#elif 1
+#define MUL(a,b) \
+({ int32_t _ta=(a), _tb=(b), _tc; \
+ _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)(((_tc >> 14))+ (((_ta >> 16)*(_tb >> 16)) << 2 )); })
+#define MUL_L(a,b) \
+({ int32_t _ta=(a), _tb=(b), _tc; \
+ _tc=(_ta & 0xffff)*(_tb >> 16)+(_ta >> 16)*(_tb & 0xffff); (int32_t)((_tc >> 10) + (((_ta >> 16)*(_tb >> 16)) << 6)); })
+#else
+#define MUL(a,b) (((a) >> 15) * ((b) >> 15))
+#define MUL_L(a,b) (((a) >> 13) * ((b) >> 13))
+#endif
+
+#define MUL_C(a,b) MUL_L (a, LEVEL (b))
+#define DIV(a,b) ((((int64_t)LEVEL (a)) << 26) / (b))
+#define BIAS(x) ((x) + (bias*0))
+
+#endif
diff -ruN liba52.orig/bit_allocate.c liba52/bit_allocate.c
--- liba52.orig/bit_allocate.c 2002-02-19 07:20:20.000000000 +0100
+++ liba52/bit_allocate.c 2008-07-23 14:03:01.000000000 +0200
@@ -1,6 +1,6 @@
/*
* bit_allocate.c
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
@@ -21,14 +21,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
+#include "config-a52.h"
#include <inttypes.h>
#include "a52.h"
#include "a52_internal.h"
-static int hthtab[3][50] = {
+static int hthtab[3][50] IDATA_ATTR = {
{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 @@
0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
};
-static int8_t baptab[305] = {
+static int8_t baptab[305] IDATA_ATTR = {
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 @@
0, 0, 0, 0 /* 148 padding elems */
};
-static int bndtab[30] = {21, 22, 23, 24, 25, 26, 27, 28, 31, 34,
+static int bndtab[30] IDATA_ATTR = {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 int8_t latab[256] IDATA_ATTR = {
-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,
@@ -231,7 +231,7 @@
int startband, endband;
startband = j;
- endband = ((bndtab-20)[i] < end) ? (bndtab-20)[i] : end;
+ endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
psd = 128 * exp[j++];
while (j < endband) {
int next, delta;
diff -ruN liba52.orig/bitstream.c liba52/bitstream.c
--- liba52.orig/bitstream.c 2002-07-28 03:52:06.000000000 +0200
+++ liba52/bitstream.c 2008-07-23 14:03:01.000000000 +0200
@@ -1,6 +1,6 @@
/*
* bitstream.c
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
+#include "config-a52.h"
#include <inttypes.h>
@@ -38,7 +38,9 @@
align = (long)buf & 3;
state->buffer_start = (uint32_t *) (buf - align);
state->bits_left = 0;
+ state->current_word = 0;
bitstream_get (state, align * 8);
+ bitstream_get_2 (state, 0); /* pretend function is used - keep gcc happy */
}
static inline void bitstream_fill_current (a52_state_t * state)
diff -ruN liba52.orig/bitstream.h liba52/bitstream.h
--- liba52.orig/bitstream.h 2002-07-28 03:52:07.000000000 +0200
+++ liba52/bitstream.h 2008-07-23 14:03:02.000000000 +0200
@@ -1,6 +1,6 @@
/*
* bitstream.h
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
@@ -21,29 +21,29 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* (stolen from the kernel) */
+//#define swab32(x) (betoh32(x))
#ifdef WORDS_BIGENDIAN
-# define swab32(x) (x)
+# define swab32(x) (x)
#else
-# if 0 && defined (__i386__)
+# if defined (__i386__)
-# define swab32(x) __i386_swab32(x)
- static inline const uint32_t __i386_swab32(uint32_t x)
- {
- __asm__("bswap %0" : "=r" (x) : "0" (x));
- return x;
- }
+# define swab32(x) __i386_swab32(x)
+ static inline const uint32_t __i386_swab32(uint32_t x)
+ {
+ __asm__("bswap %0" : "=r" (x) : "0" (x));
+ return x;
+ }
-# else
+# else
-# define swab32(x)\
+# define swab32(x)\
((((uint8_t*)&x)[0] << 24) | (((uint8_t*)&x)[1] << 16) | \
(((uint8_t*)&x)[2] << 8) | (((uint8_t*)&x)[3]))
-# endif
+# endif
#endif
void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf);
diff -ruN liba52.orig/config-a52.h liba52/config-a52.h
--- liba52.orig/config-a52.h 1970-01-01 01:00:00.000000000 +0100
+++ liba52/config-a52.h 2008-07-23 14:03:01.000000000 +0200
@@ -0,0 +1,26 @@
+#define IDATA_ATTR
+#define IBSS_ATTR
+/* a52dec profiling */
+/* #undef A52DEC_GPROF */
+
+/* Define to 1 if you have the `memalign' function. */
+/* #undef HAVE_MEMALIGN 1 */
+
+/* liba52 djbfft support */
+/* #undef LIBA52_DJBFFT */
+
+/* a52 sample precision */
+/* #undef LIBA52_DOUBLE */
+
+/* use fixed-point arithmetic */
+#define LIBA52_FIXED
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+
+/* Used in bitstream.h */
+
+#ifdef ROCKBOX_BIG_ENDIAN
+#define WORDS_BIGENDIAN 1
+#endif
+
diff -ruN liba52.orig/downmix.c liba52/downmix.c
--- liba52.orig/downmix.c 2002-01-28 06:37:54.000000000 +0100
+++ liba52/downmix.c 2008-07-23 14:03:02.000000000 +0200
@@ -1,6 +1,6 @@
/*
* downmix.c
- * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org>
+ * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
*
* This file is part of a52dec, a free ATSC A-52 stream decoder.
@@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "config.h"
+#include "config-a52.h"
#include <string.h>
#include <inttypes.h>
@@ -31,8 +31,8 @@
#define CONVERT(acmod,output) (((output) << 3) + (acmod))
-int a52_downmix_init (int input, int flags, sample_t * level,
- sample_t clev, sample_t slev)
+int a52_downmix_init (int input, int flags, level_t * level,
+ level_t clev, level_t slev)
{
static uint8_t table[11][8] = {
{A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
@@ -66,94 +66,106 @@
output = table[output][input & 7];
- if ((output == A52_STEREO) &&
- ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
+ if (output == A52_STEREO &&
+ (input == A52_DOLBY || (input == A52_3F && clev == LEVEL (LEVEL_3DB))))
output = A52_DOLBY;
- if (flags & A52_ADJUST_LEVEL)
+ if (flags & A52_ADJUST_LEVEL) {
+ level_t adjust;
+
switch (CONVERT (input & 7, output)) {
case CONVERT (A52_3F, A52_MONO):
- *level *= LEVEL_3DB / (1 + clev);
+ adjust = DIV (LEVEL_3DB, LEVEL (1) + clev);
break;
case CONVERT (A52_STEREO, A52_MONO):
case CONVERT (A52_2F2R, A52_2F1R):
case CONVERT (A52_3F2R, A52_3F1R):
level_3db:
- *level *= LEVEL_3DB;
+ adjust = LEVEL (LEVEL_3DB);
break;
case CONVERT (A52_3F2R, A52_2F1R):
- if (clev < LEVEL_PLUS3DB - 1)
+ if (clev < LEVEL (LEVEL_PLUS3DB - 1))
goto level_3db;
/* break thru */
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F1R, A52_2F1R):
case CONVERT (A52_3F1R, A52_2F2R):
case CONVERT (A52_3F2R, A52_2F2R):
- *level /= 1 + clev;
+ adjust = DIV (1, LEVEL (1) + clev);
break;
case CONVERT (A52_2F1R, A52_MONO):
- *level *= LEVEL_PLUS3DB / (2 + slev);
+ adjust = DIV (LEVEL_PLUS3DB, LEVEL (2) + slev);
break;
case CONVERT (A52_2F1R, A52_STEREO):
case CONVERT (A52_3F1R, A52_3F):
- *level /= 1 + slev * LEVEL_3DB;
+ adjust = DIV (1, LEVEL (1) + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_MONO):
- *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
+ adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + MUL_C (slev, 0.5));
break;
case CONVERT (A52_3F1R, A52_STEREO):
- *level /= 1 + clev + slev * LEVEL_3DB;
+ adjust = DIV (1, LEVEL (1) + clev + MUL_C (slev, LEVEL_3DB));
break;
case CONVERT (A52_2F2R, A52_MONO):
- *level *= LEVEL_3DB / (1 + slev);
+ adjust = DIV (LEVEL_3DB, LEVEL (1) + slev);
break;
case CONVERT (A52_2F2R, A52_STEREO):
case CONVERT (A52_3F2R, A52_3F):
- *level /= 1 + slev;
+ adjust = DIV (1, LEVEL (1) + slev);
break;
case CONVERT (A52_3F2R, A52_MONO):
- *level *= LEVEL_3DB / (1 + clev + slev);
+ adjust = DIV (LEVEL_3DB, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_3F2R, A52_STEREO):
- *level /= 1 + clev + slev;
+ adjust = DIV (1, LEVEL (1) + clev + slev);
break;
case CONVERT (A52_MONO, A52_DOLBY):
- *level *= LEVEL_PLUS3DB;
+ adjust = LEVEL (LEVEL_PLUS3DB);
break;
case CONVERT (A52_3F, A52_DOLBY):
case CONVERT (A52_2F1R, A52_DOLBY):
- *level *= 1 / (1 + LEVEL_3DB);
+ adjust = LEVEL (1 / (1 + LEVEL_3DB));
break;
case CONVERT (A52_3F1R, A52_DOLBY):
case CONVERT (A52_2F2R, A52_DOLBY):
- *level *= 1 / (1 + 2 * LEVEL_3DB);
+ adjust = LEVEL (1 / (1 + 2 * LEVEL_3DB));
break;
case CONVERT (A52_3F2R, A52_DOLBY):
- *level *= 1 / (1 + 3 * LEVEL_3DB);
+ adjust = LEVEL (1 / (1 + 3 * LEVEL_3DB));
break;
+
+ default:
+ return output;
}
+ *level = MUL_L (*level, adjust);
+ }
+
return output;
}
-int a52_downmix_coeff (sample_t * coeff, int acmod, int output, sample_t level,
- sample_t clev, sample_t slev)
+int a52_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
+ level_t clev, level_t slev)
{
+ level_t level_3db;
+
+ level_3db = MUL_C (level, LEVEL_3DB);
+
switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
case CONVERT (A52_CHANNEL, A52_CHANNEL):
@@ -169,120 +181,138 @@
return 0;
case CONVERT (A52_CHANNEL, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_6DB;
+ coeff[0] = coeff[1] = MUL_C (level, LEVEL_6DB);
return 3;
case CONVERT (A52_STEREO, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
+ coeff[0] = coeff[1] = level_3db;
return 3;
case CONVERT (A52_3F, A52_MONO):
- coeff[0] = coeff[2] = level * LEVEL_3DB;
- coeff[1] = level * clev * LEVEL_PLUS3DB;
+ coeff[0] = coeff[2] = level_3db;
+ coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
return 7;
case CONVERT (A52_2F1R, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
- coeff[2] = level * slev * LEVEL_3DB;
+ coeff[0] = coeff[1] = level_3db;
+ coeff[2] = MUL_L (level_3db, slev);
return 7;
case CONVERT (A52_2F2R, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
- coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
+ coeff[0] = coeff[1] = level_3db;
+ coeff[2] = coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_3F1R, A52_MONO):
- coeff[0] = coeff[2] = level * LEVEL_3DB;
- coeff[1] = level * clev * LEVEL_PLUS3DB;
- coeff[3] = level * slev * LEVEL_3DB;
+ coeff[0] = coeff[2] = level_3db;
+ coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
+ coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_3F2R, A52_MONO):
- coeff[0] = coeff[2] = level * LEVEL_3DB;
- coeff[1] = level * clev * LEVEL_PLUS3DB;
- coeff[3] = coeff[4] = level * slev * LEVEL_3DB;
+ coeff[0] = coeff[2] = level_3db;
+ coeff[1] = MUL_C (MUL_L (level_3db, clev), LEVEL_PLUS6DB);
+ coeff[3] = coeff[4] = MUL_L (level_3db, slev);
return 31;
case CONVERT (A52_MONO, A52_DOLBY):
- coeff[0] = level * LEVEL_3DB;
+ coeff[0] = level_3db;
return 0;
case CONVERT (A52_3F, A52_DOLBY):
- clev = LEVEL_3DB;
+ coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
+ coeff[1] = level_3db;
+ return 7;
+
case CONVERT (A52_3F, A52_STEREO):
case CONVERT (A52_3F1R, A52_2F1R):
case CONVERT (A52_3F2R, A52_2F2R):
coeff[0] = coeff[2] = coeff[3] = coeff[4] = level;
- coeff[1] = level * clev;
+ coeff[1] = MUL_L (level, clev);
return 7;
case CONVERT (A52_2F1R, A52_DOLBY):
- slev = 1;
+ coeff[0] = coeff[1] = level;
+ coeff[2] = level_3db;
+ return 7;
+
case CONVERT (A52_2F1R, A52_STEREO):
coeff[0] = coeff[1] = level;
- coeff[2] = level * slev * LEVEL_3DB;
+ coeff[2] = MUL_L (level_3db, slev);
return 7;
case CONVERT (A52_3F1R, A52_DOLBY):
- clev = LEVEL_3DB;
- slev = 1;
+ coeff[0] = coeff[2] = level;
+ coeff[1] = coeff[3] = level_3db;
+ return 15;
+
case CONVERT (A52_3F1R, A52_STEREO):
coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = level * slev * LEVEL_3DB;
+ coeff[1] = MUL_L (level, clev);
+ coeff[3] = MUL_L (level_3db, slev);
return 15;
case CONVERT (A52_2F2R, A52_DOLBY):
- slev = LEVEL_3DB;
+ coeff[0] = coeff[1] = level;
+ coeff[2] = coeff[3] = level_3db;
+ return 15;
+
case CONVERT (A52_2F2R, A52_STEREO):
coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level * slev;
+ coeff[2] = coeff[3] = MUL_L (level, slev);
return 15;
case CONVERT (A52_3F2R, A52_DOLBY):
- clev = LEVEL_3DB;
+ coeff[0] = coeff[2] = level;
+ coeff[1] = coeff[3] = coeff[4] = level_3db;
+ return 31;
+
case CONVERT (A52_3F2R, A52_2F1R):
- slev = LEVEL_3DB;
+ coeff[0] = coeff[2] = level;
+ coeff[1] = MUL_L (level, clev);
+ coeff[3] = coeff[4] = level_3db;
+ return 31;
+
case CONVERT (A52_3F2R, A52_STEREO):
coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = coeff[4] = level * slev;
+ coeff[1] = MUL_L (level, clev);
+ coeff[3] = coeff[4] = MUL_L (level, slev);
return 31;
case CONVERT (A52_3F1R, A52_3F):
coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = level * slev * LEVEL_3DB;
+ coeff[3] = MUL_L (level_3db, slev);
return 13;
case CONVERT (A52_3F2R, A52_3F):
coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = level * slev;
+ coeff[3] = coeff[4] = MUL_L (level, slev);
return 29;
case CONVERT (A52_2F2R, A52_2F1R):
coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level * LEVEL_3DB;
+ coeff[2] = coeff[3] = level_3db;
return 12;
case CONVERT (A52_3F2R, A52_3F1R):
coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = level * LEVEL_3DB;
+ coeff[3] = coeff[4] = level_3db;
return 24;
case CONVERT (A52_2F1R, A52_2F2R):
coeff[0] = coeff[1] = level;
- coeff[2] = level * LEVEL_3DB;
+ coeff[2] = level_3db;
return 0;
case CONVERT (A52_3F1R, A52_2F2R):
coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = level * LEVEL_3DB;
+ coeff[1] = MUL_L (level, clev);
+ coeff[3] = level_3db;
return 7;
case CONVERT (A52_3F1R, A52_3F2R):
coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = level * LEVEL_3DB;
+ coeff[3] = level_3db;
return 0;
case CONVERT (A52_CHANNEL, A52_CHANNEL1):
@@ -304,7 +334,7 @@
int i;
for (i = 0; i < 256; i++)
- dest[i] += src[i] + bias;
+ dest[i] += BIAS (src[i]);
}
static void mix3to1 (sample_t * samples, sample_t bias)
@@ -312,7 +342,7 @@
int i;