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

Michael Smith msmith at xiph.org
Thu Nov 7 01:21:54 PST 2002



msmith      02/11/07 04:21:54

  Modified:    oggenc   audio.c encode.c
  Log:
  Patch from jordy at acm.org (Jordan Mendelson) for little-endian AIFF files,
  as (apparently) produced by MacOS X from CDs.
  
  Some code reformatting in encode.c

Revision  Changes    Path
1.28      +13 -4     vorbis-tools/oggenc/audio.c

Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/audio.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- audio.c	11 Jul 2002 14:20:33 -0000	1.27
+++ audio.c	7 Nov 2002 09:21:54 -0000	1.28
@@ -258,9 +258,18 @@
                         fprintf(stderr, _("Warning: AIFF-C header truncated.\n"));
                         return 0;
                 }
-		else if(memcmp(buffer+18, "NONE", 4)) 
+
+		if(!memcmp(buffer+18, "NONE", 4)) 
+		{
+			aiff->bigendian = 1;
+		}
+		else if(!memcmp(buffer+18, "sowt", 4)) 
+		{
+			aiff->bigendian = 0;
+		}
+		else
                 {
-			fprintf(stderr, _("Warning: Can't handle compressed AIFF-C\n"));
+			fprintf(stderr, _("Warning: Can't handle compressed AIFF-C (%c%c%c%c)\n"), *(buffer+18), *(buffer+19), *(buffer+20), *(buffer+21));
                         return 0; /* Compressed. Can't handle */
                 }
         }
@@ -301,7 +310,6 @@
                 aiff->channels = format.channels;
                 aiff->samplesize = format.samplesize;
                 aiff->totalsamples = format.totalframes;
-		aiff->bigendian = 1;
 
                 opt->readdata = (void *)aiff;
 
@@ -468,8 +476,9 @@
         long realsamples;
 
         if(f->totalsamples && f->samplesread + 
-			bytes_read/(sampbyte*f->channels) > f->totalsamples) 
+			bytes_read/(sampbyte*f->channels) > f->totalsamples) {
                 bytes_read = sampbyte*f->channels*(f->totalsamples - f->samplesread);
+    }
 
         realsamples = bytes_read/(sampbyte*f->channels);
         f->samplesread += realsamples;

<p><p>1.28      +23 -23    vorbis-tools/oggenc/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- encode.c	19 Jul 2002 06:35:48 -0000	1.27
+++ encode.c	7 Nov 2002 09:21:54 -0000	1.28
@@ -155,46 +155,46 @@
     vorbis_info_init(&vi);
     
     if(opt->quality_set > 0){
-      if(vorbis_encode_setup_vbr(&vi, opt->channels, opt->rate, opt->quality)){
-	fprintf(stderr, _("Mode initialisation failed: invalid parameters for quality\n"));
-	vorbis_info_clear(&vi);
-	return 1;
-      }
+        if(vorbis_encode_setup_vbr(&vi, opt->channels, opt->rate, opt->quality)){
+	        fprintf(stderr, _("Mode initialisation failed: invalid parameters for quality\n"));
+	        vorbis_info_clear(&vi);
+	        return 1;
+        }
 
-      /* do we have optional hard quality restrictions? */
-      if(opt->max_bitrate > 0 || opt->min_bitrate > 0){
-	struct ovectl_ratemanage_arg ai;
-	vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &ai);
+        /* do we have optional hard quality restrictions? */
+        if(opt->max_bitrate > 0 || opt->min_bitrate > 0){
+            struct ovectl_ratemanage_arg ai;
+	        vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_GET, &ai);
         
-	ai.bitrate_hard_min=opt->min_bitrate;
-	ai.bitrate_hard_max=opt->max_bitrate;
-	ai.management_active=1;
+	        ai.bitrate_hard_min=opt->min_bitrate;
+	        ai.bitrate_hard_max=opt->max_bitrate;
+	        ai.management_active=1;
 
-	vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &ai);
+	        vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, &ai);
 
-      }
+        }
 
 
     }else {
-      if(vorbis_encode_setup_managed(&vi, opt->channels, opt->rate, 
+        if(vorbis_encode_setup_managed(&vi, opt->channels, opt->rate, 
                                      opt->max_bitrate>0?opt->max_bitrate*1000:-1,
                                      opt->bitrate*1000, 
                                      opt->min_bitrate>0?opt->min_bitrate*1000:-1)){
-	fprintf(stderr, _("Mode initialisation failed: invalid parameters for bitrate\n"));
-	vorbis_info_clear(&vi);
-	return 1;
-      }
+	        fprintf(stderr, _("Mode initialisation failed: invalid parameters for bitrate\n"));
+	        vorbis_info_clear(&vi);
+	        return 1;
+        }
     }
     
     if(opt->managed && opt->bitrate < 0)
-      {
+    {
         vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_AVG, NULL);
-      }
+    }
     else if(!opt->managed)
-      {
+    {
         /* Turn off management entirely (if it was turned on). */
         vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, NULL);
-      }
+    }
     
     set_advanced_encoder_options(opt->advopt, opt->advopt_count, &vi);
     

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