[xiph-commits] r16957 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Mar 9 09:13:11 PST 2010


Author: xiphmont
Date: 2010-03-09 09:13:11 -0800 (Tue, 09 Mar 2010)
New Revision: 16957

Modified:
   trunk/vorbis/lib/vorbisenc.c
Log:
Extend residue2 setup code to work with non-stereo bundles



Modified: trunk/vorbis/lib/vorbisenc.c
===================================================================
--- trunk/vorbis/lib/vorbisenc.c	2010-03-09 16:05:44 UTC (rev 16956)
+++ trunk/vorbis/lib/vorbisenc.c	2010-03-09 17:13:11 UTC (rev 16957)
@@ -467,7 +467,7 @@
                                         const vorbis_residue_template *res){
 
   codec_setup_info *ci=vi->codec_setup;
-  int i,n;
+  int i;
 
   vorbis_info_residue0 *r=ci->residue_param[number]=
     _ogg_malloc(sizeof(*r));
@@ -566,10 +566,25 @@
        boundaries.  We still lowpass 'wherever', but we have to round up
        here to next boundary, or the vorbis spec will round it *down* to
        previous boundary in encode/decode */
-    if(ci->residue_type[number]==2)
-      r->end=(int)((freq/nyq*blocksize*2)/r->grouping+.9)* /* round up only if we're well past */
+    if(ci->residue_type[number]==2){
+      /* residue 2 bundles together multiple channels; used by stereo
+         and surround.  Count the channels in use */
+      /* Multiple maps/submaps can point to the same residue.  In the case
+         of residue 2, they all better have the same number of
+         channels/samples. */
+      int j,k,ch=0;
+      for(i=0;i<ci->maps&&ch==0;i++){
+        vorbis_info_mapping0 *mi=(vorbis_info_mapping0 *)ci->map_param[i];
+        for(j=0;j<mi->submaps && ch==0;j++)
+          if(mi->residuesubmap[j]==number) /* we found a submap referencing theis residue backend */
+            for(k=0;k<vi->channels;k++)
+              if(mi->chmuxlist[k]==j) /* this channel belongs to the submap */
+                ch++;
+      }
+
+      r->end=(int)((freq/nyq*blocksize*ch)/r->grouping+.9)* /* round up only if we're well past */
         r->grouping;
-    else
+    }else
       r->end=(int)((freq/nyq*blocksize)/r->grouping+.9)* /* round up only if we're well past */
         r->grouping;
     if(r->end==0)r->end=r->grouping; /* LFE channel */



More information about the commits mailing list