[xiph-cvs] cvs commit: vorbis/vorbis-tools vorbiscomment.c

Michael Smith msmith at xiph.org
Wed Sep 6 06:21:36 PDT 2000



msmith      00/09/06 06:21:36

  Modified:    vorbis-tools Tag: branch_postbeta2 vorbiscomment.c
  Log:
  Fix a potentially nasty bug which might cause bitstreams to be decoded
  slightly differently after use of vorbiscomment under some circumstances.
  Didn't confirm this, but it's better this way anyway.
  
  Updated vorbiscomment to flush header pages after the header packets, to
  enable easier streaming. Note: this means that vorbiscomment could be used
  to convert an older file so that it can be streamed correctly, with a simple
  wrapper.

Revision  Changes    Path
No                   revision

No                   revision

1.1.4.1   +29 -6     vorbis/vorbis-tools/vorbiscomment.c

Index: vorbiscomment.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/vorbis-tools/vorbiscomment.c,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- vorbiscomment.c	2000/08/05 00:27:52	1.1
+++ vorbiscomment.c	2000/09/06 13:21:35	1.1.4.1
@@ -1,3 +1,17 @@
+/* This program is provided under the GNU General Public License, version 2, 
+ * which is included with this program.
+ *
+ * (c) 2000 Michael Smith <msmith at labyrinth.net.au>
+ * Portions (c) 2000 Kenneth C. Arnold <kcarnold at yahoo.com>
+ * 
+ * *********************************************************************
+ * Vorbis comment field editor - designed to be wrapped by scripts, etc.
+ * and as a proof of concept/example code/
+ * 
+ * last mod: $Id: vorbiscomment.c,v 1.1.4.1 2000/09/06 13:21:35 msmith Exp $
+ */
+
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -11,10 +25,11 @@
 int main(int argc, char **argv)
 {
 
-	unsigned char *buffer;
+	char *buffer;
         int bytes;
         int i;
         int serial;
+	int result;
         int eosin=0,eosout=0;
         FILE *input, *output;
 
@@ -32,8 +47,10 @@
 
         ogg_packet	 	*header;
         ogg_packet header_main;
+	ogg_packet header_main_original;
         ogg_packet header_comments;
         ogg_packet header_codebooks;
+	ogg_packet header_codebooks_original;
 
         if(argc == 3)
         {
@@ -109,13 +126,13 @@
             exit(1);
           }
         
-	if(ogg_stream_packetout(&os,&header_main)!=1)
+	if(ogg_stream_packetout(&os,&header_main_original)!=1)
           {
             fprintf(stderr, "First header broken\n");
             exit(1);
           }
         
-	if(vorbis_synthesis_headerin(&vi,&vc,&header_main)<0)
+	if(vorbis_synthesis_headerin(&vi,&vc,&header_main_original)<0)
           {
             fprintf(stderr, "ogg, but not vorbis\n");
             exit(1);
@@ -141,7 +158,7 @@
                     }
                   vorbis_synthesis_headerin(&vi,&vc,header);
                   i++;
-		  header = &header_codebooks;
+		  header = &header_codebooks_original;
                 }
               }
           }
@@ -201,13 +218,20 @@
             ogg_stream_packetin(&out,&header_main);
             ogg_stream_packetin(&out,&header_comments);
             ogg_stream_packetin(&out,&header_codebooks);
+
+	    while((result = ogg_stream_flush(&os, &og)))
+	    {
+		if(!result) break;
+		fwrite(og.header,1, og.header_len, output);
+		fwrite(og.body,1,og.body_len, output);
+	    }
             
             /* Hard bit - stream ogg packets out, ogg packets in */
             
             while(!(eosin && eosout)){
               while(!(eosin && !eosout)){
 
-		int result=ogg_sync_pageout(&oy,&og);
+		result=ogg_sync_pageout(&oy,&og);
                 if(result==0)break;
                 else if(result==-1)fprintf(stderr, "Error in bitstream, continuing\n");
                 else
@@ -260,7 +284,6 @@
 int edit_comments(vorbis_comment *in, vorbis_comment *out)
 {
   char comment[1024];
-  int pos = 0, ret = 0;
   vorbis_comment_init(out);
   
   while (1)

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list