summaryrefslogtreecommitdiffstats
path: root/contrib/patch-a52dec.patch
diff options
context:
space:
mode:
authormaurj <[email protected]>2007-04-06 12:55:22 +0000
committermaurj <[email protected]>2007-04-06 12:55:22 +0000
commit8f2b527621659ddb8a6666e7226ca3bb14fb6025 (patch)
tree46fd8013d0cfcc5437588e002c258e39e938d5df /contrib/patch-a52dec.patch
parentbda1114e6103c8eade3e4bb45f2f736325bffb2c (diff)
Added a new patch file, to patch liba52 to support a Dolby Pro Logic II matrix encoding. Note: this patch file isn't yet integrated into the Jam process, and the DPLII support in Handbrake isn't yet committed. I've really only committed the patch so that someone kind (Prigaux?) can add it to the Jam process, and therefore patch the precompiled contrib library download.
The changes in this patch are backwards-compatible, i.e. the contrib library download can be updated and used without breaking the current projects. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@483 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'contrib/patch-a52dec.patch')
-rw-r--r--contrib/patch-a52dec.patch114
1 files changed, 114 insertions, 0 deletions
diff --git a/contrib/patch-a52dec.patch b/contrib/patch-a52dec.patch
new file mode 100644
index 000000000..9eaf34ffd
--- /dev/null
+++ b/contrib/patch-a52dec.patch
@@ -0,0 +1,114 @@
+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] = Lt + Lss;
++ samples[i + 256] = 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):