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

Chris Wolf cwolf at xiph.org
Sun Dec 30 20:26:54 PST 2001



cwolf       01/12/30 20:26:53

  Modified:    oggdrop  Script.rc encode.c encode.h encthread.c encthread.h
                        main.c oggdrop.dsp resource.h
  Log:
  Replace bitrate submenu with quality coefficient slider

Revision  Changes    Path
1.8       +43 -15    win32-tools/oggdrop/Script.rc

Index: Script.rc
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/Script.rc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Script.rc	2001/09/28 15:19:06	1.7
+++ Script.rc	2001/12/31 04:26:52	1.8
@@ -45,18 +45,18 @@
 // TEXTINCLUDE
 //
 
-1 TEXTINCLUDE DISCARDABLE
+1 TEXTINCLUDE DISCARDABLE 
 BEGIN
     "resource.h\0"
 END
 
-2 TEXTINCLUDE DISCARDABLE
+2 TEXTINCLUDE DISCARDABLE 
 BEGIN
     "#include ""afxres.h""\r\n"
     "\0"
 END
 
-3 TEXTINCLUDE DISCARDABLE
+3 TEXTINCLUDE DISCARDABLE 
 BEGIN
     "\r\n"
     "\0"
@@ -70,21 +70,11 @@
 // Menu
 //
 
-IDR_MENU1 MENU DISCARDABLE
+IDR_MENU1 MENU DISCARDABLE 
 BEGIN
     POPUP "Menu"
     BEGIN
-        POPUP "&Bitrate"
-        BEGIN
-            MENUITEM "64 kbps",                     IDM_BITRATE64
-            MENUITEM "80 kbps",                     IDM_BITRATE80, CHECKED
-            MENUITEM "96 kbps",                     IDM_BITRATE96
-            MENUITEM "128 kbps",                    IDM_BITRATE128
-            MENUITEM "160 kbps",                    IDM_BITRATE160
-            MENUITEM "192 kbps",                    IDM_BITRATE192
-            MENUITEM "256 kbps",                    IDM_BITRATE256
-            MENUITEM "350 kbps",                    IDM_BITRATE350
-        END
+        MENUITEM "&Save Quality",               IDM_SAVEQUALITY
         POPUP "&Options"
         BEGIN
             MENUITEM "&Errors to log file",         IDM_LOGERR
@@ -105,6 +95,44 @@
 // Icon with lowest ID value placed first to ensure application icon
 // remains consistent on all systems.
 IDI_ICON1               ICON    DISCARDABLE     "resource/fish.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_QUALITY DIALOG DISCARDABLE  0, 0, 150, 66
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Save Quality"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "Quality Coeffcient",IDC_STATIC,47,7,56,8
+    CONTROL         "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_AUTOTICKS | 
+                    TBS_BOTH | WS_TABSTOP,25,22,100,15
+    PUSHBUTTON      "Accept",IDC_BUTTON1,60,42,30,14
+    LTEXT           "0.01%",IDC_STATIC,16,14,20,8
+    LTEXT           "100%",IDC_STATIC,121,15,18,8
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    IDD_QUALITY, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 142
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 59
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
 #endif    // English (U.S.) resources
 /////////////////////////////////////////////////////////////////////////////
 

1.3       +3 -1      win32-tools/oggdrop/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encode.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- encode.c	2001/08/30 16:50:20	1.2
+++ encode.c	2001/12/31 04:26:52	1.3
@@ -47,9 +47,11 @@
 
         /* Have vorbisenc choose a mode for us */
         vorbis_info_init(&vi);
+  /*
         vorbis_encode_init(&vi, opt->channels, opt->rate, -1, 
                         opt->bitrate*1000, -1);
-
+  */
+  vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality_coefficient);
 
         /* Now, set up the analysis engine, stream encoder, and other
            preparation before the encoding begins.

1.3       +2 -0      win32-tools/oggdrop/encode.h

Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encode.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- encode.h	2001/08/30 16:50:11	1.2
+++ encode.h	2001/12/31 04:26:52	1.3
@@ -48,6 +48,7 @@
         char *namefmt;
         char *outfile;
         int kbps;
+  float quality_coefficient;
 } oe_options;
 
 typedef struct
@@ -66,6 +67,7 @@
         int channels;
         long rate;
         int bitrate;
+  float quality_coefficient;
 
         FILE *out;
         char *filename;

1.7       +15 -9     win32-tools/oggdrop/encthread.c

Index: encthread.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encthread.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- encthread.c	2001/09/29 17:52:54	1.6
+++ encthread.c	2001/12/31 04:26:52	1.7
@@ -19,7 +19,7 @@
 enclist_t *head = NULL;
 
 oe_options opt = {NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, 
-		0, 0, NULL,NULL, 64}; /* Default values */
+		0, 0, NULL,NULL, 0, 1.0}; /* Default values */
 
 /* Define supported formats here */
 input_format formats[] = {
@@ -110,6 +110,16 @@
         opt.kbps = kbps;
 }
 
+void encthread_setquality(int quality)
+{
+  if (quality < 0)
+    quality = 1;
+  else if (quality > 100)
+    quality = 100;
+
+  opt.quality_coefficient = (float)(((float)quality)/100.0);
+}
+
 void _nothing_prog(char *fn, long total, long done, double time)
 {
         // do nothing
@@ -159,6 +169,7 @@
                         enc_opts.progress_update = _update;
                         enc_opts.end_encode = _nothing_end;
                         enc_opts.error = _error;
+      enc_opts.quality_coefficient = 1.0;
 
                         set_filename(in_file);
 
@@ -214,9 +225,10 @@
                         enc_opts.out = out;
                         enc_opts.comments = &vc;
                         enc_opts.filename = out_fn;
-			/* enc_opts.bitrate = opt.kbps; /* defaulted at the start, so this is ok */
-			enc_opts.bitrate = opt.kbps * enc_opts.channels / 2; /* Olaf: Scale to match channel count */
 
+			//enc_opts.bitrate = opt.kbps * enc_opts.channels / 2; /* Olaf: Scale to match channel count */
+      enc_opts.quality_coefficient = opt.quality_coefficient;
+
                         if (!enc_opts.total_samples_per_channel)
                                 enc_opts.progress_update = _nothing_prog;
 
@@ -237,12 +249,6 @@
 
                 Sleep(500);
         } 
-
-	/* Olaf: We already reset these a few lines above
-	animate = 0;
-	totalfiles = 0;
-	numfiles = 0;
-	*/
 
         DeleteCriticalSection(&mutex);
 

1.3       +1 -1      win32-tools/oggdrop/encthread.h

Index: encthread.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encthread.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- encthread.h	2001/08/30 16:50:54	1.2
+++ encthread.h	2001/12/31 04:26:52	1.3
@@ -3,6 +3,6 @@
 
 void encthread_init(void);
 void encthread_addfile(char *file);
-void encthread_setbitrate(int kbps);
+void encthread_setquality(int quality);
 
 #endif

1.7       +96 -54    win32-tools/oggdrop/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/main.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- main.c	2001/09/28 15:19:06	1.6
+++ main.c	2001/12/31 04:26:52	1.7
@@ -2,6 +2,8 @@
 #include <shellapi.h>
 #include <string.h>
 #include <stdio.h>
+#include <commctrl.h>
+
 #include "resource.h"
 #include "encthread.h"
 #include "audio.h"
@@ -25,9 +27,16 @@
 double file_complete;
 int totalfiles;
 int numfiles;
+HWND g_hwnd;
+HWND qcwnd;
+int qcValue;
+
 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
 int animate = 0;
 
+BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, 
+                     WPARAM wParam, LPARAM lParam) ;
+
 int get_base_key(HKEY* key)
 {
         DWORD disposition;
@@ -56,18 +65,10 @@
                 RegSetValueEx(base_key, name, 0, REG_DWORD, (byte*)&value, sizeof(int));
 }
 
-void set_bitrate(int v)
+void set_quality_coefficient(int v)
 {
-	CheckMenuItem(menu, IDM_BITRATE64, v == 64 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE80, v == 80 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE96, v == 96 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE128, v == 128 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE160, v == 160 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE192, v == 192 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE256, v == 256 ? MF_CHECKED : MF_UNCHECKED);
-	CheckMenuItem(menu, IDM_BITRATE350, v == 350 ? MF_CHECKED : MF_UNCHECKED);
-	encthread_setbitrate(v);
-	write_setting("bitrate", v);
+  encthread_setquality(v);
+  write_setting("quality", v);
 }
 
 void set_always_on_top(HWND hwnd, int v)
@@ -90,7 +91,7 @@
         HWND hwnd;
         MSG msg;
         WNDCLASS wndclass;
-    const int width = 120;
+  const int width = 120;
         const int height = 120;
         int x;
         int y;
@@ -111,17 +112,20 @@
         RegisterClass(&wndclass);
 
         x = max(min(read_setting("window_x", 64), GetSystemMetrics(SM_CXSCREEN) - width), 0);
-    y = max(min(read_setting("window_y", 64), GetSystemMetrics(SM_CYSCREEN) - height), 0);
+  y = max(min(read_setting("window_y", 64), GetSystemMetrics(SM_CYSCREEN) - height), 0);
 
-    hwnd = CreateWindow(szAppName, "OggDrop", WS_POPUP | WS_DLGFRAME, x, y,
-		width, height, NULL, NULL, hInstance, NULL);
+  hwnd = CreateWindow(szAppName, "OggDrop", WS_POPUP | WS_DLGFRAME, x, y,
+  width, height, NULL, NULL, hInstance, NULL);
 
+  g_hwnd = hwnd;
+
         ShowWindow(hwnd, iCmdShow);
         UpdateWindow(hwnd);
 
         SetTimer(hwnd, 1, 80, NULL);
 
-	set_bitrate(read_setting("bitrate", 96));
+  qcValue = read_setting("quality", 75);
+  set_quality_coefficient(qcValue);
         set_always_on_top(hwnd, read_setting("always_on_top", 1));
         set_logerr(hwnd, read_setting("logerr", 0));
         
@@ -183,7 +187,6 @@
         switch (message) {
         case WM_CREATE:
                 menu = LoadMenu(hinst, MAKEINTRESOURCE(IDR_MENU1));
-		if (menu == NULL) MessageBox(hwnd, "ACK!", "ACK!", 0);
                 menu = GetSubMenu(menu, 0);
 
                 offscreen = CreateCompatibleDC(NULL);
@@ -216,8 +219,8 @@
                 
                 percomp = ((double)(totalfiles - numfiles) + 1 - (1 - file_complete)) / (double)totalfiles;
 
-		SetRect(&bar1, 0, height - 23, file_complete * width, height - 13);
-		SetRect(&bar2, 0, height - 12, percomp * width, height - 2);
+		SetRect(&bar1, 0, height - 23, (int)(file_complete * width), height - 13);
+		SetRect(&bar2, 0, height - 12, (int)(percomp * width), height - 2);
 
                 FillRect(offscreen, &bar1, (HBRUSH)GetStockObject(BLACK_BRUSH));
                 FillRect(offscreen, &bar2, (HBRUSH)GetStockObject(BLACK_BRUSH));
@@ -225,8 +228,10 @@
                 BitBlt(hdc, 0, 0, width, height, offscreen, 0, 0, SRCCOPY);
 
                 EndPaint(hwnd, &ps);
-		return 0;
 
+    return DefWindowProc(hwnd, message, wParam, lParam);
+		//return 0;
+
         case WM_TIMER:
                 if (animate || frame) {
                         frame--;
@@ -287,7 +292,9 @@
                 return 0;
 
         case WM_COMMAND:
-		switch (LOWORD(wParam)) {
+		switch (LOWORD(wParam)) 
+    {
+ 
                 case IDM_QUIT:
                         encoding_done = 1;
                         PostQuitMessage(0);
@@ -297,40 +304,22 @@
                         break;	
                 case IDM_LOGERR:
                         set_logerr(hwnd, ~GetMenuState(menu, LOWORD(wParam), MF_BYCOMMAND) & MF_CHECKED);
-			break;
-		case IDM_BITRATE64:
-			set_bitrate(64);
-			encthread_setbitrate(64);
-			break;
-		case IDM_BITRATE80:
-			set_bitrate(80);
-			encthread_setbitrate(80);
-			break;
-		case IDM_BITRATE96:
-			set_bitrate(96);
-			encthread_setbitrate(96);
-			break;
-		case IDM_BITRATE128:
-			set_bitrate(128);
-			encthread_setbitrate(128);
                         break;
-		case IDM_BITRATE160:
-			set_bitrate(160);
-			encthread_setbitrate(160);
-			break;
-		case IDM_BITRATE192:
-			set_bitrate(192);
-			encthread_setbitrate(192);
-			break;
-		case IDM_BITRATE256:
-			set_bitrate(256);
-			encthread_setbitrate(256);
-			break;
-		case IDM_BITRATE350:
-			set_bitrate(350);
-			encthread_setbitrate(350);
-			break;
-		}
+
+    case IDM_SAVEQUALITY:
+      {
+        int value = 
+          DialogBox(
+                hinst,  
+                MAKEINTRESOURCE(IDD_QUALITY),   
+                hwnd, QCProc);
+
+        if (value != -1)
+          set_quality_coefficient(value);
+      }
+      break;
+
+    } // LOWORD(wParam)
                 return 0;
 
         case WM_DROPFILES:
@@ -347,3 +336,56 @@
 
         return DefWindowProc(hwnd, message, wParam, lParam);
 }
+
+ /**
+  * Saved quality coefficient slider dialog procedure.
+  */
+BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, 
+                     WPARAM wParam, LPARAM lParam) 
+{
+  switch (message) 
+  { 
+  case WM_INITDIALOG: 
+ 
+    SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETRANGE, 
+        (WPARAM) TRUE,                   // redraw flag 
+        (LPARAM) MAKELONG(0, 100));  // min. & max. positions 
+
+    SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETPAGESIZE, 
+        0, (LPARAM) 4);                  // new page size 
+ 
+    SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETSEL, 
+        (WPARAM) FALSE,                  // redraw flag 
+        (LPARAM) MAKELONG(0, 100));
+
+    SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETPOS, 
+        (WPARAM) TRUE,                   // redraw flag 
+        (LPARAM) read_setting("quality", 75)); 
+    break;
+
+   case WM_HSCROLL:
+
+    qcValue = (LONG)SendDlgItemMessage(hwndDlg, IDC_SLIDER1, 
+                        TBM_GETPOS, (WPARAM)0, (LPARAM)0 );
+    break;
+
+    case WM_CLOSE:
+      EndDialog(hwndDlg, -1);
+    break;
+
+
+    case WM_COMMAND: 
+      switch (LOWORD(wParam)) 
+      { 
+        case IDC_BUTTON1:
+        {
+          EndDialog(hwndDlg, qcValue);
+          return TRUE;
+        }
+        default: 
+            break; 
+      } 
+  } 
+  return FALSE; 
+} 
+ 

1.9       +6 -2      win32-tools/oggdrop/oggdrop.dsp

Index: oggdrop.dsp
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/oggdrop.dsp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- oggdrop.dsp	2001/09/14 07:04:43	1.8
+++ oggdrop.dsp	2001/12/31 04:26:52	1.9
@@ -70,7 +70,7 @@
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\ogg\include" /I "..\..\vorbis\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\ogg\include" /I "..\..\vorbis\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /FD /GZ /c
 # SUBTRACT CPP /YX
 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@@ -81,7 +81,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ogg_static_d.lib vorbis_static_d.lib vorbisenc_static_d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd" /pdbtype:sept /libpath:"..\..\ogg\win32\Static_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Static_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Static_Debug"
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib ogg_static_d.lib vorbis_static_d.lib vorbisenc_static_d.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcmtd" /pdbtype:sept /libpath:"..\..\ogg\win32\Static_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Static_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Static_Debug"
 # SUBTRACT LINK32 /pdb:none
 
 !ENDIF 
@@ -112,6 +112,10 @@
 # Begin Source File
 
 SOURCE=.\oe_win32.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\tb.c
 # End Source File
 # End Group
 # Begin Group "Header Files"

1.6       +11 -7     win32-tools/oggdrop/resource.h

Index: resource.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/resource.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- resource.h	2001/09/28 15:19:07	1.5
+++ resource.h	2001/12/31 04:26:52	1.6
@@ -2,6 +2,7 @@
 // Microsoft Developer Studio generated include file.
 // Used by Script.rc
 //
+#define IDD_QUALITY                     101
 #define IDB_TF01                        112
 #define IDB_TF02                        113
 #define IDB_TF03                        114
@@ -16,6 +17,8 @@
 #define IDB_TF12                        123
 #define IDR_MENU1                       124
 #define IDI_ICON1                       130
+#define IDC_SLIDER1                     1000
+#define IDC_BUTTON1                     1001
 #define IDM_QUIT                        40005
 #define IDM_BITRATE128                  40006
 #define IDM_BITRATE256                  40007
@@ -23,19 +26,20 @@
 #define IDM_BITRATE350                  40009
 #define IDM_BITRATE192                  40010
 #define IDM_BITRATE160                  40011
-#define IDM_BITRATE64					40012
-#define IDM_BITRATE80					40013
-#define IDM_BITRATE96					40014
+#define IDM_BITRATE64                   40012
+#define IDM_BITRATE80                   40013
+#define IDM_BITRATE96                   40014
 #define IDM_LOGERR                      40015
+#define IDM_SAVEQUALITY                 40016
 
 // Next default values for new objects
-//
+// 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NO_MFC                     1
-#define _APS_NEXT_RESOURCE_VALUE        132
-#define _APS_NEXT_COMMAND_VALUE         40016
-#define _APS_NEXT_CONTROL_VALUE         1000
+#define _APS_NEXT_RESOURCE_VALUE        133
+#define _APS_NEXT_COMMAND_VALUE         40017
+#define _APS_NEXT_CONTROL_VALUE         1002
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif

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