[xiph-cvs] cvs commit: win32-tools/oggdrop Script.rc audio.c encode.h main.c

Michael Smith msmith at xiph.org
Fri Jul 19 01:33:49 PDT 2002



msmith      02/07/19 01:33:49

  Modified:    oggdrop  Script.rc audio.c encode.h main.c
  Log:
  More updates from Ryan

Revision  Changes    Path
1.16      +1 -1      win32-tools/oggdrop/Script.rc

Index: Script.rc
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/Script.rc,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Script.rc	2002/01/08 13:00:25	1.15
+++ Script.rc	2002/07/19 08:33:48	1.16
@@ -7,7 +7,7 @@
 //
 // Generated from the TEXTINCLUDE 2 resource.
 //
-#include "afxres.h"
+#include "winres.h"
 
 /////////////////////////////////////////////////////////////////////////////
 #undef APSTUDIO_READONLY_SYMBOLS

<p><p>1.4       +6 -6      win32-tools/oggdrop/audio.c

Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/audio.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- audio.c	2002/01/06 19:17:00	1.3
+++ audio.c	2002/07/19 08:33:48	1.4
@@ -219,8 +219,8 @@
 
         for(i = 0; i < bytes_read/4; i++)
         {
-		buffer[0][i] = ((buf[i*4+1]<<8) | (((int)buf[i*4]) & 0xff))/32768.0;
-		buffer[1][i] = ((buf[i*4+3]<<8) | (((int)buf[i*4+2]) & 0xff))/32768.0;
+		buffer[0][i] = (float) (((buf[i*4+1]<<8) | (((int)buf[i*4]) & 0xff))/32768.0);
+		buffer[1][i] = (float) (((buf[i*4+3]<<8) | (((int)buf[i*4+2]) & 0xff))/32768.0);
         }
 
         return bytes_read/4;
@@ -234,8 +234,8 @@
 
         for(i=0;i<bytes_read/4; i++)
         {
-		buffer[0][i] = ((buf[i*4+1]<<8) | (((int)buf[i*4]) & 0xff))/32768.0;
-		buffer[1][i] = ((buf[i*4+3]<<8) | (((int)buf[i*4+2]) & 0xff))/32768.0;
+		buffer[0][i] = (float) (((buf[i*4+1]<<8) | (((int)buf[i*4]) & 0xff))/32768.0);
+		buffer[1][i] = (float) (((buf[i*4+3]<<8) | (((int)buf[i*4+2]) & 0xff))/32768.0);
         }
 
         return bytes_read/4;
@@ -254,7 +254,7 @@
 
 
         for(i=0;i<bytes_read/2; i++)
-		buffer[0][i] = ((buf[i*2+1]<<8) | (((int)buf[i*2]) & 0xff))/32768.0;
+		buffer[0][i] = (float) (((buf[i*2+1]<<8) | (((int)buf[i*2]) & 0xff))/32768.0);
 
         return bytes_read/2;
 }
@@ -281,7 +281,7 @@
  */
 void set_filename(const char *filename)
 {
-	_filename = filename;
+	_filename = (char *) filename;
 }
 
 /**

<p><p>1.5       +1 -0      win32-tools/oggdrop/encode.h

Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encode.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- encode.h	2002/01/03 09:12:13	1.4
+++ encode.h	2002/07/19 08:33:48	1.5
@@ -3,6 +3,7 @@
 
 #include <stdio.h>
 #include <vorbis/codec.h>
+#include <vorbis/vorbisenc.h>
 
 
 typedef void TIMER;

<p><p>1.15      +27 -5     win32-tools/oggdrop/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/main.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- main.c	2002/01/08 12:52:40	1.14
+++ main.c	2002/07/19 08:33:48	1.15
@@ -11,7 +11,7 @@
 #define LOSHORT(l)           ((SHORT)(l))
 #define HISHORT(l)           ((SHORT)(((DWORD)(l) >> 16) & 0xFFFF))
 
-#define BASEKEY "Software\\Xiphophorus\\Oggdrop"
+#define BASEKEY "Software\\Xiph.Org\\Oggdrop"
 
 #define VORBIS_DEFAULT_QUALITY 40
 
@@ -74,8 +74,10 @@
 BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, 
                      WPARAM wParam, LPARAM lParam) ;
 
-float qc2approxBitrate(int qcValue);
 
+float qc2approxBitrate(float qcValue, int rate, int channels);
+
+
 int get_base_key(HKEY* key)
 {
         DWORD disposition;
@@ -482,7 +484,7 @@
 
                   qcValue = read_setting("quality", VORBIS_DEFAULT_QUALITY);
 
-			nominalBitrate = qc2approxBitrate(qcValue);
+			nominalBitrate = qc2approxBitrate((float) qcValue, 44100, 2);
             (void) sprintf(editBuf, "%03.1fkbps", nominalBitrate/1000);
 
             SendDlgItemMessage(hwndDlg, IDC_EDIT2, WM_SETTEXT,(WPARAM)0, (LPARAM)editBuf);
@@ -532,7 +534,7 @@
 //    	SetFocus(GetDlgItem(hwndDlg, IDC_EDIT1));
 //    	SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETSEL,(WPARAM)0, (LPARAM)-1);
 
-			nominalBitrate = qc2approxBitrate(qcValue);
+			nominalBitrate = qc2approxBitrate((float) qcValue, 44100, 2);
                         (void) sprintf(editBuf, "%03.1fkbps", nominalBitrate/1000);
 
                         SendDlgItemMessage(hwndDlg, IDC_EDIT2, WM_SETTEXT,(WPARAM)0, (LPARAM)editBuf);
@@ -671,9 +673,25 @@
 } 
 
 
-float qc2approxBitrate(int qcValue)
+float qc2approxBitrate(float qcValue, int rate, int channels)
 {
+#if 1  /* this is probably slower, but always portable/accurate. */
+    vorbis_info vi;
+    float br;
+
+    vorbis_info_init(&vi);
+    if(vorbis_encode_init_vbr(&vi, channels, rate, (float) (qcValue / 100.0))) 
+        return 128000.0; /* Mode setup failed: go with a default. */
+
+    br = (float)vi.bitrate_nominal;
+    vorbis_info_clear(&vi);
+
+    return br;
+
+#else   /* this is fast, but it wings it with incorrect results. */
+
   float approxBitrate;
+  double scale;
 
   if ( qcValue < 41)
   {
@@ -694,5 +712,9 @@
             ((((float)qcValue/10)-8)*32)+((((float)qcValue/10)-9)*116));
   }
 
+  if (approxBitrate < 64000.0)
+    approxBitrate = 64000.0;
+
   return approxBitrate;
+#endif
 }

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