[vlc-commits] codec: faad: handle mid/back pair repeats

Francois Cartegnie git at videolan.org
Thu Aug 24 14:49:25 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Aug 24 14:19:56 2017 +0200| [2cdb7a234e23d8c37e2f2ac7a3a10c9afb1cb409] | committer: Francois Cartegnie

codec: faad: handle mid/back pair repeats

Previous faad2 contribs fix was incorrect.
Fix has to be done in decoder module.

This reverts commit 85f0e45b2304afa64ace2e3f0ddc19ad8b5accfb.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2cdb7a234e23d8c37e2f2ac7a3a10c9afb1cb409
---

 contrib/src/faad2/faad2-fix-4channels-groups.patch | 25 -----------------
 contrib/src/faad2/rules.mak                        |  1 -
 modules/codec/faad.c                               | 31 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/contrib/src/faad2/faad2-fix-4channels-groups.patch b/contrib/src/faad2/faad2-fix-4channels-groups.patch
deleted file mode 100644
index 3ac27c71ca..0000000000
--- a/contrib/src/faad2/faad2-fix-4channels-groups.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff -Naur faad2/libfaad/decoder.c faad2_patched/libfaad/decoder.c
---- faad2/libfaad/decoder.c	2017-08-23 12:31:12.495650331 +0200
-+++ faad2_patched/libfaad/decoder.c	2017-08-23 12:30:44.755816954 +0200
-@@ -600,6 +601,21 @@
-         hInfo->num_lfe_channels = hDecoder->pce.num_lfe_channels;
-         total += hInfo->num_lfe_channels;
- 
-+        /* Patch when channels are declared as 1 + 4 */
-+	if(total <= 8)
-+	{
-+		if(hInfo->num_front_channels < 2 && hInfo->num_side_channels > 3)
-+		{
-+			hInfo->num_front_channels += 2;
-+			hInfo->num_side_channels -= 2;
-+		}
-+		if(hInfo->num_side_channels < 2 && hInfo->num_back_channels > 3)
-+		{
-+			hInfo->num_side_channels += 2;
-+			hInfo->num_back_channels -= 2;
-+		}
-+	}
-+
-         chdir = hInfo->num_front_channels;
-         if (chdir & 1)
-         {
diff --git a/contrib/src/faad2/rules.mak b/contrib/src/faad2/rules.mak
index 48bd86d4e6..4a4467b714 100644
--- a/contrib/src/faad2/rules.mak
+++ b/contrib/src/faad2/rules.mak
@@ -24,7 +24,6 @@ endif
 	$(APPLY) $(SRC)/faad2/faad2-fix-71wPCEmapping.patch
 	$(APPLY) $(SRC)/faad2/faad2-fix-cpe-reconstruction.patch
 	$(APPLY) $(SRC)/faad2/faad2-add-define.patch
-	$(APPLY) $(SRC)/faad2/faad2-fix-4channels-groups.patch
 	cd $(UNPACK_DIR) && $(CC) -iquote . -E - </dev/null || sed -i 's/-iquote /-I/' libfaad/Makefile.am
 	$(MOVE)
 
diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 1711ab4596..f134f4e320 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -478,6 +478,37 @@ static int DecodeBlock( decoder_t *p_dec, block_t *p_block )
             }
         }
 #endif
+        /* Handle > 1 local pair 5.1 setups.
+           In case of more than 1 channel pair per area, faad will have repeats
+           in channels sequence. We need to remap to available surround channels.
+           Front > Middle > Rear:
+           In case of 4 middle, it maps to 2F 2M if no previous front.
+           In case of 4 rear, it maps to 2M 2R if no previous rear.
+        */
+        unsigned i_faadused = 0;
+        for( unsigned i=0; i<frame.channels; i++ )
+            if( frame.channel_position[i] > 0 )
+                i_faadused |= 1 << frame.channel_position[i];
+
+        for( size_t i=3; i<frame.channels; i++ )
+        {
+             if( frame.channel_position[i - 3] == frame.channel_position[i - 1] &&
+                 frame.channel_position[i - 2] == frame.channel_position[i] &&
+                 frame.channel_position[i - 1] >= SIDE_CHANNEL_LEFT &&
+                 frame.channel_position[i - 1] <= BACK_CHANNEL_CENTER &&
+                 frame.channel_position[i - 1] >= SIDE_CHANNEL_LEFT &&
+                 frame.channel_position[i - 1] <= BACK_CHANNEL_CENTER )
+             {
+                if( ( (1 << (frame.channel_position[i - 3] - 2)) & i_faadused ) == 0 &&
+                    ( (1 << (frame.channel_position[i - 2] - 2)) & i_faadused ) == 0 )
+                {
+                    frame.channel_position[i - 3] -= 2;
+                    frame.channel_position[i - 2] -= 2;
+                    i_faadused |= 1 << frame.channel_position[i - 3];
+                    i_faadused |= 1 << frame.channel_position[i - 2];
+                }
+             }
+        }
 
         /* Convert frame.channel_position to our own channel values */
         p_dec->fmt_out.audio.i_physical_channels = 0;



More information about the vlc-commits mailing list