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

Michael Smith msmith at xiph.org
Sat Mar 29 05:15:27 PST 2003



msmith      03/03/29 08:15:27

  Modified:    oggenc   audio.c oggenc.c
  Log:
  24 bit input support.

Revision  Changes    Path
1.32      +32 -5     vorbis-tools/oggenc/audio.c

Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/audio.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- audio.c	19 Jan 2003 23:04:24 -0000	1.31
+++ audio.c	29 Mar 2003 13:15:26 -0000	1.32
@@ -321,7 +321,7 @@
         {
                 fprintf(stderr, 
                                 _("Warning: OggEnc does not support this type of AIFF/AIFC file\n"
-				" Must be 8 or 16 bit PCM.\n"));
+				" Must be 8, 16, or 24 bit PCM.\n"));
                 return 0;
         }
 }
@@ -420,7 +420,9 @@
 
 
         if( format.align == format.channels*samplesize &&
-			format.samplesize == samplesize*8)
+			format.samplesize == samplesize*8 && 
+    		(format.samplesize == 24 || format.samplesize == 16 || 
+             format.samplesize == 8))
         {
                 /* OK, good - we have the one supported format,
                    now we want to find the size of the file */
@@ -461,7 +463,7 @@
         else
         {
                 fprintf(stderr, 
-				_("ERROR: Wav file is unsupported subformat (must be 16 bit PCM\n"
+				_("ERROR: Wav file is unsupported subformat (must be 8,16, or 24 bit PCM\n"
                                 "or floating point PCM\n"));
                 return 0;
         }
@@ -495,7 +497,7 @@
                         }
                 }
         }
-	else
+	else if(f->samplesize==16)
         {
                 if(!f->bigendian)
                 {
@@ -520,6 +522,32 @@
                         }
                 }
         }
+    else if(f->samplesize==24) 
+    {
+        if(!f->bigendian) {
+            for(i = 0; i < realsamples; i++)
+            {
+                for(j=0; j < f->channels; j++) 
+                {
+                    buffer[j][i] = ((buf[i*3*f->channels + 3*j + 2] << 16) |
+                      (((unsigned char *)buf)[i*3*f->channels + 3*j + 1] << 8) |
+                      (((unsigned char *)buf)[i*3*f->channels + 3*j] & 0xff)) 
+                        / 8388608.0f;
+
+                }
+            }
+        }
+        else {
+            fprintf(stderr, _("Big endian 24 bit PCM data is not currently "
+                              "supported, aborting.\n"));
+            return 0;
+        }
+    }
+    else {
+        fprintf(stderr, _("Internal error: attempt to read unsupported "
+                          "bitdepth %d\n"), f->samplesize);
+        return 0;
+    }
 
         return realsamples;
 }
@@ -594,7 +622,6 @@
     resampler *rs = d;
     long in_samples;
     int out_samples;
-    int i;
 
     in_samples = res_push_max_input(&rs->resampler, samples);
     if(in_samples > rs->bufsize)

<p><p>1.71      +2 -2      vorbis-tools/oggenc/oggenc.c

Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- oggenc.c	7 Nov 2002 10:47:21 -0000	1.70
+++ oggenc.c	29 Mar 2003 13:15:26 -0000	1.71
@@ -439,11 +439,11 @@
                 "                      once, for example, and have it used for all the files)\n"
                 "\n"
                 "INPUT FILES:\n"
-		" OggEnc input files must currently be 16 or 8 bit PCM WAV, AIFF, or AIFF/C\n"
+		" OggEnc input files must currently be 24, 16, or 8 bit PCM WAV, AIFF, or AIFF/C\n"
                 " files, or 32 bit IEEE floating point WAV. Files may be mono or stereo\n"
         " (or more channels) and any sample rate.\n"
                 " Alternatively, the --raw option may be used to use a raw PCM data file, which\n"
-		" must be 16bit stereo little-endian PCM ('headerless wav'), unless additional\n"
+		" must be 16 bit stereo little-endian PCM ('headerless wav'), unless additional\n"
                 " parameters for raw mode are specified.\n"
                 " You can specify taking the file from stdin by using - as the input filename.\n"
                 " In this mode, output is to stdout unless an output filename is specified\n"

<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