[xiph-cvs] cvs commit: vorbis-tools/oggenc encode.c encode.h oggenc.c

Jack Moffitt jack at xiph.org
Mon Dec 17 22:29:23 PST 2001



jack        01/12/17 22:29:22

  Modified:    oggenc   encode.c encode.h oggenc.c
  Log:
  Commit changes for RC3 on behalf of Mike, since he is travelling.

Revision  Changes    Path
1.13      +25 -21    vorbis-tools/oggenc/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- encode.c	2001/11/25 02:15:43	1.12
+++ encode.c	2001/12/18 06:29:20	1.13
@@ -154,32 +154,36 @@
                 {
 
                         /* Do the main analysis, creating a packet */
-			vorbis_analysis(&vb, &op);
+			vorbis_analysis(&vb, NULL);
+			vorbis_bitrate_addblock(&vb);
 
-			/* Add packet to bitstream */
-			ogg_stream_packetin(&os,&op);
-			packetsdone++;
-
-			/* If we've gone over a page boundary, we can do actual output,
-			   so do so (for however many pages are available) */
-
-			while(!eos)
+			while(vorbis_bitrate_flushpacket(&vd, &op)) 
                         {
-				int result = ogg_stream_pageout(&os,&og);
-				if(!result) break;
+				/* Add packet to bitstream */
+				ogg_stream_packetin(&os,&op);
+				packetsdone++;
+
+				/* If we've gone over a page boundary, we can do actual output,
+				   so do so (for however many pages are available) */
 
-				ret = oe_write_page(&og, opt->out);
-				if(ret != og.header_len + og.body_len)
+				while(!eos)
                                 {
-					opt->error("Failed writing data to output stream\n");
-					ret = 1;
-					goto cleanup; /* Bail */
-				}
-				else
-					bytes_written += ret; 
+					int result = ogg_stream_pageout(&os,&og);
+					if(!result) break;
 
-				if(ogg_page_eos(&og))
-					eos = 1;
+					ret = oe_write_page(&og, opt->out);
+					if(ret != og.header_len + og.body_len)
+					{
+						opt->error("Failed writing data to output stream\n");
+						ret = 1;
+						goto cleanup; /* Bail */
+					}
+					else
+						bytes_written += ret; 
+	
+					if(ogg_page_eos(&og))
+						eos = 1;
+				}
                         }
                 }
         }

1.13      +5 -0      vorbis-tools/oggenc/encode.h

Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- encode.h	2001/09/28 09:51:36	1.12
+++ encode.h	2001/12/18 06:29:20	1.13
@@ -61,12 +61,15 @@
     char *namefmt_remove;
     char *namefmt_replace;
         char *outfile;
+
         /* All 3 in kbps */
         int min_bitrate;
         int nominal_bitrate;
         int max_bitrate;
+
         /* Float from 0 to 1 (low->high) */
         float quality;
+
         unsigned int serial;
 } oe_options;
 
@@ -87,6 +90,8 @@
         int channels;
         long rate;
         int samplesize;
+
+	/* Various bitrate/quality options */
         int bitrate;
         int min_bitrate;
         int max_bitrate;

1.35      +20 -5     vorbis-tools/oggenc/oggenc.c

Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- oggenc.c	2001/12/04 08:38:01	1.34
+++ oggenc.c	2001/12/18 06:29:20	1.35
@@ -22,7 +22,7 @@
 #include "audio.h"
 #include "utf8.h"
 
-#define VERSION_STRING "OggEnc v0.8 (libvorbis rc2)\n"
+#define VERSION_STRING "OggEnc v0.9 (libvorbis rc3)\n"
 #define COPYRIGHT "(c) 2001 Michael Smith <msmith at labyrinth.net.au)\n"
 
 #define CHUNK 4096 /* We do reads, etc. in multiples of this */
@@ -525,16 +525,31 @@
                                 opt->title[opt->title_count - 1] = strdup(optarg);
                                 break;
                         case 'b':
-				opt->nominal_bitrate = atoi(optarg);
+				if(sscanf(optarg, "%d", &opt->nominal_bitrate)
+						!= 1) {
+					fprintf(stderr, "Warning: nominal bitrate \"%s\" not recognised\n", optarg);
+					opt->nominal_bitrate = -1;
+				}
                                 break;
                         case 'm':
-				opt->min_bitrate = atoi(optarg);
+				if(sscanf(optarg, "%d", &opt->min_bitrate)
+						!= 1) {
+					fprintf(stderr, "Warning: minimum bitrate \"%s\" not recognised\n", optarg);
+					opt->min_bitrate = -1;
+				}
                                 break;
                         case 'M':
-				opt->max_bitrate = atoi(optarg);
+				if(sscanf(optarg, "%d", &opt->max_bitrate)
+						!= 1) {
+					fprintf(stderr, "Warning: maximum bitrate \"%s\" not recognised\n", optarg);
+					opt->max_bitrate = -1;
+				}
                                 break;
                         case 'q':
-				opt->quality = (float)(atof(optarg) * 0.1);
+				if(sscanf(optarg, "%f", &opt->quality) != 1) {
+					fprintf(stderr, "Quality option \"%s\" not recognised, ignoring\n", optarg);
+					break;
+				}
                                 if(opt->quality > 1.0f)
                                 {
                                         opt->quality = 1.0f;

--- >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