[xiph-commits] r9597 - trunk/vorbis-tools/oggdec

msmith at svn.xiph.org msmith at svn.xiph.org
Thu Jul 21 06:40:01 PDT 2005


Author: msmith
Date: 2005-07-21 06:39:59 -0700 (Thu, 21 Jul 2005)
New Revision: 9597

Modified:
   trunk/vorbis-tools/oggdec/oggdec.c
Log:
Limited support for chained oggs in oggdec.


Modified: trunk/vorbis-tools/oggdec/oggdec.c
===================================================================
--- trunk/vorbis-tools/oggdec/oggdec.c	2005-07-21 13:14:20 UTC (rev 9596)
+++ trunk/vorbis-tools/oggdec/oggdec.c	2005-07-21 13:39:59 UTC (rev 9597)
@@ -229,6 +229,8 @@
     int size;
     int seekable = 0;
     int percent = 0;
+    int channels;
+    int samplerate;
 
     if(ov_open(in, &vf, NULL, 0) < 0) {
         fprintf(stderr, "ERROR: Failed to open input as vorbis\n");
@@ -236,10 +238,26 @@
         return 1;
     }
 
+    channels = ov_info(&vf,0)->channels;
+    samplerate = ov_info(&vf,0)->rate;
+
     if(ov_seekable(&vf)) {
+        int link;
+        int chainsallowed;
+        for(link = 0; link < ov_streams(&vf); link++) {
+            if(ov_info(&vf, link)->channels = channels && 
+                    ov_info(&vf, link)->rate == samplerate)
+            {
+                chainsallowed = 1;
+            }
+        }
+
         seekable = 1;
-        length = ov_pcm_total(&vf, 0);
-        size = bits/8 * ov_info(&vf, 0)->channels;
+        if(chainsallowed)
+            length = ov_pcm_total(&vf, -1);
+        else
+            length = ov_pcm_total(&vf, 0);
+        size = bits/8 * channels;
         if(!quiet)
             fprintf(stderr, "Decoding \"%s\" to \"%s\"\n", 
                     infile?infile:"standard input", 
@@ -255,8 +273,11 @@
 
     while((ret = ov_read(&vf, buf, buflen, endian, bits/8, sign, &bs)) != 0) {
         if(bs != 0) {
-            fprintf(stderr, "Only one logical bitstream currently supported\n");
-            break;
+            vorbis_info *vi = ov_info(&vf, -1);
+            if(channels != vi->channels || samplerate != vi->rate) {
+                fprintf(stderr, "Logical bitstreams with changing parameters are not supported\n");
+                break;
+            }
         }
 
         if(ret < 0 ) {



More information about the commits mailing list