diff options
author | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
---|---|---|
committer | XhmikosR <xhmikosr@users.sourceforge.net> | 2010-04-09 18:12:59 +0400 |
commit | efbc9d9043ff8ff92716ddd00a5f61412d535593 (patch) | |
tree | 8f3e621f756cf1f5b4d64d97964c7e7abd8aaf08 /src/filters/transform/MpaDecFilter/a52dec | |
parent | df6b139a6d9027156f614b68687e039e3a5854db (diff) |
revert r1783
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1785 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/transform/MpaDecFilter/a52dec')
9 files changed, 1626 insertions, 1823 deletions
diff --git a/src/filters/transform/MpaDecFilter/a52dec/include/a52.h b/src/filters/transform/MpaDecFilter/a52dec/include/a52.h index 5be0879c3..7701ef9ca 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/include/a52.h +++ b/src/filters/transform/MpaDecFilter/a52dec/include/a52.h @@ -31,12 +31,12 @@ extern "C" { # endif
#ifndef LIBA52_DOUBLE
- typedef float sample_t;
+typedef float sample_t;
#else
- typedef double sample_t;
+typedef double sample_t;
#endif
- typedef struct a52_state_s a52_state_t;
+typedef struct a52_state_s a52_state_t;
#define A52_CHANNEL 0
#define A52_MONO 1
@@ -54,16 +54,16 @@ extern "C" { #define A52_LFE 16
#define A52_ADJUST_LEVEL 32
- a52_state_t * a52_init(uint32_t mm_accel);
- sample_t * a52_samples(a52_state_t * state);
- int a52_syncinfo(uint8_t * buf, int * flags,
- int * sample_rate, int * bit_rate);
- int a52_frame(a52_state_t * state, uint8_t * buf, int * flags,
- sample_t * level, sample_t bias);
- void a52_dynrng(a52_state_t * state,
- sample_t (* call)(sample_t, void *), void * data);
- int a52_block(a52_state_t * state);
- void a52_free(a52_state_t * state);
+a52_state_t * a52_init (uint32_t mm_accel);
+sample_t * a52_samples (a52_state_t * state);
+int a52_syncinfo (uint8_t * buf, int * flags,
+ int * sample_rate, int * bit_rate);
+int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
+ sample_t * level, sample_t bias);
+void a52_dynrng (a52_state_t * state,
+ sample_t (* call) (sample_t, void *), void * data);
+int a52_block (a52_state_t * state);
+void a52_free (a52_state_t * state);
# ifdef __cplusplus
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/a52_internal.h b/src/filters/transform/MpaDecFilter/a52dec/liba52/a52_internal.h index 2e8b7ce65..50d01b83f 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/a52_internal.h +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/a52_internal.h @@ -21,21 +21,18 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-typedef struct
-{
+typedef struct {
uint8_t bai; /* fine SNR offset, fast gain */
uint8_t deltbae; /* delta bit allocation exists */
int8_t deltba[50]; /* per-band delta bit allocation */
} ba_t;
-typedef struct
-{
+typedef struct {
uint8_t exp[256]; /* decoded channel exponents */
int8_t bap[256]; /* derived channel bit allocation */
} expbap_t;
-struct a52_state_s
-{
+struct a52_state_s {
uint8_t fscod; /* sample rate */
uint8_t halfrate; /* halfrate factor */
uint8_t acmod; /* coded channels */
@@ -50,7 +47,7 @@ struct a52_state_s int dynrnge; /* apply dynamic range */
sample_t dynrng; /* dynamic range */
void * dynrngdata; /* dynamic range callback funtion and data */
- sample_t (* dynrngcall)(sample_t range, void * dynrngdata);
+ sample_t (* dynrngcall) (sample_t range, void * dynrngdata);
uint8_t chincpl; /* channel coupled */
uint8_t phsflginu; /* phase flags in use (stereo only) */
@@ -106,18 +103,18 @@ struct a52_state_s #define DELTA_BIT_NONE (2)
#define DELTA_BIT_RESERVED (3)
-void a52_bit_allocate(a52_state_t * state, ba_t * ba, int bndstart,
- 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);
-void a52_downmix(sample_t * samples, int acmod, int output, sample_t bias,
- sample_t clev, sample_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);
+void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
+ 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);
+void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+ sample_t clev, sample_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);
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/bit_allocate.c b/src/filters/transform/MpaDecFilter/a52dec/liba52/bit_allocate.c index f321c673f..564eb2492 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/bit_allocate.c +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/bit_allocate.c @@ -28,33 +28,25 @@ #include "a52.h"
#include "a52_internal.h"
-static 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,
- 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0,
- 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0
- },
- {
- 0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860,
- 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880,
- 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0,
- 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820,
- 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0
- },
- {
- 0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850,
- 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860,
- 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0,
- 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0,
- 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720
- }
+static 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,
+ 0x910, 0x910, 0x910, 0x910, 0x900, 0x8f0, 0x8c0, 0x870, 0x820, 0x7e0,
+ 0x7a0, 0x770, 0x760, 0x7a0, 0x7c0, 0x7c0, 0x6e0, 0x400, 0x3c0, 0x3c0},
+ {0x710, 0x710, 0x7a0, 0x7f0, 0x820, 0x830, 0x840, 0x850, 0x850, 0x860,
+ 0x860, 0x860, 0x860, 0x860, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880,
+ 0x890, 0x890, 0x8a0, 0x8a0, 0x8b0, 0x8b0, 0x8c0, 0x8c0, 0x8e0, 0x8f0,
+ 0x900, 0x910, 0x910, 0x910, 0x910, 0x900, 0x8e0, 0x8b0, 0x870, 0x820,
+ 0x7e0, 0x7b0, 0x760, 0x770, 0x7a0, 0x7c0, 0x780, 0x5d0, 0x3c0, 0x3c0},
+ {0x680, 0x680, 0x750, 0x7b0, 0x7e0, 0x810, 0x820, 0x830, 0x840, 0x850,
+ 0x850, 0x850, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860, 0x860,
+ 0x870, 0x870, 0x870, 0x870, 0x880, 0x880, 0x880, 0x890, 0x8a0, 0x8b0,
+ 0x8c0, 0x8d0, 0x8e0, 0x8f0, 0x900, 0x910, 0x910, 0x910, 0x900, 0x8f0,
+ 0x8d0, 0x8b0, 0x840, 0x7f0, 0x790, 0x760, 0x7a0, 0x7c0, 0x7b0, 0x720}
};
-static int8_t baptab[305] =
-{
+static 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,
@@ -64,28 +56,26 @@ static int8_t baptab[305] = 16, 16, 16, 16, 16, 16, 16, 16, 16, 14, 14, 14, 14, 14, 14, 14,
14, 12, 12, 12, 12, 11, 11, 11, 11, 10, 10, 10, 10, 9, 9, 9,
- 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5,
- 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0,
+ 9, 8, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5,
+ 5, 4, 4, -3, -3, 3, 3, 3, -2, -2, -1, -1, -1, -1, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0 /* 148 padding elems */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0 /* 148 padding elems */
};
static 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
- };
+ 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] = {
-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,
@@ -95,19 +85,19 @@ static int8_t latab[256] = -17, -17, -17, -16, -16, -16, -15, -15, -15, -14, -14, -14,
-13, -13, -13, -13, -12, -12, -12, -12, -11, -11, -11, -11,
-10, -10, -10, -10, -10, -9, -9, -9, -9, -9, -8, -8,
- -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6,
- -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5,
- -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
+ -8, -8, -8, -8, -7, -7, -7, -7, -7, -7, -6, -6,
+ -6, -6, -6, -6, -6, -6, -5, -5, -5, -5, -5, -5,
+ -5, -5, -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
+ -4, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
+ -3, -3, -3, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0
};
#define UPDATE_LEAK() \
@@ -131,15 +121,14 @@ do { \ mask -= floor; \
} while (0)
-void a52_bit_allocate(a52_state_t * state, ba_t * ba, int bndstart,
- int start, int end, int fastleak, int slowleak,
- expbap_t * expbap)
+void a52_bit_allocate (a52_state_t * state, ba_t * ba, int bndstart,
+ 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,
- 0xa10, 0xa90, 0xb10, 0x1400
- };
+ 0xa10, 0xa90, 0xb10, 0x1400};
int i, j;
uint8_t * exp;
@@ -171,125 +160,106 @@ void a52_bit_allocate(a52_state_t * state, ba_t * ba, int bndstart, i = bndstart;
j = start;
- if(start == 0) /* not the coupling channel */
- {
- int lowcomp;
+ if (start == 0) { /* not the coupling channel */
+ int lowcomp;
- lowcomp = 0;
- j = end - 1;
- do
- {
- if(i < j)
- {
- if(exp[i+1] == exp[i] - 2)
- lowcomp = 384;
- else if(lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- }
- psd = 128 * exp[i];
- mask = psd + fgain + lowcomp;
- COMPUTE_MASK();
- bap[i] = (baptab + 156)[mask + 4 * exp[i]];
- i++;
- }
- while((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
- fastleak = psd + fgain;
- slowleak = psd + sgain;
+ lowcomp = 0;
+ j = end - 1;
+ do {
+ if (i < j) {
+ if (exp[i+1] == exp[i] - 2)
+ lowcomp = 384;
+ else if (lowcomp && (exp[i+1] > exp[i]))
+ lowcomp -= 64;
+ }
+ psd = 128 * exp[i];
+ mask = psd + fgain + lowcomp;
+ COMPUTE_MASK ();
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
+ } while ((i < 3) || ((i < 7) && (exp[i] > exp[i-1])));
+ fastleak = psd + fgain;
+ slowleak = psd + sgain;
- while(i < 7)
- {
- if(i < j)
- {
- if(exp[i+1] == exp[i] - 2)
- lowcomp = 384;
- else if(lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- }
- psd = 128 * exp[i];
- UPDATE_LEAK();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK();
- bap[i] = (baptab + 156)[mask + 4 * exp[i]];
- i++;
- }
+ while (i < 7) {
+ if (i < j) {
+ if (exp[i+1] == exp[i] - 2)
+ lowcomp = 384;
+ else if (lowcomp && (exp[i+1] > exp[i]))
+ lowcomp -= 64;
+ }
+ psd = 128 * exp[i];
+ UPDATE_LEAK ();
+ mask = ((fastleak + lowcomp < slowleak) ?
+ fastleak + lowcomp : slowleak);
+ COMPUTE_MASK ();
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
+ }
- if(end == 7) /* lfe channel */
- return;
+ if (end == 7) /* lfe channel */
+ return;
- do
- {
- if(exp[i+1] == exp[i] - 2)
- lowcomp = 320;
- else if(lowcomp && (exp[i+1] > exp[i]))
- lowcomp -= 64;
- psd = 128 * exp[i];
- UPDATE_LEAK();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK();
- bap[i] = (baptab + 156)[mask + 4 * exp[i]];
- i++;
- }
- while(i < 20);
+ do {
+ if (exp[i+1] == exp[i] - 2)
+ lowcomp = 320;
+ else if (lowcomp && (exp[i+1] > exp[i]))
+ lowcomp -= 64;
+ psd = 128 * exp[i];
+ UPDATE_LEAK ();
+ mask = ((fastleak + lowcomp < slowleak) ?
+ fastleak + lowcomp : slowleak);
+ COMPUTE_MASK ();
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
+ } while (i < 20);
- while(lowcomp > 128) /* two iterations maximum */
- {
- lowcomp -= 128;
- psd = 128 * exp[i];
- UPDATE_LEAK();
- mask = ((fastleak + lowcomp < slowleak) ?
- fastleak + lowcomp : slowleak);
- COMPUTE_MASK();
- bap[i] = (baptab + 156)[mask + 4 * exp[i]];
- i++;
- }
- j = i;
+ while (lowcomp > 128) { /* two iterations maximum */
+ lowcomp -= 128;
+ psd = 128 * exp[i];
+ UPDATE_LEAK ();
+ mask = ((fastleak + lowcomp < slowleak) ?
+ fastleak + lowcomp : slowleak);
+ COMPUTE_MASK ();
+ bap[i] = (baptab+156)[mask + 4 * exp[i]];
+ i++;
+ }
+ j = i;
}
- do
- {
- int startband, endband;
+ do {
+ int startband, endband;
- startband = j;
- endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
- psd = 128 * exp[j++];
- while(j < endband)
- {
- int next, delta;
+ startband = j;
+ endband = (bndtab[i-20] < end) ? bndtab[i-20] : end;
+ psd = 128 * exp[j++];
+ while (j < endband) {
+ int next, delta;
- next = 128 * exp[j++];
- delta = next - psd;
- switch(delta >> 9)
- {
- case -6:
- case -5:
- case -4:
- case -3:
- case -2:
- psd = next;
- break;
- case -1:
- psd = next + latab[(-delta) >> 1];
- break;
- case 0:
- psd += latab[delta >> 1];
- break;
- }
- }
- /* minpsd = -289 */
- UPDATE_LEAK();
- mask = (fastleak < slowleak) ? fastleak : slowleak;
- COMPUTE_MASK();
- i++;
- j = startband;
- do
- {
- /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
- /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
- bap[j] = (baptab + 156)[mask + 4 * exp[j]];
- }
- while(++j < endband);
- }
- while(j < end);
+ next = 128 * exp[j++];
+ delta = next - psd;
+ switch (delta >> 9) {
+ case -6: case -5: case -4: case -3: case -2:
+ psd = next;
+ break;
+ case -1:
+ psd = next + latab[(-delta) >> 1];
+ break;
+ case 0:
+ psd += latab[delta >> 1];
+ break;
+ }
+ }
+ /* minpsd = -289 */
+ UPDATE_LEAK ();
+ mask = (fastleak < slowleak) ? fastleak : slowleak;
+ COMPUTE_MASK ();
+ i++;
+ j = startband;
+ do {
+ /* max(mask+4*exp)=147=-(minpsd+fgain-deltba-snroffset)>>5+4*exp */
+ /* min(mask+4*exp)=-156=-(sgain-deltba-snroffset)>>5 */
+ bap[j] = (baptab+156)[mask + 4 * exp[j]];
+ } while (++j < endband);
+ } while (j < end);
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.c b/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.c index 6b3dc8ff5..6b1becb7b 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.c +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.c @@ -31,24 +31,24 @@ #define BUFFER_SIZE 4096
-void a52_bitstream_set_ptr(a52_state_t * state, uint8_t * buf)
+void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf)
{
int align;
align = (long)buf & 3;
- state->buffer_start = (uint32_t *)(buf - align);
+ 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 */
+ 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)
+static inline void bitstream_fill_current (a52_state_t * state)
{
uint32_t tmp;
tmp = *(state->buffer_start++);
- state->current_word = swab32(tmp);
+ state->current_word = swab32 (tmp);
}
/*
@@ -60,43 +60,43 @@ static inline void bitstream_fill_current(a52_state_t * state) * -ah
*/
-uint32_t a52_bitstream_get_bh(a52_state_t * state, uint32_t num_bits)
+uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits)
{
uint32_t result = 0;
- if(state->bits_left)
+ if (state->bits_left)
{
- num_bits -= state->bits_left;
- result = ((state->current_word << (32 - state->bits_left)) >>
- (32 - state->bits_left));
+ num_bits -= state->bits_left;
+ result = ((state->current_word << (32 - state->bits_left)) >>
+ (32 - state->bits_left));
}
- bitstream_fill_current(state);
+ bitstream_fill_current (state);
- if(num_bits != 0)
- result = (result << num_bits) | (state->current_word >> (32 - num_bits));
+ if (num_bits != 0)
+ result = (result << num_bits) | (state->current_word >> (32 - num_bits));
state->bits_left = 32 - num_bits;
return result;
}
-int32_t a52_bitstream_get_bh_2(a52_state_t * state, uint32_t num_bits)
+int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits)
{
int32_t result = 0;
- if(state->bits_left)
+ if (state->bits_left)
{
- num_bits -= state->bits_left;
- result = ((((int32_t)state->current_word) << (32 - state->bits_left))
- >> (32 - state->bits_left));
+ num_bits -= state->bits_left;
+ result = ((((int32_t)state->current_word) << (32 - state->bits_left))
+ >> (32 - state->bits_left));
}
bitstream_fill_current(state);
- if(num_bits != 0)
- result = (result << num_bits) | (state->current_word >> (32 - num_bits));
-
+ if (num_bits != 0)
+ result = (result << num_bits) | (state->current_word >> (32 - num_bits));
+
state->bits_left = 32 - num_bits;
return result;
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.h b/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.h index 88c748c95..0d28e19f4 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.h +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/bitstream.h @@ -31,11 +31,11 @@ # if 0 && 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;
-}
+ static inline const uint32_t __i386_swab32(uint32_t x)
+ {
+ __asm__("bswap %0" : "=r" (x) : "0" (x));
+ return x;
+ }
# else
@@ -46,34 +46,32 @@ static inline const uint32_t __i386_swab32(uint32_t x) # endif
#endif
-void a52_bitstream_set_ptr(a52_state_t * state, uint8_t * buf);
-uint32_t a52_bitstream_get_bh(a52_state_t * state, uint32_t num_bits);
-int32_t a52_bitstream_get_bh_2(a52_state_t * state, uint32_t num_bits);
+void a52_bitstream_set_ptr (a52_state_t * state, uint8_t * buf);
+uint32_t a52_bitstream_get_bh (a52_state_t * state, uint32_t num_bits);
+int32_t a52_bitstream_get_bh_2 (a52_state_t * state, uint32_t num_bits);
-static inline uint32_t bitstream_get(a52_state_t * state, uint32_t num_bits)
+static inline uint32_t bitstream_get (a52_state_t * state, uint32_t num_bits)
{
uint32_t result;
-
- if(num_bits < state->bits_left)
- {
- result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
- state->bits_left -= num_bits;
- return result;
+
+ if (num_bits < state->bits_left) {
+ result = (state->current_word << (32 - state->bits_left)) >> (32 - num_bits);
+ state->bits_left -= num_bits;
+ return result;
}
- return a52_bitstream_get_bh(state, num_bits);
+ return a52_bitstream_get_bh (state, num_bits);
}
-static inline int32_t bitstream_get_2(a52_state_t * state, uint32_t num_bits)
+static inline int32_t bitstream_get_2 (a52_state_t * state, uint32_t num_bits)
{
int32_t result;
-
- if(num_bits < state->bits_left)
- {
- result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
- state->bits_left -= num_bits;
- return result;
+
+ if (num_bits < state->bits_left) {
+ result = (((int32_t)state->current_word) << (32 - state->bits_left)) >> (32 - num_bits);
+ state->bits_left -= num_bits;
+ return result;
}
- return a52_bitstream_get_bh_2(state, num_bits);
+ return a52_bitstream_get_bh_2 (state, num_bits);
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/downmix.c b/src/filters/transform/MpaDecFilter/a52dec/liba52/downmix.c index a28842b4f..83ccb5def 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/downmix.c +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/downmix.c @@ -31,660 +31,625 @@ #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, sample_t * level,
+ sample_t clev, sample_t slev)
{
- static uint8_t table[11][8] =
- {
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO
- },
- {
- A52_MONO, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_STEREO, A52_3F, A52_STEREO, A52_3F
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
- A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
- A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R
- },
- {
- A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO
- },
- {
- A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
- A52_MONO, A52_MONO, A52_MONO, A52_MONO
- },
- {
- A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
- A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY
- }
+ static uint8_t table[11][8] = {
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
+ A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
+ {A52_MONO, A52_MONO, A52_MONO, A52_MONO,
+ A52_MONO, A52_MONO, A52_MONO, A52_MONO},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
+ A52_STEREO, A52_STEREO, A52_STEREO, A52_STEREO},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
+ A52_STEREO, A52_3F, A52_STEREO, A52_3F},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
+ A52_2F1R, A52_2F1R, A52_2F1R, A52_2F1R},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO,
+ A52_2F1R, A52_3F1R, A52_2F1R, A52_3F1R},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
+ A52_2F2R, A52_2F2R, A52_2F2R, A52_2F2R},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_3F,
+ A52_2F2R, A52_3F2R, A52_2F2R, A52_3F2R},
+ {A52_CHANNEL1, A52_MONO, A52_MONO, A52_MONO,
+ A52_MONO, A52_MONO, A52_MONO, A52_MONO},
+ {A52_CHANNEL2, A52_MONO, A52_MONO, A52_MONO,
+ A52_MONO, A52_MONO, A52_MONO, A52_MONO},
+ {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_DOLBY,
+ A52_DOLBY, A52_DOLBY, A52_DOLBY, A52_DOLBY}
};
int output;
output = flags & A52_CHANNEL_MASK;
- if(output > A52_DOLBY)
- return -1;
+ if (output > A52_DOLBY)
+ return -1;
output = table[output][input & 7];
- if((output == A52_STEREO) &&
- ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
- output = A52_DOLBY;
-
- if(flags & A52_ADJUST_LEVEL)
- switch(CONVERT(input & 7, output))
- {
-
- case CONVERT(A52_3F, A52_MONO):
- *level *= LEVEL_3DB / (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;
- break;
-
- case CONVERT(A52_3F2R, A52_2F1R):
- if(clev < 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;
- break;
-
- case CONVERT(A52_2F1R, A52_MONO):
- *level *= LEVEL_PLUS3DB / (2 + slev);
- break;
-
- case CONVERT(A52_2F1R, A52_STEREO):
- case CONVERT(A52_3F1R, A52_3F):
- *level /= 1 + slev * LEVEL_3DB;
- break;
-
- case CONVERT(A52_3F1R, A52_MONO):
- *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
- break;
-
- case CONVERT(A52_3F1R, A52_STEREO):
- *level /= 1 + clev + slev * LEVEL_3DB;
- break;
-
- case CONVERT(A52_2F2R, A52_MONO):
- *level *= LEVEL_3DB / (1 + slev);
- break;
-
- case CONVERT(A52_2F2R, A52_STEREO):
- case CONVERT(A52_3F2R, A52_3F):
- *level /= 1 + slev;
- break;
-
- case CONVERT(A52_3F2R, A52_MONO):
- *level *= LEVEL_3DB / (1 + clev + slev);
- break;
-
- case CONVERT(A52_3F2R, A52_STEREO):
- *level /= 1 + clev + slev;
- break;
-
- case CONVERT(A52_MONO, A52_DOLBY):
- *level *= LEVEL_PLUS3DB;
- break;
-
- case CONVERT(A52_3F, A52_DOLBY):
- case CONVERT(A52_2F1R, A52_DOLBY):
- *level *= 1 / (1 + LEVEL_3DB);
- break;
-
- case CONVERT(A52_3F1R, A52_DOLBY):
- case CONVERT(A52_2F2R, A52_DOLBY):
- *level *= 1 / (1 + 2 * LEVEL_3DB);
- break;
-
- case CONVERT(A52_3F2R, A52_DOLBY):
- *level *= 1 / (1 + 3 * LEVEL_3DB);
- break;
- }
+ if ((output == A52_STEREO) &&
+ ((input == A52_DOLBY) || ((input == A52_3F) && (clev == LEVEL_3DB))))
+ output = A52_DOLBY;
+
+ if (flags & A52_ADJUST_LEVEL)
+ switch (CONVERT (input & 7, output)) {
+
+ case CONVERT (A52_3F, A52_MONO):
+ *level *= LEVEL_3DB / (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;
+ break;
+
+ case CONVERT (A52_3F2R, A52_2F1R):
+ if (clev < 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;
+ break;
+
+ case CONVERT (A52_2F1R, A52_MONO):
+ *level *= LEVEL_PLUS3DB / (2 + slev);
+ break;
+
+ case CONVERT (A52_2F1R, A52_STEREO):
+ case CONVERT (A52_3F1R, A52_3F):
+ *level /= 1 + slev * LEVEL_3DB;
+ break;
+
+ case CONVERT (A52_3F1R, A52_MONO):
+ *level *= LEVEL_3DB / (1 + clev + 0.5 * slev);
+ break;
+
+ case CONVERT (A52_3F1R, A52_STEREO):
+ *level /= 1 + clev + slev * LEVEL_3DB;
+ break;
+
+ case CONVERT (A52_2F2R, A52_MONO):
+ *level *= LEVEL_3DB / (1 + slev);
+ break;
+
+ case CONVERT (A52_2F2R, A52_STEREO):
+ case CONVERT (A52_3F2R, A52_3F):
+ *level /= 1 + slev;
+ break;
+
+ case CONVERT (A52_3F2R, A52_MONO):
+ *level *= LEVEL_3DB / (1 + clev + slev);
+ break;
+
+ case CONVERT (A52_3F2R, A52_STEREO):
+ *level /= 1 + clev + slev;
+ break;
+
+ case CONVERT (A52_MONO, A52_DOLBY):
+ *level *= LEVEL_PLUS3DB;
+ break;
+
+ case CONVERT (A52_3F, A52_DOLBY):
+ case CONVERT (A52_2F1R, A52_DOLBY):
+ *level *= 1 / (1 + LEVEL_3DB);
+ break;
+
+ case CONVERT (A52_3F1R, A52_DOLBY):
+ case CONVERT (A52_2F2R, A52_DOLBY):
+ *level *= 1 / (1 + 2 * LEVEL_3DB);
+ break;
+
+ case CONVERT (A52_3F2R, A52_DOLBY):
+ *level *= 1 / (1 + 3 * LEVEL_3DB);
+ break;
+ }
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 (sample_t * coeff, int acmod, int output, sample_t level,
+ sample_t clev, sample_t slev)
{
- switch(CONVERT(acmod, output & A52_CHANNEL_MASK))
- {
-
- case CONVERT(A52_CHANNEL, A52_CHANNEL):
- case CONVERT(A52_MONO, A52_MONO):
- case CONVERT(A52_STEREO, A52_STEREO):
- case CONVERT(A52_3F, A52_3F):
- case CONVERT(A52_2F1R, A52_2F1R):
- case CONVERT(A52_3F1R, A52_3F1R):
- case CONVERT(A52_2F2R, A52_2F2R):
- case CONVERT(A52_3F2R, A52_3F2R):
- case CONVERT(A52_STEREO, A52_DOLBY):
- coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
- return 0;
-
- case CONVERT(A52_CHANNEL, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_6DB;
- return 3;
-
- case CONVERT(A52_STEREO, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
- return 3;
-
- case CONVERT(A52_3F, A52_MONO):
- coeff[0] = coeff[2] = level * LEVEL_3DB;
- coeff[1] = level * clev * LEVEL_PLUS3DB;
- return 7;
-
- case CONVERT(A52_2F1R, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
- coeff[2] = level * slev * LEVEL_3DB;
- return 7;
-
- case CONVERT(A52_2F2R, A52_MONO):
- coeff[0] = coeff[1] = level * LEVEL_3DB;
- coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
- 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;
- 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;
- return 31;
-
- case CONVERT(A52_MONO, A52_DOLBY):
- coeff[0] = level * LEVEL_3DB;
- return 0;
-
- case CONVERT(A52_3F, A52_DOLBY):
- clev = LEVEL_3DB;
- 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;
- return 7;
-
- case CONVERT(A52_2F1R, A52_DOLBY):
- slev = 1;
- case CONVERT(A52_2F1R, A52_STEREO):
- coeff[0] = coeff[1] = level;
- coeff[2] = level * slev * LEVEL_3DB;
- return 7;
-
- case CONVERT(A52_3F1R, A52_DOLBY):
- clev = LEVEL_3DB;
- slev = 1;
- case CONVERT(A52_3F1R, A52_STEREO):
- coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = level * slev * LEVEL_3DB;
- return 15;
-
- case CONVERT(A52_2F2R, A52_DOLBY):
- slev = LEVEL_3DB;
- case CONVERT(A52_2F2R, A52_STEREO):
- coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level * slev;
- return 15;
-
- case CONVERT(A52_3F2R, A52_DOLBY):
- clev = LEVEL_3DB;
- case CONVERT(A52_3F2R, A52_2F1R):
- slev = LEVEL_3DB;
- case CONVERT(A52_3F2R, A52_STEREO):
- coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = coeff[4] = level * slev;
- return 31;
-
- case CONVERT(A52_3F1R, A52_3F):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = level * slev * LEVEL_3DB;
- return 13;
-
- case CONVERT(A52_3F2R, A52_3F):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = level * slev;
- return 29;
-
- case CONVERT(A52_2F2R, A52_2F1R):
- coeff[0] = coeff[1] = level;
- coeff[2] = coeff[3] = level * LEVEL_3DB;
- return 12;
-
- case CONVERT(A52_3F2R, A52_3F1R):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = coeff[4] = level * LEVEL_3DB;
- return 24;
-
- case CONVERT(A52_2F1R, A52_2F2R):
- coeff[0] = coeff[1] = level;
- coeff[2] = level * LEVEL_3DB;
- return 0;
-
- case CONVERT(A52_3F1R, A52_2F2R):
- coeff[0] = coeff[2] = level;
- coeff[1] = level * clev;
- coeff[3] = level * LEVEL_3DB;
- return 7;
-
- case CONVERT(A52_3F1R, A52_3F2R):
- coeff[0] = coeff[1] = coeff[2] = level;
- coeff[3] = level * LEVEL_3DB;
- return 0;
-
- case CONVERT(A52_CHANNEL, A52_CHANNEL1):
- coeff[0] = level;
- coeff[1] = 0;
- return 0;
-
- case CONVERT(A52_CHANNEL, A52_CHANNEL2):
- coeff[0] = 0;
- coeff[1] = level;
- return 0;
+ switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
+
+ case CONVERT (A52_CHANNEL, A52_CHANNEL):
+ case CONVERT (A52_MONO, A52_MONO):
+ case CONVERT (A52_STEREO, A52_STEREO):
+ case CONVERT (A52_3F, A52_3F):
+ case CONVERT (A52_2F1R, A52_2F1R):
+ case CONVERT (A52_3F1R, A52_3F1R):
+ case CONVERT (A52_2F2R, A52_2F2R):
+ case CONVERT (A52_3F2R, A52_3F2R):
+ case CONVERT (A52_STEREO, A52_DOLBY):
+ coeff[0] = coeff[1] = coeff[2] = coeff[3] = coeff[4] = level;
+ return 0;
+
+ case CONVERT (A52_CHANNEL, A52_MONO):
+ coeff[0] = coeff[1] = level * LEVEL_6DB;
+ return 3;
+
+ case CONVERT (A52_STEREO, A52_MONO):
+ coeff[0] = coeff[1] = level * LEVEL_3DB;
+ return 3;
+
+ case CONVERT (A52_3F, A52_MONO):
+ coeff[0] = coeff[2] = level * LEVEL_3DB;
+ coeff[1] = level * clev * LEVEL_PLUS3DB;
+ return 7;
+
+ case CONVERT (A52_2F1R, A52_MONO):
+ coeff[0] = coeff[1] = level * LEVEL_3DB;
+ coeff[2] = level * slev * LEVEL_3DB;
+ return 7;
+
+ case CONVERT (A52_2F2R, A52_MONO):
+ coeff[0] = coeff[1] = level * LEVEL_3DB;
+ coeff[2] = coeff[3] = level * slev * LEVEL_3DB;
+ 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;
+ 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;
+ return 31;
+
+ case CONVERT (A52_MONO, A52_DOLBY):
+ coeff[0] = level * LEVEL_3DB;
+ return 0;
+
+ case CONVERT (A52_3F, A52_DOLBY):
+ clev = LEVEL_3DB;
+ 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;
+ return 7;
+
+ case CONVERT (A52_2F1R, A52_DOLBY):
+ slev = 1;
+ case CONVERT (A52_2F1R, A52_STEREO):
+ coeff[0] = coeff[1] = level;
+ coeff[2] = level * slev * LEVEL_3DB;
+ return 7;
+
+ case CONVERT (A52_3F1R, A52_DOLBY):
+ clev = LEVEL_3DB;
+ slev = 1;
+ case CONVERT (A52_3F1R, A52_STEREO):
+ coeff[0] = coeff[2] = level;
+ coeff[1] = level * clev;
+ coeff[3] = level * slev * LEVEL_3DB;
+ return 15;
+
+ case CONVERT (A52_2F2R, A52_DOLBY):
+ slev = LEVEL_3DB;
+ case CONVERT (A52_2F2R, A52_STEREO):
+ coeff[0] = coeff[1] = level;
+ coeff[2] = coeff[3] = level * slev;
+ return 15;
+
+ case CONVERT (A52_3F2R, A52_DOLBY):
+ clev = LEVEL_3DB;
+ case CONVERT (A52_3F2R, A52_2F1R):
+ slev = LEVEL_3DB;
+ case CONVERT (A52_3F2R, A52_STEREO):
+ coeff[0] = coeff[2] = level;
+ coeff[1] = level * clev;
+ coeff[3] = coeff[4] = level * slev;
+ return 31;
+
+ case CONVERT (A52_3F1R, A52_3F):
+ coeff[0] = coeff[1] = coeff[2] = level;
+ coeff[3] = level * slev * LEVEL_3DB;
+ return 13;
+
+ case CONVERT (A52_3F2R, A52_3F):
+ coeff[0] = coeff[1] = coeff[2] = level;
+ coeff[3] = coeff[4] = level * slev;
+ return 29;
+
+ case CONVERT (A52_2F2R, A52_2F1R):
+ coeff[0] = coeff[1] = level;
+ coeff[2] = coeff[3] = level * LEVEL_3DB;
+ return 12;
+
+ case CONVERT (A52_3F2R, A52_3F1R):
+ coeff[0] = coeff[1] = coeff[2] = level;
+ coeff[3] = coeff[4] = level * LEVEL_3DB;
+ return 24;
+
+ case CONVERT (A52_2F1R, A52_2F2R):
+ coeff[0] = coeff[1] = level;
+ coeff[2] = level * LEVEL_3DB;
+ return 0;
+
+ case CONVERT (A52_3F1R, A52_2F2R):
+ coeff[0] = coeff[2] = level;
+ coeff[1] = level * clev;
+ coeff[3] = level * LEVEL_3DB;
+ return 7;
+
+ case CONVERT (A52_3F1R, A52_3F2R):
+ coeff[0] = coeff[1] = coeff[2] = level;
+ coeff[3] = level * LEVEL_3DB;
+ return 0;
+
+ case CONVERT (A52_CHANNEL, A52_CHANNEL1):
+ coeff[0] = level;
+ coeff[1] = 0;
+ return 0;
+
+ case CONVERT (A52_CHANNEL, A52_CHANNEL2):
+ coeff[0] = 0;
+ coeff[1] = level;
+ return 0;
}
return -1; /* NOTREACHED */
}
-static void mix2to1(sample_t * dest, sample_t * src, sample_t bias)
+static void mix2to1 (sample_t * dest, sample_t * src, sample_t bias)
{
int i;
- for(i = 0; i < 256; i++)
- dest[i] += src[i] + bias;
+ for (i = 0; i < 256; i++)
+ dest[i] += src[i] + bias;
}
-static void mix3to1(sample_t * samples, sample_t bias)
+static void mix3to1 (sample_t * samples, sample_t bias)
{
int i;
- for(i = 0; i < 256; i++)
- samples[i] += samples[i + 256] + samples[i + 512] + bias;
+ for (i = 0; i < 256; i++)
+ samples[i] += samples[i + 256] + samples[i + 512] + bias;
}
-static void mix4to1(sample_t * samples, sample_t bias)
+static void mix4to1 (sample_t * samples, sample_t bias)
{
int i;
- for(i = 0; i < 256; i++)
- samples[i] += (samples[i + 256] + samples[i + 512] +
- samples[i + 768] + bias);
+ for (i = 0; i < 256; i++)
+ samples[i] += (samples[i + 256] + samples[i + 512] +
+ samples[i + 768] + bias);
}
-static void mix5to1(sample_t * samples, sample_t bias)
+static void mix5to1 (sample_t * samples, sample_t bias)
{
int i;
- for(i = 0; i < 256; i++)
- samples[i] += (samples[i + 256] + samples[i + 512] +
- samples[i + 768] + samples[i + 1024] + bias);
+ for (i = 0; i < 256; i++)
+ samples[i] += (samples[i + 256] + samples[i + 512] +
+ samples[i + 768] + samples[i + 1024] + bias);
}
-static void mix3to2(sample_t * samples, sample_t bias)
+static void mix3to2 (sample_t * samples, sample_t bias)
{
int i;
sample_t common;
- for(i = 0; i < 256; i++)
- {
- common = samples[i + 256] + bias;
- samples[i] += common;
- samples[i + 256] = samples[i + 512] + common;
+ for (i = 0; i < 256; i++) {
+ common = samples[i + 256] + bias;
+ samples[i] += common;
+ samples[i + 256] = samples[i + 512] + common;
}
}
-static void mix21to2(sample_t * left, sample_t * right, sample_t bias)
+static void mix21to2 (sample_t * left, sample_t * right, sample_t bias)
{
int i;
sample_t common;
- for(i = 0; i < 256; i++)
- {
- common = right[i + 256] + bias;
- left[i] += common;
- right[i] += common;
+ for (i = 0; i < 256; i++) {
+ common = right[i + 256] + bias;
+ left[i] += common;
+ right[i] += common;
}
}
-static void mix21toS(sample_t * samples, sample_t bias)
+static void mix21toS (sample_t * samples, sample_t bias)
{
int i;
sample_t surround;
- for(i = 0; i < 256; i++)
- {
- surround = samples[i + 512];
- samples[i] += bias - surround;
- samples[i + 256] += bias + surround;
+ for (i = 0; i < 256; i++) {
+ surround = samples[i + 512];
+ samples[i] += bias - surround;
+ samples[i + 256] += bias + surround;
}
}
-static void mix31to2(sample_t * samples, sample_t bias)
+static void mix31to2 (sample_t * samples, sample_t bias)
{
int i;
sample_t common;
- for(i = 0; i < 256; i++)
- {
- common = samples[i + 256] + samples[i + 768] + bias;
- samples[i] += common;
- samples[i + 256] = samples[i + 512] + common;
+ for (i = 0; i < 256; i++) {
+ common = samples[i + 256] + samples[i + 768] + bias;
+ samples[i] += common;
+ samples[i + 256] = samples[i + 512] + common;
}
}
-static void mix31toS(sample_t * samples, sample_t bias)
+static void mix31toS (sample_t * samples, sample_t bias)
{
int i;
sample_t common, surround;
- for(i = 0; i < 256; i++)
- {
- common = samples[i + 256] + bias;
- surround = samples[i + 768];
- samples[i] += common - surround;
- samples[i + 256] = samples[i + 512] + common + surround;
+ for (i = 0; i < 256; i++) {
+ common = samples[i + 256] + bias;
+ surround = samples[i + 768];
+ samples[i] += common - surround;
+ samples[i + 256] = samples[i + 512] + common + surround;
}
}
-static void mix22toS(sample_t * samples, sample_t bias)
+static void mix22toS (sample_t * samples, sample_t bias)
{
int i;
sample_t surround;
- for(i = 0; i < 256; i++)
- {
- surround = samples[i + 512] + samples[i + 768];
- samples[i] += bias - surround;
- samples[i + 256] += bias + surround;
+ for (i = 0; i < 256; i++) {
+ surround = samples[i + 512] + samples[i + 768];
+ samples[i] += bias - surround;
+ samples[i + 256] += bias + surround;
}
}
-static void mix32to2(sample_t * samples, sample_t bias)
+static void mix32to2 (sample_t * samples, sample_t bias)
{
int i;
sample_t common;
- for(i = 0; i < 256; i++)
- {
- common = samples[i + 256] + bias;
- samples[i] += common + samples[i + 768];
- samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
+ for (i = 0; i < 256; i++) {
+ common = samples[i + 256] + bias;
+ samples[i] += common + samples[i + 768];
+ samples[i + 256] = common + samples[i + 512] + samples[i + 1024];
}
}
-static void mix32toS(sample_t * samples, sample_t bias)
+static void mix32toS (sample_t * samples, sample_t bias)
{
int i;
sample_t common, surround;
- for(i = 0; i < 256; i++)
- {
- common = samples[i + 256] + bias;
- surround = samples[i + 768] + samples[i + 1024];
- samples[i] += common - surround;
- samples[i + 256] = samples[i + 512] + common + surround;
+ for (i = 0; i < 256; i++) {
+ common = samples[i + 256] + bias;
+ surround = samples[i + 768] + samples[i + 1024];
+ samples[i] += common - surround;
+ samples[i + 256] = samples[i + 512] + common + surround;
}
}
-static void move2to1(sample_t * src, sample_t * dest, sample_t bias)
+static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
{
int i;
- for(i = 0; i < 256; i++)
- dest[i] = src[i] + src[i + 256] + bias;
+ for (i = 0; i < 256; i++)
+ dest[i] = src[i] + src[i + 256] + bias;
}
-static void zero(sample_t * samples)
+static void zero (sample_t * samples)
{
int i;
- for(i = 0; i < 256; i++)
- samples[i] = 0;
+ for (i = 0; i < 256; i++)
+ samples[i] = 0;
}
-void a52_downmix(sample_t * samples, int acmod, int output, sample_t bias,
- sample_t clev, sample_t slev)
+void a52_downmix (sample_t * samples, int acmod, int output, sample_t bias,
+ sample_t clev, sample_t slev)
{
- switch(CONVERT(acmod, output & A52_CHANNEL_MASK))
- {
-
- case CONVERT(A52_CHANNEL, A52_CHANNEL2):
- memcpy(samples, samples + 256, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_CHANNEL, A52_MONO):
- case CONVERT(A52_STEREO, A52_MONO):
-mix_2to1:
- mix2to1(samples, samples + 256, bias);
- break;
-
- case CONVERT(A52_2F1R, A52_MONO):
- if(slev == 0)
- goto mix_2to1;
- case CONVERT(A52_3F, A52_MONO):
-mix_3to1:
- mix3to1(samples, bias);
- break;
-
- case CONVERT(A52_3F1R, A52_MONO):
- if(slev == 0)
- goto mix_3to1;
- case CONVERT(A52_2F2R, A52_MONO):
- if(slev == 0)
- goto mix_2to1;
- mix4to1(samples, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_MONO):
- if(slev == 0)
- goto mix_3to1;
- mix5to1(samples, bias);
- break;
-
- case CONVERT(A52_MONO, A52_DOLBY):
- memcpy(samples + 256, samples, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_3F, A52_STEREO):
- case CONVERT(A52_3F, A52_DOLBY):
-mix_3to2:
- mix3to2(samples, bias);
- break;
-
- case CONVERT(A52_2F1R, A52_STEREO):
- if(slev == 0)
- break;
- mix21to2(samples, samples + 256, bias);
- break;
-
- case CONVERT(A52_2F1R, A52_DOLBY):
- mix21toS(samples, bias);
- break;
-
- case CONVERT(A52_3F1R, A52_STEREO):
- if(slev == 0)
- goto mix_3to2;
- mix31to2(samples, bias);
- break;
-
- case CONVERT(A52_3F1R, A52_DOLBY):
- mix31toS(samples, bias);
- break;
-
- case CONVERT(A52_2F2R, A52_STEREO):
- if(slev == 0)
- break;
- mix2to1(samples, samples + 512, bias);
- mix2to1(samples + 256, samples + 768, bias);
- break;
-
- case CONVERT(A52_2F2R, A52_DOLBY):
- mix22toS(samples, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_STEREO):
- if(slev == 0)
- goto mix_3to2;
- mix32to2(samples, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_DOLBY):
- mix32toS(samples, bias);
- break;
-
- case CONVERT(A52_3F1R, A52_3F):
- if(slev == 0)
- break;
- mix21to2(samples, samples + 512, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_3F):
- if(slev == 0)
- break;
- mix2to1(samples, samples + 768, bias);
- mix2to1(samples + 512, samples + 1024, bias);
- break;
-
- case CONVERT(A52_3F1R, A52_2F1R):
- mix3to2(samples, bias);
- memcpy(samples + 512, samples + 768, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_2F2R, A52_2F1R):
- mix2to1(samples + 512, samples + 768, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_2F1R):
- mix3to2(samples, bias);
- move2to1(samples + 768, samples + 512, bias);
- break;
-
- case CONVERT(A52_3F2R, A52_3F1R):
- mix2to1(samples + 768, samples + 1024, bias);
- break;
-
- case CONVERT(A52_2F1R, A52_2F2R):
- memcpy(samples + 768, samples + 512, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_3F1R, A52_2F2R):
- mix3to2(samples, bias);
- memcpy(samples + 512, samples + 768, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_3F2R, A52_2F2R):
- mix3to2(samples, bias);
- memcpy(samples + 512, samples + 768, 256 * sizeof(sample_t));
- memcpy(samples + 768, samples + 1024, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_3F1R, A52_3F2R):
- memcpy(samples + 1024, samples + 768, 256 * sizeof(sample_t));
- break;
+ switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
+
+ case CONVERT (A52_CHANNEL, A52_CHANNEL2):
+ memcpy (samples, samples + 256, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_CHANNEL, A52_MONO):
+ case CONVERT (A52_STEREO, A52_MONO):
+ mix_2to1:
+ mix2to1 (samples, samples + 256, bias);
+ break;
+
+ case CONVERT (A52_2F1R, A52_MONO):
+ if (slev == 0)
+ goto mix_2to1;
+ case CONVERT (A52_3F, A52_MONO):
+ mix_3to1:
+ mix3to1 (samples, bias);
+ break;
+
+ case CONVERT (A52_3F1R, A52_MONO):
+ if (slev == 0)
+ goto mix_3to1;
+ case CONVERT (A52_2F2R, A52_MONO):
+ if (slev == 0)
+ goto mix_2to1;
+ mix4to1 (samples, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_MONO):
+ if (slev == 0)
+ goto mix_3to1;
+ mix5to1 (samples, bias);
+ break;
+
+ case CONVERT (A52_MONO, A52_DOLBY):
+ memcpy (samples + 256, samples, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_3F, A52_STEREO):
+ case CONVERT (A52_3F, A52_DOLBY):
+ mix_3to2:
+ mix3to2 (samples, bias);
+ break;
+
+ case CONVERT (A52_2F1R, A52_STEREO):
+ if (slev == 0)
+ break;
+ mix21to2 (samples, samples + 256, bias);
+ break;
+
+ case CONVERT (A52_2F1R, A52_DOLBY):
+ mix21toS (samples, bias);
+ break;
+
+ case CONVERT (A52_3F1R, A52_STEREO):
+ if (slev == 0)
+ goto mix_3to2;
+ mix31to2 (samples, bias);
+ break;
+
+ case CONVERT (A52_3F1R, A52_DOLBY):
+ mix31toS (samples, bias);
+ break;
+
+ case CONVERT (A52_2F2R, A52_STEREO):
+ if (slev == 0)
+ break;
+ mix2to1 (samples, samples + 512, bias);
+ mix2to1 (samples + 256, samples + 768, bias);
+ break;
+
+ case CONVERT (A52_2F2R, A52_DOLBY):
+ mix22toS (samples, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_STEREO):
+ if (slev == 0)
+ goto mix_3to2;
+ mix32to2 (samples, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_DOLBY):
+ mix32toS (samples, bias);
+ break;
+
+ case CONVERT (A52_3F1R, A52_3F):
+ if (slev == 0)
+ break;
+ mix21to2 (samples, samples + 512, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_3F):
+ if (slev == 0)
+ break;
+ mix2to1 (samples, samples + 768, bias);
+ mix2to1 (samples + 512, samples + 1024, bias);
+ break;
+
+ case CONVERT (A52_3F1R, A52_2F1R):
+ mix3to2 (samples, bias);
+ memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_2F2R, A52_2F1R):
+ mix2to1 (samples + 512, samples + 768, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_2F1R):
+ mix3to2 (samples, bias);
+ move2to1 (samples + 768, samples + 512, bias);
+ break;
+
+ case CONVERT (A52_3F2R, A52_3F1R):
+ mix2to1 (samples + 768, samples + 1024, bias);
+ break;
+
+ case CONVERT (A52_2F1R, A52_2F2R):
+ memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_3F1R, A52_2F2R):
+ mix3to2 (samples, bias);
+ memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_3F2R, A52_2F2R):
+ mix3to2 (samples, bias);
+ memcpy (samples + 512, samples + 768, 256 * sizeof (sample_t));
+ memcpy (samples + 768, samples + 1024, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_3F1R, A52_3F2R):
+ memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
+ break;
}
}
-void a52_upmix(sample_t * samples, int acmod, int output)
+void a52_upmix (sample_t * samples, int acmod, int output)
{
- switch(CONVERT(acmod, output & A52_CHANNEL_MASK))
- {
-
- case CONVERT(A52_CHANNEL, A52_CHANNEL2):
- memcpy(samples + 256, samples, 256 * sizeof(sample_t));
- break;
-
- case CONVERT(A52_3F2R, A52_MONO):
- zero(samples + 1024);
- case CONVERT(A52_3F1R, A52_MONO):
- case CONVERT(A52_2F2R, A52_MONO):
- zero(samples + 768);
- case CONVERT(A52_3F, A52_MONO):
- case CONVERT(A52_2F1R, A52_MONO):
- zero(samples + 512);
- case CONVERT(A52_CHANNEL, A52_MONO):
- case CONVERT(A52_STEREO, A52_MONO):
- zero(samples + 256);
- break;
-
- case CONVERT(A52_3F2R, A52_STEREO):
- case CONVERT(A52_3F2R, A52_DOLBY):
- zero(samples + 1024);
- case CONVERT(A52_3F1R, A52_STEREO):
- case CONVERT(A52_3F1R, A52_DOLBY):
- zero(samples + 768);
- case CONVERT(A52_3F, A52_STEREO):
- case CONVERT(A52_3F, A52_DOLBY):
-mix_3to2:
- memcpy(samples + 512, samples + 256, 256 * sizeof(sample_t));
- zero(samples + 256);
- break;
-
- case CONVERT(A52_2F2R, A52_STEREO):
- case CONVERT(A52_2F2R, A52_DOLBY):
- zero(samples + 768);
- case CONVERT(A52_2F1R, A52_STEREO):
- case CONVERT(A52_2F1R, A52_DOLBY):
- zero(samples + 512);
- break;
-
- case CONVERT(A52_3F2R, A52_3F):
- zero(samples + 1024);
- case CONVERT(A52_3F1R, A52_3F):
- case CONVERT(A52_2F2R, A52_2F1R):
- zero(samples + 768);
- break;
-
- case CONVERT(A52_3F2R, A52_3F1R):
- zero(samples + 1024);
- break;
-
- case CONVERT(A52_3F2R, A52_2F1R):
- zero(samples + 1024);
- case CONVERT(A52_3F1R, A52_2F1R):
-mix_31to21:
- memcpy(samples + 768, samples + 512, 256 * sizeof(sample_t));
- goto mix_3to2;
-
- case CONVERT(A52_3F2R, A52_2F2R):
- memcpy(samples + 1024, samples + 768, 256 * sizeof(sample_t));
- goto mix_31to21;
+ switch (CONVERT (acmod, output & A52_CHANNEL_MASK)) {
+
+ case CONVERT (A52_CHANNEL, A52_CHANNEL2):
+ memcpy (samples + 256, samples, 256 * sizeof (sample_t));
+ break;
+
+ case CONVERT (A52_3F2R, A52_MONO):
+ zero (samples + 1024);
+ case CONVERT (A52_3F1R, A52_MONO):
+ case CONVERT (A52_2F2R, A52_MONO):
+ zero (samples + 768);
+ case CONVERT (A52_3F, A52_MONO):
+ case CONVERT (A52_2F1R, A52_MONO):
+ zero (samples + 512);
+ case CONVERT (A52_CHANNEL, A52_MONO):
+ case CONVERT (A52_STEREO, A52_MONO):
+ zero (samples + 256);
+ break;
+
+ case CONVERT (A52_3F2R, A52_STEREO):
+ case CONVERT (A52_3F2R, A52_DOLBY):
+ zero (samples + 1024);
+ case CONVERT (A52_3F1R, A52_STEREO):
+ case CONVERT (A52_3F1R, A52_DOLBY):
+ zero (samples + 768);
+ case CONVERT (A52_3F, A52_STEREO):
+ case CONVERT (A52_3F, A52_DOLBY):
+ mix_3to2:
+ memcpy (samples + 512, samples + 256, 256 * sizeof (sample_t));
+ zero (samples + 256);
+ break;
+
+ case CONVERT (A52_2F2R, A52_STEREO):
+ case CONVERT (A52_2F2R, A52_DOLBY):
+ zero (samples + 768);
+ case CONVERT (A52_2F1R, A52_STEREO):
+ case CONVERT (A52_2F1R, A52_DOLBY):
+ zero (samples + 512);
+ break;
+
+ case CONVERT (A52_3F2R, A52_3F):
+ zero (samples + 1024);
+ case CONVERT (A52_3F1R, A52_3F):
+ case CONVERT (A52_2F2R, A52_2F1R):
+ zero (samples + 768);
+ break;
+
+ case CONVERT (A52_3F2R, A52_3F1R):
+ zero (samples + 1024);
+ break;
+
+ case CONVERT (A52_3F2R, A52_2F1R):
+ zero (samples + 1024);
+ case CONVERT (A52_3F1R, A52_2F1R):
+ mix_31to21:
+ memcpy (samples + 768, samples + 512, 256 * sizeof (sample_t));
+ goto mix_3to2;
+
+ case CONVERT (A52_3F2R, A52_2F2R):
+ memcpy (samples + 1024, samples + 768, 256 * sizeof (sample_t));
+ goto mix_31to21;
}
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/imdct.c b/src/filters/transform/MpaDecFilter/a52dec/liba52/imdct.c index 69afaa2b8..303fe0ca4 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/imdct.c +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/imdct.c @@ -40,22 +40,20 @@ #include "a52_internal.h"
//#include "mm_accel.h"
-typedef struct complex_s
-{
+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
+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 */
@@ -72,10 +70,10 @@ static complex_t post2[32]; static sample_t a52_imdct_window[256];
-static void (* ifft128)(complex_t * buf);
-static void (* ifft64)(complex_t * buf);
+static void (* ifft128) (complex_t * buf);
+static void (* ifft64) (complex_t * buf);
-static inline void ifft2(complex_t * buf)
+static inline void ifft2 (complex_t * buf)
{
double r, i;
@@ -87,7 +85,7 @@ static inline void ifft2(complex_t * buf) buf[1].imag = i - buf[1].imag;
}
-static inline void ifft4(complex_t * buf)
+static inline void ifft4 (complex_t * buf)
{
double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
@@ -169,18 +167,18 @@ static inline void ifft4(complex_t * buf) a1.imag += tmp4; \
} while (0)
-static inline void ifft8(complex_t * buf)
+static inline void ifft8 (complex_t * buf)
{
double tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
- ifft4(buf);
- ifft2(buf + 4);
- ifft2(buf + 6);
- BUTTERFLY_ZERO(buf[0], buf[2], buf[4], buf[6]);
- BUTTERFLY_HALF(buf[1], buf[3], buf[5], buf[7], roots16[1]);
+ ifft4 (buf);
+ ifft2 (buf + 4);
+ ifft2 (buf + 6);
+ BUTTERFLY_ZERO (buf[0], buf[2], buf[4], buf[6]);
+ 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, sample_t * weight, int n)
{
complex_t * buf1;
complex_t * buf2;
@@ -193,101 +191,97 @@ static void ifft_pass(complex_t * buf, sample_t * weight, int n) buf2 = buf + 2 * n;
buf3 = buf + 3 * n;
- BUTTERFLY_ZERO(buf[-1], buf1[-1], buf2[-1], buf3[-1]);
+ BUTTERFLY_ZERO (buf[-1], buf1[-1], buf2[-1], buf3[-1]);
i = n - 1;
- do
- {
- BUTTERFLY(buf[0], buf1[0], buf2[0], buf3[0], weight[n], weight[2*i]);
- buf++;
- buf1++;
- buf2++;
- buf3++;
- weight++;
- }
- while(--i);
+ do {
+ BUTTERFLY (buf[0], buf1[0], buf2[0], buf3[0], weight[n], weight[2*i]);
+ buf++;
+ buf1++;
+ buf2++;
+ buf3++;
+ weight++;
+ } while (--i);
}
-static void ifft16(complex_t * buf)
+static void ifft16 (complex_t * buf)
{
- ifft8(buf);
- ifft4(buf + 8);
- ifft4(buf + 12);
- ifft_pass(buf, roots16 - 4, 4);
+ ifft8 (buf);
+ ifft4 (buf + 8);
+ ifft4 (buf + 12);
+ ifft_pass (buf, roots16 - 4, 4);
}
-static void ifft32(complex_t * buf)
+static void ifft32 (complex_t * buf)
{
- ifft16(buf);
- ifft8(buf + 16);
- ifft8(buf + 24);
- ifft_pass(buf, roots32 - 8, 8);
+ ifft16 (buf);
+ ifft8 (buf + 16);
+ ifft8 (buf + 24);
+ ifft_pass (buf, roots32 - 8, 8);
}
-static void ifft64_c(complex_t * buf)
+static void ifft64_c (complex_t * buf)
{
- ifft32(buf);
- ifft16(buf + 32);
- ifft16(buf + 48);
- ifft_pass(buf, roots64 - 16, 16);
+ ifft32 (buf);
+ ifft16 (buf + 32);
+ ifft16 (buf + 48);
+ ifft_pass (buf, roots64 - 16, 16);
}
-static void ifft128_c(complex_t * buf)
+static void ifft128_c (complex_t * buf)
{
- ifft32(buf);
- ifft16(buf + 32);
- ifft16(buf + 48);
- ifft_pass(buf, roots64 - 16, 16);
-
- ifft32(buf + 64);
- ifft32(buf + 96);
- ifft_pass(buf, roots128 - 32, 32);
+ ifft32 (buf);
+ ifft16 (buf + 32);
+ ifft16 (buf + 48);
+ ifft_pass (buf, roots64 - 16, 16);
+
+ ifft32 (buf + 64);
+ ifft32 (buf + 96);
+ ifft_pass (buf, roots128 - 32, 32);
}
-void a52_imdct_512(sample_t * data, sample_t * delay, sample_t bias)
+void a52_imdct_512 (sample_t * data, sample_t * delay, sample_t bias)
{
int i, k;
sample_t t_r, t_i, a_r, a_i, b_r, b_i, w_1, w_2;
const sample_t * window = a52_imdct_window;
complex_t buf[128];
-
- for(i = 0; i < 128; i++)
- {
- k = fftorder[i];
- t_r = pre1[i].real;
- t_i = pre1[i].imag;
-
- buf[i].real = t_i * data[255-k] + t_r * data[k];
- buf[i].imag = t_r * data[255-k] - t_i * data[k];
+
+ for (i = 0; i < 128; i++) {
+ k = fftorder[i];
+ t_r = pre1[i].real;
+ t_i = pre1[i].imag;
+
+ buf[i].real = t_i * data[255-k] + t_r * data[k];
+ buf[i].imag = t_r * data[255-k] - t_i * data[k];
}
- ifft128(buf);
+ ifft128 (buf);
/* Post IFFT complex multiply plus IFFT complex conjugate*/
/* Window and convert to real valued signal */
- for(i = 0; i < 64; i++)
- {
- /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
- t_r = post1[i].real;
- t_i = post1[i].imag;
-
- a_r = t_r * buf[i].real + t_i * buf[i].imag;
- a_i = t_i * buf[i].real - t_r * buf[i].imag;
- b_r = t_i * buf[127-i].real + t_r * buf[127-i].imag;
- b_i = t_r * buf[127-i].real - t_i * buf[127-i].imag;
-
- w_1 = window[2*i];
- w_2 = window[255-2*i];
- data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
- data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
- delay[2*i] = a_i;
-
- w_1 = window[2*i+1];
- w_2 = window[254-2*i];
- data[2*i+1] = delay[2*i+1] * w_2 + b_r * w_1 + bias;
- data[254-2*i] = delay[2*i+1] * w_1 - b_r * w_2 + bias;
- delay[2*i+1] = b_i;
+ for (i = 0; i < 64; i++) {
+ /* y[n] = z[n] * (xcos1[n] + j * xsin1[n]) ; */
+ t_r = post1[i].real;
+ t_i = post1[i].imag;
+
+ a_r = t_r * buf[i].real + t_i * buf[i].imag;
+ a_i = t_i * buf[i].real - t_r * buf[i].imag;
+ b_r = t_i * buf[127-i].real + t_r * buf[127-i].imag;
+ b_i = t_r * buf[127-i].real - t_i * buf[127-i].imag;
+
+ w_1 = window[2*i];
+ w_2 = window[255-2*i];
+ data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
+ data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
+ delay[2*i] = a_i;
+
+ w_1 = window[2*i+1];
+ w_2 = window[254-2*i];
+ data[2*i+1] = delay[2*i+1] * w_2 + b_r * w_1 + bias;
+ data[254-2*i] = delay[2*i+1] * w_1 - b_r * w_2 + bias;
+ delay[2*i+1] = b_i;
}
}
@@ -299,150 +293,140 @@ void a52_imdct_256(sample_t * data, sample_t * delay, sample_t bias) complex_t buf1[64], buf2[64];
/* Pre IFFT complex multiply plus IFFT cmplx conjugate */
- for(i = 0; i < 64; i++)
- {
- k = fftorder[i];
- t_r = pre2[i].real;
- t_i = pre2[i].imag;
+ for (i = 0; i < 64; i++) {
+ k = fftorder[i];
+ t_r = pre2[i].real;
+ t_i = pre2[i].imag;
- buf1[i].real = t_i * data[254-k] + t_r * data[k];
- buf1[i].imag = t_r * data[254-k] - t_i * data[k];
+ buf1[i].real = t_i * data[254-k] + t_r * data[k];
+ buf1[i].imag = t_r * data[254-k] - t_i * data[k];
- buf2[i].real = t_i * data[255-k] + t_r * data[k+1];
- buf2[i].imag = t_r * data[255-k] - t_i * data[k+1];
+ buf2[i].real = t_i * data[255-k] + t_r * data[k+1];
+ buf2[i].imag = t_r * data[255-k] - t_i * data[k+1];
}
- ifft64(buf1);
- ifft64(buf2);
+ ifft64 (buf1);
+ ifft64 (buf2);
/* Post IFFT complex multiply */
/* Window and convert to real valued signal */
- for(i = 0; i < 32; i++)
- {
- /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
- t_r = post2[i].real;
- t_i = post2[i].imag;
-
- a_r = t_r * buf1[i].real + t_i * buf1[i].imag;
- a_i = t_i * buf1[i].real - t_r * buf1[i].imag;
- b_r = t_i * buf1[63-i].real + t_r * buf1[63-i].imag;
- b_i = t_r * buf1[63-i].real - t_i * buf1[63-i].imag;
-
- c_r = t_r * buf2[i].real + t_i * buf2[i].imag;
- c_i = t_i * buf2[i].real - t_r * buf2[i].imag;
- d_r = t_i * buf2[63-i].real + t_r * buf2[63-i].imag;
- d_i = t_r * buf2[63-i].real - t_i * buf2[63-i].imag;
-
- w_1 = window[2*i];
- w_2 = window[255-2*i];
- data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
- data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
- delay[2*i] = c_i;
-
- w_1 = window[128+2*i];
- w_2 = window[127-2*i];
- data[128+2*i] = delay[127-2*i] * w_2 + a_i * w_1 + bias;
- data[127-2*i] = delay[127-2*i] * w_1 - a_i * w_2 + bias;
- delay[127-2*i] = c_r;
-
- w_1 = window[2*i+1];
- w_2 = window[254-2*i];
- data[2*i+1] = delay[2*i+1] * w_2 - b_i * w_1 + bias;
- data[254-2*i] = delay[2*i+1] * w_1 + b_i * w_2 + bias;
- delay[2*i+1] = d_r;
-
- w_1 = window[129+2*i];
- w_2 = window[126-2*i];
- data[129+2*i] = delay[126-2*i] * w_2 + b_r * w_1 + bias;
- data[126-2*i] = delay[126-2*i] * w_1 - b_r * w_2 + bias;
- delay[126-2*i] = d_i;
+ for (i = 0; i < 32; i++) {
+ /* y1[n] = z1[n] * (xcos2[n] + j * xs in2[n]) ; */
+ t_r = post2[i].real;
+ t_i = post2[i].imag;
+
+ a_r = t_r * buf1[i].real + t_i * buf1[i].imag;
+ a_i = t_i * buf1[i].real - t_r * buf1[i].imag;
+ b_r = t_i * buf1[63-i].real + t_r * buf1[63-i].imag;
+ b_i = t_r * buf1[63-i].real - t_i * buf1[63-i].imag;
+
+ c_r = t_r * buf2[i].real + t_i * buf2[i].imag;
+ c_i = t_i * buf2[i].real - t_r * buf2[i].imag;
+ d_r = t_i * buf2[63-i].real + t_r * buf2[63-i].imag;
+ d_i = t_r * buf2[63-i].real - t_i * buf2[63-i].imag;
+
+ w_1 = window[2*i];
+ w_2 = window[255-2*i];
+ data[2*i] = delay[2*i] * w_2 - a_r * w_1 + bias;
+ data[255-2*i] = delay[2*i] * w_1 + a_r * w_2 + bias;
+ delay[2*i] = c_i;
+
+ w_1 = window[128+2*i];
+ w_2 = window[127-2*i];
+ data[128+2*i] = delay[127-2*i] * w_2 + a_i * w_1 + bias;
+ data[127-2*i] = delay[127-2*i] * w_1 - a_i * w_2 + bias;
+ delay[127-2*i] = c_r;
+
+ w_1 = window[2*i+1];
+ w_2 = window[254-2*i];
+ data[2*i+1] = delay[2*i+1] * w_2 - b_i * w_1 + bias;
+ data[254-2*i] = delay[2*i+1] * w_1 + b_i * w_2 + bias;
+ delay[2*i+1] = d_r;
+
+ w_1 = window[129+2*i];
+ w_2 = window[126-2*i];
+ data[129+2*i] = delay[126-2*i] * w_2 + b_r * w_1 + bias;
+ data[126-2*i] = delay[126-2*i] * w_1 - b_r * w_2 + bias;
+ delay[126-2*i] = d_i;
}
}
-static double besselI0(double x)
+static double besselI0 (double x)
{
double bessel = 1;
int i = 100;
do
- bessel = bessel * x / (i * i) + 1;
- while(--i);
+ bessel = bessel * x / (i * i) + 1;
+ while (--i);
return bessel;
}
-void a52_imdct_init(uint32_t mm_accel)
+void a52_imdct_init (uint32_t mm_accel)
{
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;
+ 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 < 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 < 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 < 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 < 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 < 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 = 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 = 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++) {
+ 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 < 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));
+ 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));
}
#ifdef LIBA52_DJBFFT
- if(mm_accel & MM_ACCEL_DJBFFT)
- {
- //fprintf (stderr, "Using djbfft for IMDCT transform\n");
- ifft128 = (void (*)(complex_t *)) fftc4_un128;
- ifft64 = (void (*)(complex_t *)) fftc4_un64;
- }
- else
+ if (mm_accel & MM_ACCEL_DJBFFT) {
+ //fprintf (stderr, "Using djbfft for IMDCT transform\n");
+ ifft128 = (void (*) (complex_t *)) fftc4_un128;
+ ifft64 = (void (*) (complex_t *)) fftc4_un64;
+ } else
#endif
{
- //fprintf (stderr, "No accelerated IMDCT transform found\n");
- ifft128 = ifft128_c;
- ifft64 = ifft64_c;
+ //fprintf (stderr, "No accelerated IMDCT transform found\n");
+ ifft128 = ifft128_c;
+ ifft64 = ifft64_c;
}
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/parse.c b/src/filters/transform/MpaDecFilter/a52dec/liba52/parse.c index e078111d2..08d5bada4 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/parse.c +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/parse.c @@ -38,14 +38,13 @@ void * __cdecl malloc(size_t); #ifdef HAVE_MEMALIGN
/* some systems have memalign() but no declaration for it */
-void * memalign(size_t align, size_t size);
+void * memalign (size_t align, size_t size);
#else
/* assume malloc alignment is sufficient */
#define memalign(align,size) malloc (size)
#endif
-typedef struct
-{
+typedef struct {
sample_t q1[2];
sample_t q2[2];
sample_t q4;
@@ -56,88 +55,85 @@ typedef struct static uint8_t halfrate[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3};
-a52_state_t * a52_init(uint32_t mm_accel)
+a52_state_t * a52_init (uint32_t mm_accel)
{
a52_state_t * state;
int i;
- state = malloc(sizeof(a52_state_t));
- if(state == NULL)
- return NULL;
+ state = malloc (sizeof (a52_state_t));
+ if (state == NULL)
+ return NULL;
- state->samples = memalign(16, 256 * 12 * sizeof(sample_t));
- if(state->samples == NULL)
- {
- free(state);
- return NULL;
+ state->samples = memalign (16, 256 * 12 * sizeof (sample_t));
+ if (state->samples == NULL) {
+ free (state);
+ return NULL;
}
- for(i = 0; i < 256 * 12; i++)
- state->samples[i] = 0;
+ for (i = 0; i < 256 * 12; i++)
+ state->samples[i] = 0;
state->downmixed = 1;
state->lfsr_state = 1;
- a52_imdct_init(mm_accel);
+ a52_imdct_init (mm_accel);
return state;
}
-sample_t * a52_samples(a52_state_t * state)
+sample_t * a52_samples (a52_state_t * state)
{
return state->samples;
}
-int a52_syncinfo(uint8_t * buf, int * flags,
- int * sample_rate, int * bit_rate)
+int a52_syncinfo (uint8_t * buf, int * flags,
+ int * sample_rate, int * bit_rate)
{
static int rate[] = { 32, 40, 48, 56, 64, 80, 96, 112,
- 128, 160, 192, 224, 256, 320, 384, 448,
- 512, 576, 640
- };
+ 128, 160, 192, 224, 256, 320, 384, 448,
+ 512, 576, 640};
static uint8_t lfeon[8] = {0x10, 0x10, 0x04, 0x04, 0x04, 0x01, 0x04, 0x01};
int frmsizecod;
int bitrate;
int half;
int acmod;
- if((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */
- return 0;
+ if ((buf[0] != 0x0b) || (buf[1] != 0x77)) /* syncword */
+ return 0;
- if(buf[5] >= 0x60) /* bsid >= 12 */
- return 0;
+ if (buf[5] >= 0x60) /* bsid >= 12 */
+ return 0;
half = halfrate[buf[5] >> 3];
/* acmod, dsurmod and lfeon */
acmod = buf[6] >> 5;
*flags = ((((buf[6] & 0xf8) == 0x50) ? A52_DOLBY : acmod) |
- ((buf[6] & lfeon[acmod]) ? A52_LFE : 0));
+ ((buf[6] & lfeon[acmod]) ? A52_LFE : 0));
frmsizecod = buf[4] & 63;
- if(frmsizecod >= 38)
- return 0;
+ if (frmsizecod >= 38)
+ return 0;
bitrate = rate [frmsizecod >> 1];
*bit_rate = (bitrate * 1000) >> half;
- switch(buf[4] & 0xc0)
- {
+ switch (buf[4] & 0xc0) {
case 0:
- *sample_rate = 48000 >> half;
- return 4 * bitrate;
+ *sample_rate = 48000 >> half;
+ return 4 * bitrate;
case 0x40:
- *sample_rate = 44100 >> half;
- return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
+ *sample_rate = 44100 >> half;
+ return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
case 0x80:
- *sample_rate = 32000 >> half;
- return 6 * bitrate;
+ *sample_rate = 32000 >> half;
+ return 6 * bitrate;
default:
- return 0;
+ return 0;
}
}
-int a52_frame(a52_state_t * state, uint8_t * buf, int * flags,
- sample_t * level, sample_t bias)
+int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
+ sample_t * level, sample_t bias)
{
static sample_t clev[4] = {LEVEL_3DB, LEVEL_45DB, LEVEL_6DB, LEVEL_45DB};
static sample_t slev[4] = {LEVEL_3DB, LEVEL_6DB, 0, LEVEL_6DB};
@@ -148,28 +144,28 @@ int a52_frame(a52_state_t * state, uint8_t * buf, int * flags, state->halfrate = halfrate[buf[5] >> 3];
state->acmod = acmod = buf[6] >> 5;
- a52_bitstream_set_ptr(state, buf + 6);
- bitstream_get(state, 3); /* skip acmod we already parsed */
+ a52_bitstream_set_ptr (state, buf + 6);
+ bitstream_get (state, 3); /* skip acmod we already parsed */
- if((acmod == 2) && (bitstream_get(state, 2) == 2)) /* dsurmod */
- acmod = A52_DOLBY;
+ if ((acmod == 2) && (bitstream_get (state, 2) == 2)) /* dsurmod */
+ acmod = A52_DOLBY;
state->clev = state->slev = 0;
- if((acmod & 1) && (acmod != 1))
- state->clev = clev[bitstream_get(state, 2)]; /* cmixlev */
+ if ((acmod & 1) && (acmod != 1))
+ state->clev = clev[bitstream_get (state, 2)]; /* cmixlev */
- if(acmod & 4)
- state->slev = slev[bitstream_get(state, 2)]; /* surmixlev */
+ if (acmod & 4)
+ state->slev = slev[bitstream_get (state, 2)]; /* surmixlev */
- state->lfeon = bitstream_get(state, 1);
+ state->lfeon = bitstream_get (state, 1);
- state->output = a52_downmix_init(acmod, *flags, level,
- state->clev, state->slev);
- if(state->output < 0)
- return 1;
- if(state->lfeon && (*flags & A52_LFE))
- state->output |= A52_LFE;
+ state->output = a52_downmix_init (acmod, *flags, level,
+ state->clev, state->slev);
+ if (state->output < 0)
+ return 1;
+ if (state->lfeon && (*flags & A52_LFE))
+ state->output |= A52_LFE;
*flags = state->output;
/* the 2* compensates for differences in imdct */
state->dynrng = state->level = 2 * *level;
@@ -178,273 +174,247 @@ int a52_frame(a52_state_t * state, uint8_t * buf, int * flags, state->dynrngcall = NULL;
state->cplba.deltbae = DELTA_BIT_NONE;
state->ba[0].deltbae = state->ba[1].deltbae = state->ba[2].deltbae =
- state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE;
+ state->ba[3].deltbae = state->ba[4].deltbae = DELTA_BIT_NONE;
chaninfo = !acmod;
- do
- {
- bitstream_get(state, 5); /* dialnorm */
- if(bitstream_get(state, 1)) /* compre */
- bitstream_get(state, 8); /* compr */
- if(bitstream_get(state, 1)) /* langcode */
- bitstream_get(state, 8); /* langcod */
- if(bitstream_get(state, 1)) /* audprodie */
- bitstream_get(state, 7); /* mixlevel + roomtyp */
- }
- while(chaninfo--);
-
- bitstream_get(state, 2); /* copyrightb + origbs */
-
- if(bitstream_get(state, 1)) /* timecod1e */
- bitstream_get(state, 14); /* timecod1 */
- if(bitstream_get(state, 1)) /* timecod2e */
- bitstream_get(state, 14); /* timecod2 */
-
- if(bitstream_get(state, 1)) /* addbsie */
- {
- int addbsil;
-
- addbsil = bitstream_get(state, 6);
- do
- {
- bitstream_get(state, 8); /* addbsi */
- }
- while(addbsil--);
+ do {
+ bitstream_get (state, 5); /* dialnorm */
+ if (bitstream_get (state, 1)) /* compre */
+ bitstream_get (state, 8); /* compr */
+ if (bitstream_get (state, 1)) /* langcode */
+ bitstream_get (state, 8); /* langcod */
+ if (bitstream_get (state, 1)) /* audprodie */
+ bitstream_get (state, 7); /* mixlevel + roomtyp */
+ } while (chaninfo--);
+
+ bitstream_get (state, 2); /* copyrightb + origbs */
+
+ if (bitstream_get (state, 1)) /* timecod1e */
+ bitstream_get (state, 14); /* timecod1 */
+ if (bitstream_get (state, 1)) /* timecod2e */
+ bitstream_get (state, 14); /* timecod2 */
+
+ if (bitstream_get (state, 1)) { /* addbsie */
+ int addbsil;
+
+ addbsil = bitstream_get (state, 6);
+ do {
+ bitstream_get (state, 8); /* addbsi */
+ } while (addbsil--);
}
return 0;
}
-void a52_dynrng(a52_state_t * state,
- sample_t (* call)(sample_t, void *), void * data)
+void a52_dynrng (a52_state_t * state,
+ sample_t (* call) (sample_t, void *), void * data)
{
state->dynrnge = 0;
- if(call)
- {
- state->dynrnge = 1;
- state->dynrngcall = call;
- state->dynrngdata = data;
+ if (call) {
+ state->dynrnge = 1;
+ state->dynrngcall = call;
+ state->dynrngdata = data;
}
}
-static int parse_exponents(a52_state_t * state, int expstr, int ngrps,
- uint8_t exponent, uint8_t * dest)
+static int parse_exponents (a52_state_t * state, int expstr, int ngrps,
+ uint8_t exponent, uint8_t * dest)
{
int exps;
- while(ngrps--)
- {
- exps = bitstream_get(state, 7);
-
- exponent += exp_1[exps];
- if(exponent > 24)
- return 1;
-
- switch(expstr)
- {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
-
- exponent += exp_2[exps];
- if(exponent > 24)
- return 1;
-
- switch(expstr)
- {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
-
- exponent += exp_3[exps];
- if(exponent > 24)
- return 1;
-
- switch(expstr)
- {
- case EXP_D45:
- *(dest++) = exponent;
- *(dest++) = exponent;
- case EXP_D25:
- *(dest++) = exponent;
- case EXP_D15:
- *(dest++) = exponent;
- }
- }
+ while (ngrps--) {
+ exps = bitstream_get (state, 7);
+
+ exponent += exp_1[exps];
+ if (exponent > 24)
+ return 1;
+
+ switch (expstr) {
+ case EXP_D45:
+ *(dest++) = exponent;
+ *(dest++) = exponent;
+ case EXP_D25:
+ *(dest++) = exponent;
+ case EXP_D15:
+ *(dest++) = exponent;
+ }
+
+ exponent += exp_2[exps];
+ if (exponent > 24)
+ return 1;
+
+ switch (expstr) {
+ case EXP_D45:
+ *(dest++) = exponent;
+ *(dest++) = exponent;
+ case EXP_D25:
+ *(dest++) = exponent;
+ case EXP_D15:
+ *(dest++) = exponent;
+ }
+
+ exponent += exp_3[exps];
+ if (exponent > 24)
+ return 1;
+
+ switch (expstr) {
+ case EXP_D45:
+ *(dest++) = exponent;
+ *(dest++) = exponent;
+ case EXP_D25:
+ *(dest++) = exponent;
+ case EXP_D15:
+ *(dest++) = exponent;
+ }
+ }
return 0;
}
-static int parse_deltba(a52_state_t * state, int8_t * deltba)
+static int parse_deltba (a52_state_t * state, int8_t * deltba)
{
int deltnseg, deltlen, delta, j;
- memset(deltba, 0, 50);
+ memset (deltba, 0, 50);
- deltnseg = bitstream_get(state, 3);
+ deltnseg = bitstream_get (state, 3);
j = 0;
- do
- {
- j += bitstream_get(state, 5);
- deltlen = bitstream_get(state, 4);
- delta = bitstream_get(state, 3);
- delta -= (delta >= 4) ? 3 : 4;
- if(!deltlen)
- continue;
- if(j + deltlen >= 50)
- return 1;
- while(deltlen--)
- deltba[j++] = delta;
- }
- while(deltnseg--);
+ do {
+ j += bitstream_get (state, 5);
+ deltlen = bitstream_get (state, 4);
+ delta = bitstream_get (state, 3);
+ delta -= (delta >= 4) ? 3 : 4;
+ if (!deltlen)
+ continue;
+ if (j + deltlen >= 50)
+ return 1;
+ while (deltlen--)
+ deltba[j++] = delta;
+ } while (deltnseg--);
return 0;
}
-static inline int zero_snr_offsets(int nfchans, a52_state_t * state)
+static inline int zero_snr_offsets (int nfchans, a52_state_t * state)
{
int i;
- if((state->csnroffst) ||
- (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */
- (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */
- return 0;
- for(i = 0; i < nfchans; i++)
- if(state->ba[i].bai >> 3) /* fsnroffst */
- return 0;
+ if ((state->csnroffst) ||
+ (state->chincpl && state->cplba.bai >> 3) || /* cplinu, fsnroffst */
+ (state->lfeon && state->lfeba.bai >> 3)) /* fsnroffst */
+ return 0;
+ for (i = 0; i < nfchans; i++)
+ if (state->ba[i].bai >> 3) /* fsnroffst */
+ return 0;
return 1;
}
-static inline int16_t dither_gen(a52_state_t * state)
+static inline int16_t dither_gen (a52_state_t * state)
{
int16_t nstate;
- nstate = dither_lut[state->lfsr_state >> 8] ^(state->lfsr_state << 8);
-
+ nstate = dither_lut[state->lfsr_state >> 8] ^ (state->lfsr_state << 8);
+
state->lfsr_state = (uint16_t) nstate;
return nstate;
}
-static void coeff_get(a52_state_t * state, sample_t * coeff,
- expbap_t * expbap, quantizer_t * quantizer,
- sample_t level, int dither, int end)
+static void coeff_get (a52_state_t * state, sample_t * coeff,
+ expbap_t * expbap, quantizer_t * quantizer,
+ sample_t level, int dither, int end)
{
int i;
uint8_t * exp;
int8_t * bap;
sample_t factor[25];
- for(i = 0; i <= 24; i++)
- factor[i] = scale_factor[i] * level;
+ for (i = 0; i <= 24; i++)
+ factor[i] = scale_factor[i] * level;
exp = expbap->exp;
bap = expbap->bap;
- for(i = 0; i < end; i++)
- {
- int bapi;
-
- bapi = bap[i];
- switch(bapi)
- {
- case 0:
- if(dither)
- {
- coeff[i] = dither_gen(state) * LEVEL_3DB * factor[exp[i]];
- continue;
- }
- else
- {
- coeff[i] = 0;
- continue;
- }
-
- case -1:
- if(quantizer->q1_ptr >= 0)
- {
- coeff[i] = quantizer->q1[quantizer->q1_ptr--] * factor[exp[i]];
- continue;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 5);
-
- quantizer->q1_ptr = 1;
- quantizer->q1[0] = q_1_2[code];
- quantizer->q1[1] = q_1_1[code];
- coeff[i] = q_1_0[code] * factor[exp[i]];
- continue;
- }
-
- case -2:
- if(quantizer->q2_ptr >= 0)
- {
- coeff[i] = quantizer->q2[quantizer->q2_ptr--] * factor[exp[i]];
- continue;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 7);
-
- quantizer->q2_ptr = 1;
- quantizer->q2[0] = q_2_2[code];
- quantizer->q2[1] = q_2_1[code];
- coeff[i] = q_2_0[code] * factor[exp[i]];
- continue;
- }
-
- case 3:
- coeff[i] = q_3[bitstream_get(state, 3)] * factor[exp[i]];
- continue;
-
- case -3:
- if(quantizer->q4_ptr == 0)
- {
- quantizer->q4_ptr = -1;
- coeff[i] = quantizer->q4 * factor[exp[i]];
- continue;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 7);
-
- quantizer->q4_ptr = 0;
- quantizer->q4 = q_4_1[code];
- coeff[i] = q_4_0[code] * factor[exp[i]];
- continue;
- }
-
- case 4:
- coeff[i] = q_5[bitstream_get(state, 4)] * factor[exp[i]];
- continue;
-
- default:
- coeff[i] = ((bitstream_get_2(state, bapi) << (16 - bapi)) *
- factor[exp[i]]);
- }
+ for (i = 0; i < end; i++) {
+ int bapi;
+
+ bapi = bap[i];
+ switch (bapi) {
+ case 0:
+ if (dither) {
+ coeff[i] = dither_gen (state) * LEVEL_3DB * factor[exp[i]];
+ continue;
+ } else {
+ coeff[i] = 0;
+ continue;
+ }
+
+ case -1:
+ if (quantizer->q1_ptr >= 0) {
+ coeff[i] = quantizer->q1[quantizer->q1_ptr--] * factor[exp[i]];
+ continue;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 5);
+
+ quantizer->q1_ptr = 1;
+ quantizer->q1[0] = q_1_2[code];
+ quantizer->q1[1] = q_1_1[code];
+ coeff[i] = q_1_0[code] * factor[exp[i]];
+ continue;
+ }
+
+ case -2:
+ if (quantizer->q2_ptr >= 0) {
+ coeff[i] = quantizer->q2[quantizer->q2_ptr--] * factor[exp[i]];
+ continue;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 7);
+
+ quantizer->q2_ptr = 1;
+ quantizer->q2[0] = q_2_2[code];
+ quantizer->q2[1] = q_2_1[code];
+ coeff[i] = q_2_0[code] * factor[exp[i]];
+ continue;
+ }
+
+ case 3:
+ coeff[i] = q_3[bitstream_get (state, 3)] * factor[exp[i]];
+ continue;
+
+ case -3:
+ if (quantizer->q4_ptr == 0) {
+ quantizer->q4_ptr = -1;
+ coeff[i] = quantizer->q4 * factor[exp[i]];
+ continue;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 7);
+
+ quantizer->q4_ptr = 0;
+ quantizer->q4 = q_4_1[code];
+ coeff[i] = q_4_0[code] * factor[exp[i]];
+ continue;
+ }
+
+ case 4:
+ coeff[i] = q_5[bitstream_get (state, 4)] * factor[exp[i]];
+ continue;
+
+ default:
+ coeff[i] = ((bitstream_get_2 (state, bapi) << (16 - bapi)) *
+ factor[exp[i]]);
+ }
}
}
-static void coeff_get_coupling(a52_state_t * state, int nfchans,
- sample_t * coeff, sample_t (* samples)[256],
- quantizer_t * quantizer, uint8_t dithflag[5])
+static void coeff_get_coupling (a52_state_t * state, int nfchans,
+ sample_t * coeff, sample_t (* samples)[256],
+ quantizer_t * quantizer, uint8_t dithflag[5])
{
int cplbndstrc, bnd, i, i_end, ch;
uint8_t * exp;
@@ -456,120 +426,106 @@ static void coeff_get_coupling(a52_state_t * state, int nfchans, bnd = 0;
cplbndstrc = state->cplbndstrc;
i = state->cplstrtmant;
- while(i < state->cplendmant)
- {
- i_end = i + 12;
- while(cplbndstrc & 1)
- {
- cplbndstrc >>= 1;
- i_end += 12;
- }
- cplbndstrc >>= 1;
- for(ch = 0; ch < nfchans; ch++)
- cplco[ch] = state->cplco[ch][bnd] * coeff[ch];
- bnd++;
-
- while(i < i_end)
- {
- sample_t cplcoeff;
- int bapi;
-
- bapi = bap[i];
- switch(bapi)
- {
- case 0:
- cplcoeff = LEVEL_3DB * scale_factor[exp[i]];
- for(ch = 0; ch < nfchans; ch++)
- if((state->chincpl >> ch) & 1)
- {
- if(dithflag[ch])
- samples[ch][i] = (cplcoeff * cplco[ch] *
- dither_gen(state));
- else
- samples[ch][i] = 0;
- }
- i++;
- continue;
-
- case -1:
- if(quantizer->q1_ptr >= 0)
- {
- cplcoeff = quantizer->q1[quantizer->q1_ptr--];
- break;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 5);
-
- quantizer->q1_ptr = 1;
- quantizer->q1[0] = q_1_2[code];
- quantizer->q1[1] = q_1_1[code];
- cplcoeff = q_1_0[code];
- break;
- }
-
- case -2:
- if(quantizer->q2_ptr >= 0)
- {
- cplcoeff = quantizer->q2[quantizer->q2_ptr--];
- break;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 7);
-
- quantizer->q2_ptr = 1;
- quantizer->q2[0] = q_2_2[code];
- quantizer->q2[1] = q_2_1[code];
- cplcoeff = q_2_0[code];
- break;
- }
-
- case 3:
- cplcoeff = q_3[bitstream_get(state, 3)];
- break;
-
- case -3:
- if(quantizer->q4_ptr == 0)
- {
- quantizer->q4_ptr = -1;
- cplcoeff = quantizer->q4;
- break;
- }
- else
- {
- int code;
-
- code = bitstream_get(state, 7);
-
- quantizer->q4_ptr = 0;
- quantizer->q4 = q_4_1[code];
- cplcoeff = q_4_0[code];
- break;
- }
-
- case 4:
- cplcoeff = q_5[bitstream_get(state, 4)];
- break;
-
- default:
- cplcoeff = bitstream_get_2(state, bapi) << (16 - bapi);
- }
-
- cplcoeff *= scale_factor[exp[i]];
- for(ch = 0; ch < nfchans; ch++)
- if((state->chincpl >> ch) & 1)
- samples[ch][i] = cplcoeff * cplco[ch];
- i++;
- }
+ while (i < state->cplendmant) {
+ i_end = i + 12;
+ while (cplbndstrc & 1) {
+ cplbndstrc >>= 1;
+ i_end += 12;
+ }
+ cplbndstrc >>= 1;
+ for (ch = 0; ch < nfchans; ch++)
+ cplco[ch] = state->cplco[ch][bnd] * coeff[ch];
+ bnd++;
+
+ while (i < i_end) {
+ sample_t cplcoeff;
+ int bapi;
+
+ bapi = bap[i];
+ switch (bapi) {
+ case 0:
+ cplcoeff = LEVEL_3DB * scale_factor[exp[i]];
+ for (ch = 0; ch < nfchans; ch++)
+ if ((state->chincpl >> ch) & 1) {
+ if (dithflag[ch])
+ samples[ch][i] = (cplcoeff * cplco[ch] *
+ dither_gen (state));
+ else
+ samples[ch][i] = 0;
+ }
+ i++;
+ continue;
+
+ case -1:
+ if (quantizer->q1_ptr >= 0) {
+ cplcoeff = quantizer->q1[quantizer->q1_ptr--];
+ break;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 5);
+
+ quantizer->q1_ptr = 1;
+ quantizer->q1[0] = q_1_2[code];
+ quantizer->q1[1] = q_1_1[code];
+ cplcoeff = q_1_0[code];
+ break;
+ }
+
+ case -2:
+ if (quantizer->q2_ptr >= 0) {
+ cplcoeff = quantizer->q2[quantizer->q2_ptr--];
+ break;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 7);
+
+ quantizer->q2_ptr = 1;
+ quantizer->q2[0] = q_2_2[code];
+ quantizer->q2[1] = q_2_1[code];
+ cplcoeff = q_2_0[code];
+ break;
+ }
+
+ case 3:
+ cplcoeff = q_3[bitstream_get (state, 3)];
+ break;
+
+ case -3:
+ if (quantizer->q4_ptr == 0) {
+ quantizer->q4_ptr = -1;
+ cplcoeff = quantizer->q4;
+ break;
+ } else {
+ int code;
+
+ code = bitstream_get (state, 7);
+
+ quantizer->q4_ptr = 0;
+ quantizer->q4 = q_4_1[code];
+ cplcoeff = q_4_0[code];
+ break;
+ }
+
+ case 4:
+ cplcoeff = q_5[bitstream_get (state, 4)];
+ break;
+
+ default:
+ cplcoeff = bitstream_get_2 (state, bapi) << (16 - bapi);
+ }
+
+ cplcoeff *= scale_factor[exp[i]];
+ for (ch = 0; ch < nfchans; ch++)
+ if ((state->chincpl >> ch) & 1)
+ samples[ch][i] = cplcoeff * cplco[ch];
+ i++;
+ }
}
}
-int a52_block(a52_state_t * state)
+int a52_block (a52_state_t * state)
{
static const uint8_t nfchans_tbl[] = {2, 1, 2, 3, 3, 4, 4, 5, 1, 1, 2};
static int rematrix_band[4] = {25, 37, 61, 253};
@@ -583,421 +539,369 @@ int a52_block(a52_state_t * state) nfchans = nfchans_tbl[state->acmod];
- for(i = 0; i < nfchans; i++)
- blksw[i] = bitstream_get(state, 1);
+ for (i = 0; i < nfchans; i++)
+ blksw[i] = bitstream_get (state, 1);
- for(i = 0; i < nfchans; i++)
- dithflag[i] = bitstream_get(state, 1);
+ for (i = 0; i < nfchans; i++)
+ dithflag[i] = bitstream_get (state, 1);
chaninfo = !state->acmod;
- do
- {
- if(bitstream_get(state, 1)) /* dynrnge */
- {
- int dynrng;
-
- dynrng = bitstream_get_2(state, 8);
- if(state->dynrnge)
- {
- sample_t range;
-
- range = ((((dynrng & 0x1f) | 0x20) << 13) *
- scale_factor[3 - (dynrng >> 5)]);
- if(state->dynrngcall)
- range = state->dynrngcall(range, state->dynrngdata);
- state->dynrng = state->level * range;
- }
- }
- }
- while(chaninfo--);
-
- if(bitstream_get(state, 1)) /* cplstre */
- {
- state->chincpl = 0;
- if(bitstream_get(state, 1)) /* cplinu */
- {
- static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,
- 45, 45, 46, 46, 47, 47, 48, 48
- };
- int cplbegf;
- int cplendf;
- int ncplsubnd;
-
- for(i = 0; i < nfchans; i++)
- state->chincpl |= bitstream_get(state, 1) << i;
- switch(state->acmod)
- {
- case 0:
- case 1:
- return 1;
- case 2:
- state->phsflginu = bitstream_get(state, 1);
- }
- cplbegf = bitstream_get(state, 4);
- cplendf = bitstream_get(state, 4);
-
- if(cplendf + 3 - cplbegf < 0)
- return 1;
- state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;
- state->cplstrtbnd = bndtab[cplbegf];
- state->cplstrtmant = cplbegf * 12 + 37;
- state->cplendmant = cplendf * 12 + 73;
-
- state->cplbndstrc = 0;
- for(i = 0; i < ncplsubnd - 1; i++)
- if(bitstream_get(state, 1))
- {
- state->cplbndstrc |= 1 << i;
- state->ncplbnd--;
- }
- }
+ do {
+ if (bitstream_get (state, 1)) { /* dynrnge */
+ int dynrng;
+
+ dynrng = bitstream_get_2 (state, 8);
+ if (state->dynrnge) {
+ sample_t range;
+
+ range = ((((dynrng & 0x1f) | 0x20) << 13) *
+ scale_factor[3 - (dynrng >> 5)]);
+ if (state->dynrngcall)
+ range = state->dynrngcall (range, state->dynrngdata);
+ state->dynrng = state->level * range;
+ }
+ }
+ } while (chaninfo--);
+
+ if (bitstream_get (state, 1)) { /* cplstre */
+ state->chincpl = 0;
+ if (bitstream_get (state, 1)) { /* cplinu */
+ static uint8_t bndtab[16] = {31, 35, 37, 39, 41, 42, 43, 44,
+ 45, 45, 46, 46, 47, 47, 48, 48};
+ int cplbegf;
+ int cplendf;
+ int ncplsubnd;
+
+ for (i = 0; i < nfchans; i++)
+ state->chincpl |= bitstream_get (state, 1) << i;
+ switch (state->acmod) {
+ case 0: case 1:
+ return 1;
+ case 2:
+ state->phsflginu = bitstream_get (state, 1);
+ }
+ cplbegf = bitstream_get (state, 4);
+ cplendf = bitstream_get (state, 4);
+
+ if (cplendf + 3 - cplbegf < 0)
+ return 1;
+ state->ncplbnd = ncplsubnd = cplendf + 3 - cplbegf;
+ state->cplstrtbnd = bndtab[cplbegf];
+ state->cplstrtmant = cplbegf * 12 + 37;
+ state->cplendmant = cplendf * 12 + 73;
+
+ state->cplbndstrc = 0;
+ for (i = 0; i < ncplsubnd - 1; i++)
+ if (bitstream_get (state, 1)) {
+ state->cplbndstrc |= 1 << i;
+ state->ncplbnd--;
+ }
+ }
}
- if(state->chincpl) /* cplinu */
- {
- int j, cplcoe;
-
- cplcoe = 0;
- for(i = 0; i < nfchans; i++)
- if((state->chincpl) >> i & 1)
- if(bitstream_get(state, 1)) /* cplcoe */
- {
- int mstrcplco, cplcoexp, cplcomant;
-
- cplcoe = 1;
- mstrcplco = 3 * bitstream_get(state, 2);
- for(j = 0; j < state->ncplbnd; j++)
- {
- cplcoexp = bitstream_get(state, 4);
- cplcomant = bitstream_get(state, 4);
- if(cplcoexp == 15)
- cplcomant <<= 14;
- else
- cplcomant = (cplcomant | 0x10) << 13;
- state->cplco[i][j] =
- cplcomant * scale_factor[cplcoexp + mstrcplco];
- }
- }
- if((state->acmod == 2) && state->phsflginu && cplcoe)
- for(j = 0; j < state->ncplbnd; j++)
- if(bitstream_get(state, 1)) /* phsflg */
- state->cplco[1][j] = -state->cplco[1][j];
+ if (state->chincpl) { /* cplinu */
+ int j, cplcoe;
+
+ cplcoe = 0;
+ for (i = 0; i < nfchans; i++)
+ if ((state->chincpl) >> i & 1)
+ if (bitstream_get (state, 1)) { /* cplcoe */
+ int mstrcplco, cplcoexp, cplcomant;
+
+ cplcoe = 1;
+ mstrcplco = 3 * bitstream_get (state, 2);
+ for (j = 0; j < state->ncplbnd; j++) {
+ cplcoexp = bitstream_get (state, 4);
+ cplcomant = bitstream_get (state, 4);
+ if (cplcoexp == 15)
+ cplcomant <<= 14;
+ else
+ cplcomant = (cplcomant | 0x10) << 13;
+ state->cplco[i][j] =
+ cplcomant * scale_factor[cplcoexp + mstrcplco];
+ }
+ }
+ if ((state->acmod == 2) && state->phsflginu && cplcoe)
+ for (j = 0; j < state->ncplbnd; j++)
+ if (bitstream_get (state, 1)) /* phsflg */
+ state->cplco[1][j] = -state->cplco[1][j];
}
- if((state->acmod == 2) && (bitstream_get(state, 1))) /* rematstr */
- {
- int end;
+ if ((state->acmod == 2) && (bitstream_get (state, 1))) { /* rematstr */
+ int end;
- state->rematflg = 0;
- end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */
- i = 0;
- do
- state->rematflg |= bitstream_get(state, 1) << i;
- while(rematrix_band[i++] < end);
+ state->rematflg = 0;
+ end = (state->chincpl) ? state->cplstrtmant : 253; /* cplinu */
+ i = 0;
+ do
+ state->rematflg |= bitstream_get (state, 1) << i;
+ while (rematrix_band[i++] < end);
}
cplexpstr = EXP_REUSE;
lfeexpstr = EXP_REUSE;
- if(state->chincpl) /* cplinu */
- cplexpstr = bitstream_get(state, 2);
- for(i = 0; i < nfchans; i++)
- chexpstr[i] = bitstream_get(state, 2);
- if(state->lfeon)
- lfeexpstr = bitstream_get(state, 1);
-
- for(i = 0; i < nfchans; i++)
- if(chexpstr[i] != EXP_REUSE)
- {
- if((state->chincpl >> i) & 1)
- state->endmant[i] = state->cplstrtmant;
- else
- {
- int chbwcod;
-
- chbwcod = bitstream_get(state, 6);
- if(chbwcod > 60)
- return 1;
- state->endmant[i] = chbwcod * 3 + 73;
- }
- }
+ if (state->chincpl) /* cplinu */
+ cplexpstr = bitstream_get (state, 2);
+ for (i = 0; i < nfchans; i++)
+ chexpstr[i] = bitstream_get (state, 2);
+ if (state->lfeon)
+ lfeexpstr = bitstream_get (state, 1);
+
+ for (i = 0; i < nfchans; i++)
+ if (chexpstr[i] != EXP_REUSE) {
+ if ((state->chincpl >> i) & 1)
+ state->endmant[i] = state->cplstrtmant;
+ else {
+ int chbwcod;
+
+ chbwcod = bitstream_get (state, 6);
+ if (chbwcod > 60)
+ return 1;
+ state->endmant[i] = chbwcod * 3 + 73;
+ }
+ }
do_bit_alloc = 0;
- if(cplexpstr != EXP_REUSE)
- {
- int cplabsexp, ncplgrps;
-
- do_bit_alloc = 64;
- ncplgrps = ((state->cplendmant - state->cplstrtmant) /
- (3 << (cplexpstr - 1)));
- cplabsexp = bitstream_get(state, 4) << 1;
- if(parse_exponents(state, cplexpstr, ncplgrps, cplabsexp,
- state->cpl_expbap.exp + state->cplstrtmant))
- return 1;
+ if (cplexpstr != EXP_REUSE) {
+ int cplabsexp, ncplgrps;
+
+ do_bit_alloc = 64;
+ ncplgrps = ((state->cplendmant - state->cplstrtmant) /
+ (3 << (cplexpstr - 1)));
+ cplabsexp = bitstream_get (state, 4) << 1;
+ if (parse_exponents (state, cplexpstr, ncplgrps, cplabsexp,
+ state->cpl_expbap.exp + state->cplstrtmant))
+ return 1;
}
- for(i = 0; i < nfchans; i++)
- if(chexpstr[i] != EXP_REUSE)
- {
- int grp_size, nchgrps;
-
- do_bit_alloc |= 1 << i;
- grp_size = 3 << (chexpstr[i] - 1);
- nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;
- state->fbw_expbap[i].exp[0] = bitstream_get(state, 4);
- if(parse_exponents(state, chexpstr[i], nchgrps,
- state->fbw_expbap[i].exp[0],
- state->fbw_expbap[i].exp + 1))
- return 1;
- bitstream_get(state, 2); /* gainrng */
- }
- if(lfeexpstr != EXP_REUSE)
- {
- do_bit_alloc |= 32;
- state->lfe_expbap.exp[0] = bitstream_get(state, 4);
- if(parse_exponents(state, lfeexpstr, 2, state->lfe_expbap.exp[0],
- state->lfe_expbap.exp + 1))
- return 1;
+ for (i = 0; i < nfchans; i++)
+ if (chexpstr[i] != EXP_REUSE) {
+ int grp_size, nchgrps;
+
+ do_bit_alloc |= 1 << i;
+ grp_size = 3 << (chexpstr[i] - 1);
+ nchgrps = (state->endmant[i] + grp_size - 4) / grp_size;
+ state->fbw_expbap[i].exp[0] = bitstream_get (state, 4);
+ if (parse_exponents (state, chexpstr[i], nchgrps,
+ state->fbw_expbap[i].exp[0],
+ state->fbw_expbap[i].exp + 1))
+ return 1;
+ bitstream_get (state, 2); /* gainrng */
+ }
+ if (lfeexpstr != EXP_REUSE) {
+ do_bit_alloc |= 32;
+ state->lfe_expbap.exp[0] = bitstream_get (state, 4);
+ if (parse_exponents (state, lfeexpstr, 2, state->lfe_expbap.exp[0],
+ state->lfe_expbap.exp + 1))
+ return 1;
}
- if(bitstream_get(state, 1)) /* baie */
- {
- do_bit_alloc = 127;
- state->bai = bitstream_get(state, 11);
+ if (bitstream_get (state, 1)) { /* baie */
+ do_bit_alloc = 127;
+ state->bai = bitstream_get (state, 11);
}
- if(bitstream_get(state, 1)) /* snroffste */
- {
- do_bit_alloc = 127;
- state->csnroffst = bitstream_get(state, 6);
- if(state->chincpl) /* cplinu */
- state->cplba.bai = bitstream_get(state, 7);
- for(i = 0; i < nfchans; i++)
- state->ba[i].bai = bitstream_get(state, 7);
- if(state->lfeon)
- state->lfeba.bai = bitstream_get(state, 7);
+ if (bitstream_get (state, 1)) { /* snroffste */
+ do_bit_alloc = 127;
+ state->csnroffst = bitstream_get (state, 6);
+ if (state->chincpl) /* cplinu */
+ state->cplba.bai = bitstream_get (state, 7);
+ for (i = 0; i < nfchans; i++)
+ state->ba[i].bai = bitstream_get (state, 7);
+ if (state->lfeon)
+ state->lfeba.bai = bitstream_get (state, 7);
}
- if((state->chincpl) && (bitstream_get(state, 1))) /* cplleake */
- {
- do_bit_alloc |= 64;
- state->cplfleak = 9 - bitstream_get(state, 3);
- state->cplsleak = 9 - bitstream_get(state, 3);
+ if ((state->chincpl) && (bitstream_get (state, 1))) { /* cplleake */
+ do_bit_alloc |= 64;
+ state->cplfleak = 9 - bitstream_get (state, 3);
+ state->cplsleak = 9 - bitstream_get (state, 3);
}
- if(bitstream_get(state, 1)) /* deltbaie */
- {
- do_bit_alloc = 127;
- if(state->chincpl) /* cplinu */
- state->cplba.deltbae = bitstream_get(state, 2);
- for(i = 0; i < nfchans; i++)
- state->ba[i].deltbae = bitstream_get(state, 2);
- if(state->chincpl && /* cplinu */
- (state->cplba.deltbae == DELTA_BIT_NEW) &&
- parse_deltba(state, state->cplba.deltba))
- return 1;
- for(i = 0; i < nfchans; i++)
- if((state->ba[i].deltbae == DELTA_BIT_NEW) &&
- parse_deltba(state, state->ba[i].deltba))
- return 1;
+ if (bitstream_get (state, 1)) { /* deltbaie */
+ do_bit_alloc = 127;
+ if (state->chincpl) /* cplinu */
+ state->cplba.deltbae = bitstream_get (state, 2);
+ for (i = 0; i < nfchans; i++)
+ state->ba[i].deltbae = bitstream_get (state, 2);
+ if (state->chincpl && /* cplinu */
+ (state->cplba.deltbae == DELTA_BIT_NEW) &&
+ parse_deltba (state, state->cplba.deltba))
+ return 1;
+ for (i = 0; i < nfchans; i++)
+ if ((state->ba[i].deltbae == DELTA_BIT_NEW) &&
+ parse_deltba (state, state->ba[i].deltba))
+ return 1;
}
- if(do_bit_alloc)
- {
- if(zero_snr_offsets(nfchans, state))
- {
- memset(state->cpl_expbap.bap, 0, sizeof(state->cpl_expbap.bap));
- for(i = 0; i < nfchans; i++)
- memset(state->fbw_expbap[i].bap, 0,
- sizeof(state->fbw_expbap[i].bap));
- memset(state->lfe_expbap.bap, 0, sizeof(state->lfe_expbap.bap));
- }
- else
- {
- if(state->chincpl && (do_bit_alloc & 64)) /* cplinu */
- a52_bit_allocate(state, &state->cplba, state->cplstrtbnd,
- state->cplstrtmant, state->cplendmant,
- state->cplfleak << 8, state->cplsleak << 8,
- &state->cpl_expbap);
- for(i = 0; i < nfchans; i++)
- if(do_bit_alloc & (1 << i))
- a52_bit_allocate(state, state->ba + i, 0, 0,
- state->endmant[i], 0, 0,
- state->fbw_expbap + i);
- if(state->lfeon && (do_bit_alloc & 32))
- {
- state->lfeba.deltbae = DELTA_BIT_NONE;
- a52_bit_allocate(state, &state->lfeba, 0, 0, 7, 0, 0,
- &state->lfe_expbap);
- }
- }
+ if (do_bit_alloc) {
+ if (zero_snr_offsets (nfchans, state)) {
+ memset (state->cpl_expbap.bap, 0, sizeof (state->cpl_expbap.bap));
+ for (i = 0; i < nfchans; i++)
+ memset (state->fbw_expbap[i].bap, 0,
+ sizeof (state->fbw_expbap[i].bap));
+ memset (state->lfe_expbap.bap, 0, sizeof (state->lfe_expbap.bap));
+ } else {
+ if (state->chincpl && (do_bit_alloc & 64)) /* cplinu */
+ a52_bit_allocate (state, &state->cplba, state->cplstrtbnd,
+ state->cplstrtmant, state->cplendmant,
+ state->cplfleak << 8, state->cplsleak << 8,
+ &state->cpl_expbap);
+ for (i = 0; i < nfchans; i++)
+ if (do_bit_alloc & (1 << i))
+ a52_bit_allocate (state, state->ba + i, 0, 0,
+ state->endmant[i], 0, 0,
+ state->fbw_expbap +i);
+ if (state->lfeon && (do_bit_alloc & 32)) {
+ state->lfeba.deltbae = DELTA_BIT_NONE;
+ a52_bit_allocate (state, &state->lfeba, 0, 0, 7, 0, 0,
+ &state->lfe_expbap);
+ }
+ }
}
- if(bitstream_get(state, 1)) /* skiple */
- {
- i = bitstream_get(state, 9); /* skipl */
- while(i--)
- bitstream_get(state, 8);
+ if (bitstream_get (state, 1)) { /* skiple */
+ i = bitstream_get (state, 9); /* skipl */
+ while (i--)
+ bitstream_get (state, 8);
}
samples = state->samples;
- if(state->output & A52_LFE)
- samples += 256; /* shift for LFE channel */
+ if (state->output & A52_LFE)
+ samples += 256; /* shift for LFE channel */
- chanbias = a52_downmix_coeff(coeff, state->acmod, state->output,
- state->dynrng, state->clev, state->slev);
+ chanbias = a52_downmix_coeff (coeff, state->acmod, state->output,
+ state->dynrng, state->clev, state->slev);
quantizer.q1_ptr = quantizer.q2_ptr = quantizer.q4_ptr = -1;
done_cpl = 0;
- for(i = 0; i < nfchans; i++)
- {
- int j;
-
- coeff_get(state, samples + 256 * i, state->fbw_expbap + i, &quantizer,
- coeff[i], dithflag[i], state->endmant[i]);
-
- if((state->chincpl >> i) & 1)
- {
- if(!done_cpl)
- {
- done_cpl = 1;
- coeff_get_coupling(state, nfchans, coeff,
- (sample_t (*)[256])samples, &quantizer,
- dithflag);
- }
- j = state->cplendmant;
- }
- else
- j = state->endmant[i];
- do
- (samples + 256 * i)[j] = 0;
- while(++j < 256);
+ for (i = 0; i < nfchans; i++) {
+ int j;
+
+ coeff_get (state, samples + 256 * i, state->fbw_expbap +i, &quantizer,
+ coeff[i], dithflag[i], state->endmant[i]);
+
+ if ((state->chincpl >> i) & 1) {
+ if (!done_cpl) {
+ done_cpl = 1;
+ coeff_get_coupling (state, nfchans, coeff,
+ (sample_t (*)[256])samples, &quantizer,
+ dithflag);
+ }
+ j = state->cplendmant;
+ } else
+ j = state->endmant[i];
+ do
+ (samples + 256 * i)[j] = 0;
+ while (++j < 256);
}
- if(state->acmod == 2)
- {
- int j, end, band, rematflg;
-
- end = ((state->endmant[0] < state->endmant[1]) ?
- state->endmant[0] : state->endmant[1]);
-
- i = 0;
- j = 13;
- rematflg = state->rematflg;
- do
- {
- if(!(rematflg & 1))
- {
- rematflg >>= 1;
- j = rematrix_band[i++];
- continue;
- }
- rematflg >>= 1;
- band = rematrix_band[i++];
- if(band > end)
- band = end;
- do
- {
- sample_t tmp0, tmp1;
-
- tmp0 = samples[j];
- tmp1 = (samples + 256)[j];
- samples[j] = tmp0 + tmp1;
- (samples + 256)[j] = tmp0 - tmp1;
- }
- while(++j < band);
- }
- while(j < end);
+ if (state->acmod == 2) {
+ int j, end, band, rematflg;
+
+ end = ((state->endmant[0] < state->endmant[1]) ?
+ state->endmant[0] : state->endmant[1]);
+
+ i = 0;
+ j = 13;
+ rematflg = state->rematflg;
+ do {
+ if (! (rematflg & 1)) {
+ rematflg >>= 1;
+ j = rematrix_band[i++];
+ continue;
+ }
+ rematflg >>= 1;
+ band = rematrix_band[i++];
+ if (band > end)
+ band = end;
+ do {
+ sample_t tmp0, tmp1;
+
+ tmp0 = samples[j];
+ tmp1 = (samples+256)[j];
+ samples[j] = tmp0 + tmp1;
+ (samples+256)[j] = tmp0 - tmp1;
+ } while (++j < band);
+ } while (j < end);
}
- if(state->lfeon)
- {
- if(state->output & A52_LFE)
- {
- coeff_get(state, samples - 256, &state->lfe_expbap, &quantizer,
- state->dynrng, 0, 7);
- for(i = 7; i < 256; i++)
- (samples - 256)[i] = 0;
- a52_imdct_512(samples - 256, samples + 1536 - 256, state->bias);
- }
- else
- {
- /* just skip the LFE coefficients */
- coeff_get(state, samples + 1280, &state->lfe_expbap, &quantizer,
- 0, 0, 7);
- }
+ if (state->lfeon) {
+ if (state->output & A52_LFE) {
+ coeff_get (state, samples - 256, &state->lfe_expbap, &quantizer,
+ state->dynrng, 0, 7);
+ for (i = 7; i < 256; i++)
+ (samples-256)[i] = 0;
+ a52_imdct_512 (samples - 256, samples + 1536 - 256, state->bias);
+ } else {
+ /* just skip the LFE coefficients */
+ coeff_get (state, samples + 1280, &state->lfe_expbap, &quantizer,
+ 0, 0, 7);
+ }
}
i = 0;
- if(nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)
- for(i = 1; i < nfchans; i++)
- if(blksw[i] != blksw[0])
- break;
-
- if(i < nfchans)
- {
- if(state->downmixed)
- {
- state->downmixed = 0;
- a52_upmix(samples + 1536, state->acmod, state->output);
- }
-
- for(i = 0; i < nfchans; i++)
- {
- sample_t bias;
-
- bias = 0;
- if(!(chanbias & (1 << i)))
- bias = state->bias;
-
- if(coeff[i])
- {
- if(blksw[i])
- a52_imdct_256(samples + 256 * i, samples + 1536 + 256 * i,
- bias);
- else
- a52_imdct_512(samples + 256 * i, samples + 1536 + 256 * i,
- bias);
- }
- else
- {
- int j;
-
- for(j = 0; j < 256; j++)
- (samples + 256 * i)[j] = bias;
- }
- }
-
- a52_downmix(samples, state->acmod, state->output, state->bias,
- state->clev, state->slev);
- }
- else
- {
- nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];
-
- a52_downmix(samples, state->acmod, state->output, 0,
- state->clev, state->slev);
-
- if(!state->downmixed)
- {
- state->downmixed = 1;
- a52_downmix(samples + 1536, state->acmod, state->output, 0,
- state->clev, state->slev);
- }
-
- if(blksw[0])
- for(i = 0; i < nfchans; i++)
- a52_imdct_256(samples + 256 * i, samples + 1536 + 256 * i,
- state->bias);
- else
- for(i = 0; i < nfchans; i++)
- a52_imdct_512(samples + 256 * i, samples + 1536 + 256 * i,
- state->bias);
+ if (nfchans_tbl[state->output & A52_CHANNEL_MASK] < nfchans)
+ for (i = 1; i < nfchans; i++)
+ if (blksw[i] != blksw[0])
+ break;
+
+ if (i < nfchans) {
+ if (state->downmixed) {
+ state->downmixed = 0;
+ a52_upmix (samples + 1536, state->acmod, state->output);
+ }
+
+ for (i = 0; i < nfchans; i++) {
+ sample_t bias;
+
+ bias = 0;
+ if (!(chanbias & (1 << i)))
+ bias = state->bias;
+
+ if (coeff[i]) {
+ if (blksw[i])
+ a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
+ bias);
+ else
+ a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
+ bias);
+ } else {
+ int j;
+
+ for (j = 0; j < 256; j++)
+ (samples + 256 * i)[j] = bias;
+ }
+ }
+
+ a52_downmix (samples, state->acmod, state->output, state->bias,
+ state->clev, state->slev);
+ } else {
+ nfchans = nfchans_tbl[state->output & A52_CHANNEL_MASK];
+
+ a52_downmix (samples, state->acmod, state->output, 0,
+ state->clev, state->slev);
+
+ if (!state->downmixed) {
+ state->downmixed = 1;
+ a52_downmix (samples + 1536, state->acmod, state->output, 0,
+ state->clev, state->slev);
+ }
+
+ if (blksw[0])
+ for (i = 0; i < nfchans; i++)
+ a52_imdct_256 (samples + 256 * i, samples + 1536 + 256 * i,
+ state->bias);
+ else
+ for (i = 0; i < nfchans; i++)
+ a52_imdct_512 (samples + 256 * i, samples + 1536 + 256 * i,
+ state->bias);
}
return 0;
}
-void a52_free(a52_state_t * state)
+void a52_free (a52_state_t * state)
{
- free(state->samples);
- free(state);
+ free (state->samples);
+ free (state);
}
diff --git a/src/filters/transform/MpaDecFilter/a52dec/liba52/tables.h b/src/filters/transform/MpaDecFilter/a52dec/liba52/tables.h index 904cccb62..8011715b1 100644 --- a/src/filters/transform/MpaDecFilter/a52dec/liba52/tables.h +++ b/src/filters/transform/MpaDecFilter/a52dec/liba52/tables.h @@ -21,60 +21,54 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-static const int8_t exp_1[128] =
-{
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 25, 25, 25
+static const int8_t exp_1[128] = {
+ -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
+ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 25,25,25
};
-static const int8_t exp_2[128] =
-{
- -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- -2, -2, -2, -2, -2, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
- 25, 25, 25
+static const int8_t exp_2[128] = {
+ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ 25,25,25
};
-static const int8_t exp_3[128] =
-{
- -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2,
- -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2,
- -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2,
- -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2,
- -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2, -2, -1, 0, 1, 2,
- 25, 25, 25
+static const int8_t exp_3[128] = {
+ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
+ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
+ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
+ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
+ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
+ 25,25,25
};
#define Q0 ((-2 << 15) / 3.0)
#define Q1 (0)
#define Q2 ((2 << 15) / 3.0)
-static const sample_t q_1_0[32] =
-{
- Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
- Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
- Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
- 0, 0, 0, 0, 0
+static const sample_t q_1_0[32] = {
+ Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
+ Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
+ Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
+ 0,0,0,0,0
};
-static const sample_t q_1_1[32] =
-{
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
- 0, 0, 0, 0, 0
+static const sample_t q_1_1[32] = {
+ Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2,
+ Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2,
+ Q0,Q0,Q0,Q1,Q1,Q1,Q2,Q2,Q2,
+ 0,0,0,0,0
};
-static const sample_t q_1_2[32] =
-{
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
- 0, 0, 0, 0, 0
+static const sample_t q_1_2[32] = {
+ Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2,
+ Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2,
+ Q0,Q1,Q2,Q0,Q1,Q2,Q0,Q1,Q2,
+ 0,0,0,0,0
};
#undef Q0
@@ -87,34 +81,31 @@ static const sample_t q_1_2[32] = #define Q3 ((2 << 15) / 5.0)
#define Q4 ((4 << 15) / 5.0)
-static const sample_t q_2_0[128] =
-{
- Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
- Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
- Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
- Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
- Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
- 0, 0, 0
+static const sample_t q_2_0[128] = {
+ Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
+ Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
+ Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
+ Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,
+ Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,
+ 0,0,0
};
-static const sample_t q_2_1[128] =
-{
- Q0, Q0, Q0, Q0, Q0, Q1, Q1, Q1, Q1, Q1, Q2, Q2, Q2, Q2, Q2, Q3, Q3, Q3, Q3, Q3, Q4, Q4, Q4, Q4, Q4,
- Q0, Q0, Q0, Q0, Q0, Q1, Q1, Q1, Q1, Q1, Q2, Q2, Q2, Q2, Q2, Q3, Q3, Q3, Q3, Q3, Q4, Q4, Q4, Q4, Q4,
- Q0, Q0, Q0, Q0, Q0, Q1, Q1, Q1, Q1, Q1, Q2, Q2, Q2, Q2, Q2, Q3, Q3, Q3, Q3, Q3, Q4, Q4, Q4, Q4, Q4,
- Q0, Q0, Q0, Q0, Q0, Q1, Q1, Q1, Q1, Q1, Q2, Q2, Q2, Q2, Q2, Q3, Q3, Q3, Q3, Q3, Q4, Q4, Q4, Q4, Q4,
- Q0, Q0, Q0, Q0, Q0, Q1, Q1, Q1, Q1, Q1, Q2, Q2, Q2, Q2, Q2, Q3, Q3, Q3, Q3, Q3, Q4, Q4, Q4, Q4, Q4,
- 0, 0, 0
+static const sample_t q_2_1[128] = {
+ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
+ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
+ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
+ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
+ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
+ 0,0,0
};
-static const sample_t q_2_2[128] =
-{
- Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4,
- Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4,
- Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4,
- Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4,
- Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4, Q0, Q1, Q2, Q3, Q4,
- 0, 0, 0
+static const sample_t q_2_2[128] = {
+ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
+ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
+ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
+ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
+ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
+ 0,0,0
};
#undef Q0
@@ -123,10 +114,9 @@ static const sample_t q_2_2[128] = #undef Q3
#undef Q4
-static const sample_t q_3[8] =
-{
- (-6 << 15) / 7.0, (-4 << 15) / 7.0, (-2 << 15) / 7.0, 0,
- (2 << 15) / 7.0, (4 << 15) / 7.0, (6 << 15) / 7.0, 0
+static const sample_t q_3[8] = {
+ (-6 << 15)/7.0, (-4 << 15)/7.0, (-2 << 15)/7.0, 0,
+ ( 2 << 15)/7.0, ( 4 << 15)/7.0, ( 6 << 15)/7.0, 0
};
#define Q0 ((-10 << 15) / 11.0)
@@ -141,8 +131,7 @@ static const sample_t q_3[8] = #define Q9 ((8 << 15) / 11.0)
#define QA ((10 << 15) / 11.0)
-static const sample_t q_4_0[128] =
-{
+static const sample_t q_4_0[128] = {
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
@@ -157,8 +146,7 @@ static const sample_t q_4_0[128] = 0, 0, 0, 0, 0, 0, 0
};
-static const sample_t q_4_1[128] =
-{
+static const sample_t q_4_1[128] = {
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
@@ -185,18 +173,16 @@ static const sample_t q_4_1[128] = #undef Q9
#undef QA
-static const sample_t q_5[16] =
-{
- (-14 << 15) / 15.0, (-12 << 15) / 15.0, (-10 << 15) / 15.0,
- (-8 << 15) / 15.0, (-6 << 15) / 15.0, (-4 << 15) / 15.0,
- (-2 << 15) / 15.0, 0 , (2 << 15) / 15.0,
- (4 << 15) / 15.0, (6 << 15) / 15.0, (8 << 15) / 15.0,
- (10 << 15) / 15.0, (12 << 15) / 15.0, (14 << 15) / 15.0,
+static const sample_t q_5[16] = {
+ (-14 << 15)/15.0,(-12 << 15)/15.0,(-10 << 15)/15.0,
+ ( -8 << 15)/15.0,( -6 << 15)/15.0,( -4 << 15)/15.0,
+ ( -2 << 15)/15.0, 0 ,( 2 << 15)/15.0,
+ ( 4 << 15)/15.0,( 6 << 15)/15.0,( 8 << 15)/15.0,
+ ( 10 << 15)/15.0,( 12 << 15)/15.0,( 14 << 15)/15.0,
0
};
-static const sample_t scale_factor[25] =
-{
+static const sample_t scale_factor[25] = {
0.000030517578125,
0.0000152587890625,
0.00000762939453125,
@@ -224,8 +210,7 @@ static const sample_t scale_factor[25] = 0.000000000001818989403545856475830078125
};
-static const uint16_t dither_lut[256] =
-{
+static const uint16_t dither_lut[256] = {
0x0000, 0xa011, 0xe033, 0x4022, 0x6077, 0xc066, 0x8044, 0x2055,
0xc0ee, 0x60ff, 0x20dd, 0x80cc, 0xa099, 0x0088, 0x40aa, 0xe0bb,
0x21cd, 0x81dc, 0xc1fe, 0x61ef, 0x41ba, 0xe1ab, 0xa189, 0x0198,
|