[xiph-commits] r17996 - in trunk/ffmpeg2theora: . patches

j at svn.xiph.org j at svn.xiph.org
Sun May 22 04:21:35 PDT 2011


Author: j
Date: 2011-05-22 04:21:35 -0700 (Sun, 22 May 2011)
New Revision: 17996

Modified:
   trunk/ffmpeg2theora/get_ffmpeg.sh
   trunk/ffmpeg2theora/patches/6to2channel-resample.patch
Log:
update 6to2 patch

Modified: trunk/ffmpeg2theora/get_ffmpeg.sh
===================================================================
--- trunk/ffmpeg2theora/get_ffmpeg.sh	2011-05-20 22:08:35 UTC (rev 17995)
+++ trunk/ffmpeg2theora/get_ffmpeg.sh	2011-05-22 11:21:35 UTC (rev 17996)
@@ -4,13 +4,13 @@
 common="$common --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-doc"
 
 #optional, if you have those libs installed:
-#extra="--enable-libopencore-amrnb --enable-libopencore-amrwb"
+#extra="$extra --enable-libopencore-amrnb --enable-libopencore-amrwb"
 
 #apt-get install liba52-dev libgsm1-dev
 #extra="$extra  --enable-libgsm"
 
 #optional, if you have libvpx installed:
-#extra="--enable-libvpx"
+#extra="$extra --enable-libvpx"
 
 #linux
 options="$common --enable-pthreads $extra"

Modified: trunk/ffmpeg2theora/patches/6to2channel-resample.patch
===================================================================
--- trunk/ffmpeg2theora/patches/6to2channel-resample.patch	2011-05-20 22:08:35 UTC (rev 17995)
+++ trunk/ffmpeg2theora/patches/6to2channel-resample.patch	2011-05-22 11:21:35 UTC (rev 17996)
@@ -1,92 +1,65 @@
-Index: libavcodec/resample.c
-===================================================================
---- libavcodec/resample.c	(revision 22168)
-+++ libavcodec/resample.c	(working copy)
-@@ -52,6 +52,17 @@
-     unsigned buffer_size[2];         ///< sizes of allocated buffers
- };
+diff --git a/libavcodec/resample.c b/libavcodec/resample.c
+index 9e6defe..8c4eebe 100644
+--- a/libavcodec/resample.c
++++ b/libavcodec/resample.c
+@@ -108,6 +108,39 @@ static void mono_to_stereo(short *output, short *input, int n1)
+     }
+ }
  
 +/*
++5.1 to stereo input: [fl, fr, c, lfe, rl, rr]
++- Left = front_left + rear_gain * rear_left + center_gain * center
++- Right = front_right + rear_gain * rear_right + center_gain * center
++Where rear_gain is usually around 0.5-1.0 and
++      center_gain is almost always 0.7 (-3 dB)
 +*/
-+static short clip_short(int v) {
-+    if (v < -32768)
-+        v = -32768;
-+    else if (v > 32767)
-+        v = 32767;
-+    return (short) v;
-+}
++static void surround_to_stereo(short **output, short *input, int channels, int samples)
++{
++    int i;
++    short l, r;
 +
++    for (i = 0; i < samples; i++) {
++        int fl,fr,c,rl,rr,lfe;
++        fl = input[0];
++        fr = input[1];
++        c = input[2];
++        lfe = input[3];
++        rl = input[4];
++        rr = input[5];
 +
- /* n1: number of samples */
- static void stereo_to_mono(short *output, short *input, int n1)
- {
-@@ -103,14 +114,43 @@
-     }
- }
- 
--/* XXX: should use more abstract 'N' channels system */
--static void stereo_split(short *output1, short *output2, short *input, int n)
--{
-+/* XXX: make this better.  channels will always be >= 2.
-+ - Left = front_left + rear_gain * rear_left + center_gain * center
-+ - Right = front_right + rear_gain * rear_right + center_gain * center
-+ where rear_gain is usually around 0.5-1.0 and center_gain is almost always 0.7 (-3 dB) if I recall correctly.  */
-+static void multi_to_stereo_split(short *output1, short *output2, short *input, int n, int channels) {
-     int i;
-+    short l,r;
- 
-     for(i=0;i<n;i++) {
--        *output1++ = *input++;
--        *output2++ = *input++;
-+        if (channels == 2) {
-+            /* simple stereo to stereo. Input is: l, r */
-+            l = input[0];
-+            r = input[1];
-+        } else if (channels == 6) {
-+            /* 5.1 to stereo input: [fl, fr, c, lfe, rl, rr] */
-+            int fl,fr,c,rl,rr,lfe;
-+            fl = input[0];
-+            fr = input[1];
-+            c = input[2];
-+            lfe = input[3];
-+            rl = input[4];
-+            rr = input[5];
++        l = av_clip_int16(fl + (0.5 * rl) + (0.7 * c));
++        r = av_clip_int16(fr + (0.5 * rr) + (0.7 * c));
 +
-+            l = clip_short(fl + (0.5 * rl) + (0.7 * c));
-+            r = clip_short(fr + (0.5 * rr) + (0.7 * c));
-+        } else {
-+            /* channels must be 3-5, or >= 7. l, c, r, ? */
-+            l = input[0];
-+            r = input[2];
-+        }
-+
 +        /* output l & r. */
-+        *output1++ = l;
-+        *output2++ = r;
++        *output[0]++ = l;
++        *output[1]++ = r;
 +
 +        /* increment input. */
 +        input += channels;
-     }
- }
- 
-@@ -150,9 +190,9 @@
++    }
++}
++
+ static void deinterleave(short **output, short *input, int channels, int samples)
  {
-     ReSampleContext *s;
- 
--    if ( input_channels > 2)
-+	 if ((input_channels > 2) && (input_channels != 6))
-       {
--        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n");
-+		av_log(NULL, AV_LOG_ERROR, "Resampling with input channels other than 1,2, or 6 is unsupported.\n");
-         return NULL;
-       }
- 
-@@ -312,7 +352,7 @@
-     } else if (s->output_channels >= 2) {
+     int i, j;
+@@ -301,6 +334,10 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
+     } else if (s->output_channels >= 2 && s->input_channels == 1) {
          buftmp3[0] = bufout[0];
-         buftmp3[1] = bufout[1];
--        stereo_split(buftmp2[0], buftmp2[1], input, nb_samples);
-+        multi_to_stereo_split(buftmp2[0], buftmp2[1], input, nb_samples, s->input_channels);
-     } else {
-         buftmp3[0] = output;
-         memcpy(buftmp2[0], input, nb_samples*sizeof(short));
+         memcpy(buftmp2[0], input, nb_samples * sizeof(short));
++    } else if (s->input_channels == 6 && s->output_channels ==2) {
++        buftmp3[0] = bufout[0];
++        buftmp3[1] = bufout[1];
++        surround_to_stereo(buftmp2, input, s->input_channels, nb_samples);
+     } else if (s->output_channels >= s->input_channels && s->input_channels >= 2) {
+         for (i = 0; i < s->input_channels; i++) {
+             buftmp3[i] = bufout[i];
+@@ -330,7 +367,8 @@ int audio_resample(ReSampleContext *s, short *output, short *input, int nb_sampl
+         mono_to_stereo(output, buftmp3[0], nb_samples1);
+     } else if (s->output_channels == 6 && s->input_channels == 2) {
+         ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
+-    } else if (s->output_channels == s->input_channels && s->input_channels >= 2) {
++    } else if ((s->output_channels == s->input_channels && s->input_channels >= 2) ||
++               (s->output_channels == 2 && s->input_channels == 6)) {
+         interleave(output, buftmp3, s->output_channels, nb_samples1);
+     }
+ 



More information about the commits mailing list