[MPlayer-dev-eng] [PATCH] channel reordering for 6ch audio

Giacomo Comes comes at naic.edu
Mon Jul 31 21:48:50 CEST 2006


On Mon, Jul 31, 2006 at 08:26:06PM +0400, Alexander 'Lazy Ranma' Ponyatikh wrote:
> ????????????, Giacomo.
> 
> ?? ?????? 31 ???? 2006 ?., 19:59:50:
> 
> > As you are looking at channel reorder, may I point you to an ac3 bug
> > about mencoder?
> > Please check these two mails:
> 
> > http://lists.mplayerhq.hu/pipermail/mplayer-users/2005-October/056261.html
> > http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/2006-March/041453.html
> 
> > As you can see at the moment there is the need to reorder the channels
> > if you are encoding from ac3 to ac3 using mencoder. Could you also fix this?
> 
> Already did. Apply my patch for ae_lavc.c.
> I'm not going to examine 5 ch ordering, b/c 5ch audio is rare or even
> not used at all.

Thank for your quick reply.

You are right when you say that 5ch is rare, but it is used.
I have seen at least 3 or 4 dvd with 5ch ac3.

Adding support for 5ch is really easy. Your patch needs only a minor change.
Attached is the 5/6 channel version.

Giacomo

P.S. I haven't checked the other patches, but at least ae_lavc.c has an 
incorrect identation. I left yours in the modified patch, but I think it 
should be changed.
-------------- next part --------------
--- libmpcodecs/ae_lavc.c.ori	2006-07-31 15:17:29.000000000 -0400
+++ libmpcodecs/ae_lavc.c	2006-07-31 15:15:44.000000000 -0400
@@ -101,6 +101,17 @@
 static int encode_lavc(audio_encoder_t *encoder, uint8_t *dest, void *src, int size, int max_size)
 {
 	int n;
+    if (encoder->params.channels == 6 || encoder->params.channels == 5) {
+        //Codec wants: L C R  SL SR LFE
+        //We have:     L R SL SR C  LFE
+        int i;
+        uint16_t tmp;
+        for (i = 0; i < size; i += encoder->params.channels*2) {
+            tmp = ((uint16_t*)(src+i))[4];
+            memmove(src+i+4, src+i+2, 3*2);
+            ((uint16_t*)(src+i))[1] = tmp;
+        }
+    }
 	n = avcodec_encode_audio(lavc_actx, dest, size, src);
         compressed_frame_size = n;
 	return n;


More information about the MPlayer-dev-eng mailing list