summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-08-02 21:43:22 +0000
committerRodeo <[email protected]>2012-08-02 21:43:22 +0000
commitb3717d369763d620d548f224daeba5a7503fa972 (patch)
tree4742e9b49e03db2b1c558e10f40c2c821528e8f5 /contrib
parentad257c9dac38fe3f7502b1058247b4458465c0a8 (diff)
Use hb_audio_resample for downmixing AC3 sources. DRC is still applied by liba52.
Add support for center & surround mix levels to hb_audio_resample. This allows us to support upmixing all audio sources. For sources that have at least 2 front and one back or side channel(s), allow upmixing to 5.1: 3.0/3.1 (2 front and 1 back channels) 4.0/4.1 (3 front and 1 back channels) 4.0/4.1 (2 front and 2 side channels) 5.0 (3 front and 2 side channels) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4885 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'contrib')
-rw-r--r--contrib/a52dec/A00-a52-state-t-public.patch152
-rw-r--r--contrib/a52dec/A00-dpl2.patch114
-rw-r--r--contrib/a52dec/A01-thread-safe.patch41
-rw-r--r--contrib/a52dec/A02-imdct-shutup.patch4
4 files changed, 176 insertions, 135 deletions
diff --git a/contrib/a52dec/A00-a52-state-t-public.patch b/contrib/a52dec/A00-a52-state-t-public.patch
new file mode 100644
index 000000000..5e0af3577
--- /dev/null
+++ b/contrib/a52dec/A00-a52-state-t-public.patch
@@ -0,0 +1,152 @@
+diff -Naur a52dec.old/include/a52.h a52dec.new/include/a52.h
+--- a52dec.old/include/a52.h 2002-01-28 06:37:54.000000000 +0100
++++ a52dec.new/include/a52.h 2012-07-16 14:13:35.000000000 +0200
+@@ -30,7 +30,71 @@
+ typedef double sample_t;
+ #endif
+
+-typedef struct a52_state_s a52_state_t;
++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 {
++ uint8_t exp[256]; /* decoded channel exponents */
++ int8_t bap[256]; /* derived channel bit allocation */
++} expbap_t;
++
++typedef struct {
++ uint8_t fscod; /* sample rate */
++ uint8_t halfrate; /* halfrate factor */
++ uint8_t acmod; /* coded channels */
++ uint8_t lfeon; /* coded lfe channel */
++ sample_t clev; /* centre channel mix level */
++ sample_t slev; /* surround channels mix level */
++
++ int output; /* type of output */
++ sample_t level; /* output level */
++ sample_t bias; /* output bias */
++
++ 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);
++
++ uint8_t chincpl; /* channel coupled */
++ uint8_t phsflginu; /* phase flags in use (stereo only) */
++ uint8_t cplstrtmant; /* coupling channel start mantissa */
++ uint8_t cplendmant; /* coupling channel end mantissa */
++ uint32_t cplbndstrc; /* coupling band structure */
++ sample_t cplco[5][18]; /* coupling coordinates */
++
++ /* derived information */
++ uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
++ uint8_t ncplbnd; /* number of coupling bands */
++
++ uint8_t rematflg; /* stereo rematrixing */
++
++ uint8_t endmant[5]; /* channel end mantissa */
++
++ uint16_t bai; /* bit allocation information */
++
++ uint32_t * buffer_start;
++ uint16_t lfsr_state; /* dither state */
++ uint32_t bits_left;
++ uint32_t current_word;
++
++ uint8_t csnroffst; /* coarse SNR offset */
++ ba_t cplba; /* coupling bit allocation parameters */
++ ba_t ba[5]; /* channel bit allocation parameters */
++ ba_t lfeba; /* lfe bit allocation parameters */
++
++ uint8_t cplfleak; /* coupling fast leak init */
++ uint8_t cplsleak; /* coupling slow leak init */
++
++ expbap_t cpl_expbap;
++ expbap_t fbw_expbap[5];
++ expbap_t lfe_expbap;
++
++ sample_t * samples;
++ int downmixed;
++} a52_state_t;
+
+ #define A52_CHANNEL 0
+ #define A52_MONO 1
+diff -Naur a52dec.old/liba52/a52_internal.h a52dec.new/liba52/a52_internal.h
+--- a52dec.old/liba52/a52_internal.h 2002-07-28 03:52:06.000000000 +0200
++++ a52dec.new/liba52/a52_internal.h 2012-07-16 14:11:47.000000000 +0200
+@@ -21,72 +21,6 @@
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+-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 {
+- uint8_t exp[256]; /* decoded channel exponents */
+- int8_t bap[256]; /* derived channel bit allocation */
+-} expbap_t;
+-
+-struct a52_state_s {
+- uint8_t fscod; /* sample rate */
+- uint8_t halfrate; /* halfrate factor */
+- uint8_t acmod; /* coded channels */
+- uint8_t lfeon; /* coded lfe channel */
+- sample_t clev; /* centre channel mix level */
+- sample_t slev; /* surround channels mix level */
+-
+- int output; /* type of output */
+- sample_t level; /* output level */
+- sample_t bias; /* output bias */
+-
+- 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);
+-
+- uint8_t chincpl; /* channel coupled */
+- uint8_t phsflginu; /* phase flags in use (stereo only) */
+- uint8_t cplstrtmant; /* coupling channel start mantissa */
+- uint8_t cplendmant; /* coupling channel end mantissa */
+- uint32_t cplbndstrc; /* coupling band structure */
+- sample_t cplco[5][18]; /* coupling coordinates */
+-
+- /* derived information */
+- uint8_t cplstrtbnd; /* coupling start band (for bit allocation) */
+- uint8_t ncplbnd; /* number of coupling bands */
+-
+- uint8_t rematflg; /* stereo rematrixing */
+-
+- uint8_t endmant[5]; /* channel end mantissa */
+-
+- uint16_t bai; /* bit allocation information */
+-
+- uint32_t * buffer_start;
+- uint16_t lfsr_state; /* dither state */
+- uint32_t bits_left;
+- uint32_t current_word;
+-
+- uint8_t csnroffst; /* coarse SNR offset */
+- ba_t cplba; /* coupling bit allocation parameters */
+- ba_t ba[5]; /* channel bit allocation parameters */
+- ba_t lfeba; /* lfe bit allocation parameters */
+-
+- uint8_t cplfleak; /* coupling fast leak init */
+- uint8_t cplsleak; /* coupling slow leak init */
+-
+- expbap_t cpl_expbap;
+- expbap_t fbw_expbap[5];
+- expbap_t lfe_expbap;
+-
+- sample_t * samples;
+- int downmixed;
+-};
+-
+ #define LEVEL_PLUS6DB 2.0
+ #define LEVEL_PLUS3DB 1.4142135623730951
+ #define LEVEL_3DB 0.7071067811865476
diff --git a/contrib/a52dec/A00-dpl2.patch b/contrib/a52dec/A00-dpl2.patch
deleted file mode 100644
index cf1c8a64a..000000000
--- a/contrib/a52dec/A00-dpl2.patch
+++ /dev/null
@@ -1,114 +0,0 @@
-diff -Naur a52dec_original/include/a52.h a52dec_patched/include/a52.h
---- a52dec_original/include/a52.h 2002-01-28 05:37:54.000000000 +0000
-+++ a52dec_patched/include/a52.h 2007-04-04 19:12:57.000000000 +0100
-@@ -48,6 +48,10 @@
- #define A52_LFE 16
- #define A52_ADJUST_LEVEL 32
-
-+// this next constant can be ORed with A52_DOLBY to tell liba52 to use 5.0 DPLII matrix encoding,
-+// rather than just 4.0 Dolby Surround matrix encoding
-+#define A52_USE_DPLII 64
-+
- 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,
-diff -Naur a52dec_original/liba52/a52_internal.h a52dec_patched/liba52/a52_internal.h
---- a52dec_original/liba52/a52_internal.h 2002-07-28 02:52:06.000000000 +0100
-+++ a52dec_patched/liba52/a52_internal.h 2007-04-04 19:11:43.000000000 +0100
-@@ -93,6 +93,10 @@
- #define LEVEL_45DB 0.5946035575013605
- #define LEVEL_6DB 0.5
-
-+// these next two constants are used for DPL matrix encoding in downmix.c
-+#define LEVEL_SQRT_1_2 0.5
-+#define LEVEL_SQRT_3_4 0.8660254037844386
-+
- #define EXP_REUSE (0)
- #define EXP_D15 (1)
- #define EXP_D25 (2)
-diff -Naur a52dec_original/liba52/downmix.c a52dec_patched/liba52/downmix.c
---- a52dec_original/liba52/downmix.c 2002-01-28 05:37:54.000000000 +0000
-+++ a52dec_patched/liba52/downmix.c 2007-04-06 13:47:49.000000000 +0100
-@@ -34,6 +34,7 @@
- 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},
-@@ -148,6 +149,9 @@
- break;
- }
-
-+ // add the DPLII flag back into the output if it was passed in
-+ output = output | (flags & A52_USE_DPLII);
-+
- return output;
- }
-
-@@ -418,17 +422,46 @@
- }
- }
-
--static void mix32toS (sample_t * samples, sample_t bias)
-+static void mix32toS (sample_t * samples, sample_t bias, int use_dpl2)
- {
-- 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;
-- }
-+ if (use_dpl2 == 1) {
-+
-+ int i;
-+ sample_t cc, Lt, Rt, Ls, Rs, Lss, Rss;
-+
-+ for (i = 0; i < 256; i++) {
-+
-+ cc = samples[i + 256] * LEVEL_3DB;
-+
-+ Lt = samples[i] + cc;
-+ Rt = samples[i + 512] + cc;
-+
-+ Ls = samples[i + 768];
-+ Rs = samples[i + 1024];
-+
-+ Lss = (LEVEL_SQRT_3_4 * Ls) - (LEVEL_SQRT_1_2 * Rs);
-+ Rss = -(LEVEL_SQRT_1_2 * Ls) + (LEVEL_SQRT_3_4 * Rs);
-+
-+ samples[i] = bias + Lt + Lss;
-+ samples[i + 256] = bias + Rt + Rss;
-+
-+ }
-+
-+ } else {
-+
-+ 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;
-+ }
-+
-+ }
-+
- }
-
- static void move2to1 (sample_t * src, sample_t * dest, sample_t bias)
-@@ -533,7 +566,7 @@
- break;
-
- case CONVERT (A52_3F2R, A52_DOLBY):
-- mix32toS (samples, bias);
-+ mix32toS (samples, bias, ((output & A52_USE_DPLII) == A52_USE_DPLII));
- break;
-
- case CONVERT (A52_3F1R, A52_3F):
diff --git a/contrib/a52dec/A01-thread-safe.patch b/contrib/a52dec/A01-thread-safe.patch
index 0fa7f0a53..4ca2d1a08 100644
--- a/contrib/a52dec/A01-thread-safe.patch
+++ b/contrib/a52dec/A01-thread-safe.patch
@@ -1,19 +1,19 @@
-diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/a52_internal.h ../a52dec.new/liba52/a52_internal.h
---- a52dec/liba52/a52_internal.h 2011-04-28 07:54:05.499052327 -0700
-+++ ../a52dec.new/liba52/a52_internal.h 2011-04-28 07:50:30.998845068 -0700
-@@ -32,6 +32,11 @@
- int8_t bap[256]; /* derived channel bit allocation */
+diff -Naur a52dec.old/include/a52.h a52dec.new/include/a52.h
+--- a52dec.old/include/a52.h 2012-07-16 14:24:14.000000000 +0200
++++ a52dec.new/include/a52.h 2012-07-16 14:31:37.000000000 +0200
+@@ -42,6 +42,11 @@
} expbap_t;
-+typedef struct complex_s {
+ typedef struct {
+ sample_t real;
+ sample_t imag;
+} complex_t;
+
- struct a52_state_s {
- uint8_t fscod; /* sample rate */
- uint8_t halfrate; /* halfrate factor */
-@@ -85,6 +90,20 @@
++typedef struct {
+ uint8_t fscod; /* sample rate */
+ uint8_t halfrate; /* halfrate factor */
+ uint8_t acmod; /* coded channels */
+@@ -94,6 +99,20 @@
sample_t * samples;
int downmixed;
@@ -31,10 +31,13 @@ diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/a52_internal.h ..
+ complex_t * post2; // size 32
+
+ sample_t * a52_imdct_window; // size 256
- };
+ } a52_state_t;
- #define LEVEL_PLUS6DB 2.0
-@@ -119,6 +138,6 @@
+ #define A52_CHANNEL 0
+diff -Naur a52dec.old/liba52/a52_internal.h a52dec.new/liba52/a52_internal.h
+--- a52dec.old/liba52/a52_internal.h 2012-07-16 14:24:14.000000000 +0200
++++ a52dec.new/liba52/a52_internal.h 2012-07-16 14:28:33.000000000 +0200
+@@ -49,6 +49,6 @@
sample_t clev, sample_t slev);
void a52_upmix (sample_t * samples, int acmod, int output);
@@ -44,9 +47,9 @@ diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/a52_internal.h ..
+void a52_imdct_init (a52_state_t * state, uint32_t mm_accel);
+void a52_imdct_256 (a52_state_t * state, sample_t * data, sample_t * delay, sample_t bias);
+void a52_imdct_512 (a52_state_t * state, sample_t * data, sample_t * delay, sample_t bias);
-diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/imdct.c ../a52dec.new/liba52/imdct.c
---- a52dec/liba52/imdct.c 2002-07-27 18:52:07.000000000 -0700
-+++ ../a52dec.new/liba52/imdct.c 2011-04-28 07:51:00.398624376 -0700
+diff -Naur a52dec.old/liba52/imdct.c a52dec.new/liba52/imdct.c
+--- a52dec.old/liba52/imdct.c 2012-07-16 14:24:14.000000000 +0200
++++ a52dec.new/liba52/imdct.c 2012-07-16 14:33:00.000000000 +0200
@@ -40,11 +40,6 @@
#include "a52_internal.h"
#include "mm_accel.h"
@@ -316,9 +319,9 @@ diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/imdct.c ../a52dec
}
#ifdef LIBA52_DJBFFT
-diff -Naur -x '*.o' -x '*.lo' -x '*.a' -x '*.la' a52dec/liba52/parse.c ../a52dec.new/liba52/parse.c
---- a52dec/liba52/parse.c 2002-07-27 18:52:07.000000000 -0700
-+++ ../a52dec.new/liba52/parse.c 2011-04-28 07:40:48.030435061 -0700
+diff -Naur a52dec.old/liba52/parse.c a52dec.new/liba52/parse.c
+--- a52dec.old/liba52/parse.c 2012-07-16 14:24:14.000000000 +0200
++++ a52dec.new/liba52/parse.c 2012-07-16 14:33:00.000000000 +0200
@@ -56,16 +56,53 @@
a52_state_t * state;
int i;
diff --git a/contrib/a52dec/A02-imdct-shutup.patch b/contrib/a52dec/A02-imdct-shutup.patch
index 8d57ab7a3..a22e5979e 100644
--- a/contrib/a52dec/A02-imdct-shutup.patch
+++ b/contrib/a52dec/A02-imdct-shutup.patch
@@ -1,6 +1,6 @@
diff -Naur a52dec_original/liba52/imdct.c a52dec_patched/liba52/imdct.c
---- a52dec_original/liba52/imdct.c 2002-07-28 03:52:07.000000000 +0200
-+++ a52dec_patched/liba52/imdct.c 2011-07-15 20:29:09.000000000 +0200
+--- a52dec.old/liba52/imdct.c 2002-07-28 03:52:07.000000000 +0200
++++ a52dec.new/liba52/imdct.c 2011-07-15 20:29:09.000000000 +0200
@@ -425,7 +425,6 @@
} else
#endif