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

Chris Wolf cwolf at xiph.org
Wed Jan 2 23:45:01 PST 2002



cwolf       02/01/02 23:45:00

  Modified:    oggdrop  Script.rc encthread.h main.c oggdrop.opt resource.h
  Log:
  put bitrate back into parameters dialog, add text field, radio buttons, list box, extra event handling...

Revision  Changes    Path
1.9       +16 -10    win32-tools/oggdrop/Script.rc

Index: Script.rc
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/Script.rc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Script.rc	2001/12/31 04:26:52	1.8
+++ Script.rc	2002/01/03 07:44:59	1.9
@@ -74,7 +74,7 @@
 BEGIN
     POPUP "Menu"
     BEGIN
-        MENUITEM "&Save Quality",               IDM_SAVEQUALITY
+        MENUITEM "&Encode Parameters",          IDM_SAVEQUALITY
         POPUP "&Options"
         BEGIN
             MENUITEM "&Errors to log file",         IDM_LOGERR
@@ -101,17 +101,23 @@
 // Dialog
 //
 
-IDD_QUALITY DIALOG DISCARDABLE  0, 0, 150, 66
+IDD_QUALITY DIALOG DISCARDABLE  0, 0, 230, 119
 STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Save Quality"
+CAPTION "Encode Parameters"
 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
+                    TBS_BOTH | WS_TABSTOP,49,14,115,24
+    PUSHBUTTON      "Accept",IDC_BUTTON1,95,90,30,14
+    EDITTEXT        IDC_EDIT1,15,19,31,14,ES_WANTRETURN
+    GROUPBOX        "Quality",IDC_STATIC,7,7,209,33
+    CONTROL         "Select",IDC_USEQUALITY,"Button",BS_AUTORADIOBUTTON,175,
+                    20,36,10
+    GROUPBOX        "Bit Rate",IDC_STATIC,7,43,209,40
+    CONTROL         "Select",IDC_USEBITRATE,"Button",BS_AUTORADIOBUTTON,175,
+                    58,36,10
+    LISTBOX         IDC_BITRATE,15,52,48,27,LBS_NOINTEGRALHEIGHT | 
+                    LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP
 END
 
 
@@ -126,9 +132,9 @@
     IDD_QUALITY, DIALOG
     BEGIN
         LEFTMARGIN, 7
-        RIGHTMARGIN, 142
+        RIGHTMARGIN, 225
         TOPMARGIN, 7
-        BOTTOMMARGIN, 59
+        BOTTOMMARGIN, 112
     END
 END
 #endif    // APSTUDIO_INVOKED

1.4       +1 -0      win32-tools/oggdrop/encthread.h

Index: encthread.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/encthread.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- encthread.h	2001/12/31 04:26:52	1.3
+++ encthread.h	2002/01/03 07:44:59	1.4
@@ -4,5 +4,6 @@
 void encthread_init(void);
 void encthread_addfile(char *file);
 void encthread_setquality(int quality);
+void encthread_setbitrate(int bitrate);
 
 #endif

1.8       +171 -10   win32-tools/oggdrop/main.c

Index: main.c
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/main.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- main.c	2001/12/31 04:26:52	1.7
+++ main.c	2002/01/03 07:44:59	1.8
@@ -13,6 +13,8 @@
 
 #define BASEKEY "Software\\Xiphophorus\\Oggdrop"
 
+#define VORBIS_DEFAULT_QUALITY 75
+
 HANDLE event = NULL;
 int width = 120, height = 120;
 RECT bar1, bar2;
@@ -30,7 +32,32 @@
 HWND g_hwnd;
 HWND qcwnd;
 int qcValue;
+int bitRate;
+
+
+static const char *bitRateCaption[] =
+{
+  "64",
+  "80",
+  "96",
+  "112",
+  "128",
+  "160",
+  "192",
+  "224",
+  "256",
+  "288",
+  "320",
+  "352",
+  0
+};
 
+typedef union
+{
+  int buflen;
+  char buf[16];
+} EBUF;
+
 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
 int animate = 0;
 
@@ -71,6 +98,12 @@
   write_setting("quality", v);
 }
 
+void set_bitrate(int v)
+{
+  encthread_setbitrate(v);
+  write_setting("bitrate", v);
+}
+
 void set_always_on_top(HWND hwnd, int v)
 {
         CheckMenuItem(menu, IDM_ONTOP, v ? MF_CHECKED : MF_UNCHECKED);
@@ -124,7 +157,7 @@
 
         SetTimer(hwnd, 1, 80, NULL);
 
-  qcValue = read_setting("quality", 75);
+  qcValue = read_setting("quality", VORBIS_DEFAULT_QUALITY);
   set_quality_coefficient(qcValue);
         set_always_on_top(hwnd, read_setting("always_on_top", 1));
         set_logerr(hwnd, read_setting("logerr", 0));
@@ -314,7 +347,9 @@
                 MAKEINTRESOURCE(IDD_QUALITY),   
                 hwnd, QCProc);
 
-        if (value != -1)
+        if (value == -2)
+          set_bitrate(bitRate);
+        else if (value != -1)
           set_quality_coefficient(value);
       }
       break;
@@ -338,11 +373,15 @@
 }
 
  /**
-  * Saved quality coefficient slider dialog procedure.
+  *  Encode parameters dialog procedures.
   */
 BOOL CALLBACK QCProc(HWND hwndDlg, UINT message, 
                      WPARAM wParam, LPARAM lParam) 
 {
+  char editBuf[16];
+  EBUF buf2;
+  int br, i, len;
+
   switch (message) 
   { 
   case WM_INITDIALOG: 
@@ -360,31 +399,153 @@
 
     SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETPOS, 
         (WPARAM) TRUE,                   // redraw flag 
-        (LPARAM) read_setting("quality", 75)); 
-    break;
+        (LPARAM) read_setting("quality", VORBIS_DEFAULT_QUALITY));
+
+    SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETLIMITTEXT,
+        (WPARAM) 4, (LPARAM)0);
+
+    (void) sprintf(editBuf, "%02.1f", 
+        (float) ((float)read_setting("quality", VORBIS_DEFAULT_QUALITY)/10.0));
+
+    SendDlgItemMessage(hwndDlg, IDC_EDIT1, WM_SETTEXT,
+        (WPARAM)0, (LPARAM)editBuf);
+
+    SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_SETSEL,
+        (WPARAM)0, (LPARAM)-1);
+
+    (void) CheckRadioButton(hwndDlg, IDC_USEQUALITY,
+                                     IDC_USEBITRATE,
+                                     read_setting("mode", IDC_USEQUALITY));
 
+    for (br=0; bitRateCaption[br] != 0; br++)
+    {
+      SendDlgItemMessage(hwndDlg, IDC_BITRATE, LB_ADDSTRING,
+          (WPARAM)0, (LPARAM) bitRateCaption[br]);
+
+      SendDlgItemMessage(hwndDlg, IDC_BITRATE, LB_SETITEMDATA, 
+          (WPARAM) br, (LPARAM) atoi(bitRateCaption[br]));
+    }
+
+    bitRate = read_setting("bitrate", 128);
+    (void) sprintf(editBuf, "%d", bitRate);
+    
+    for(br=0; bitRateCaption[br] != 0; br++)
+    {
+      if ( ! strcmp(bitRateCaption[br], editBuf) )
+      {
+        SendDlgItemMessage(hwndDlg, IDC_BITRATE, LB_SETCURSEL,
+            (WPARAM) br, (LPARAM) 0);
+        break;
+      }
+    }
+
+   break;
+
    case WM_HSCROLL:
 
     qcValue = (LONG)SendDlgItemMessage(hwndDlg, IDC_SLIDER1, 
                         TBM_GETPOS, (WPARAM)0, (LPARAM)0 );
+
+    (void) sprintf(editBuf, "%02.1f", (float)(((float)qcValue/10.0)));
+
+    SendDlgItemMessage(hwndDlg, IDC_EDIT1, WM_SETTEXT,
+        (WPARAM)0, (LPARAM)editBuf);
+
+    (void) CheckRadioButton(hwndDlg, IDC_USEQUALITY,
+                                     IDC_USEBITRATE,
+                                     IDC_USEQUALITY);
+
     break;
 
     case WM_CLOSE:
       EndDialog(hwndDlg, -1);
     break;
 
-
     case WM_COMMAND: 
       switch (LOWORD(wParam)) 
       { 
         case IDC_BUTTON1:
-        {
-          EndDialog(hwndDlg, qcValue);
+          if (IsDlgButtonChecked(hwndDlg, IDC_USEQUALITY) == BST_CHECKED)
+          {
+            write_setting("mode", IDC_USEQUALITY);
+            EndDialog(hwndDlg, qcValue);
+          }
+          else
+          {
+            write_setting("mode", IDC_USEBITRATE);
+            EndDialog(hwndDlg, -2); // use bitrate
+          }
           return TRUE;
-        }
+        
+        case IDC_BITRATE:
+          (void) CheckRadioButton(hwndDlg, IDC_USEQUALITY,
+                                           IDC_USEBITRATE,
+                                           IDC_USEBITRATE);
+
+          if ((br = SendDlgItemMessage(hwndDlg, IDC_BITRATE, LB_GETCURSEL,
+                   (WPARAM) 0, (LPARAM) 0)) != LB_ERR)
+          {
+            bitRate = SendDlgItemMessage(hwndDlg, IDC_BITRATE, LB_GETITEMDATA,
+                   (WPARAM) br, (LPARAM) 0);
+          }
+
+          break;
+
+        case IDC_EDIT1:
+          (void) CheckRadioButton(hwndDlg, IDC_USEQUALITY,
+                                     IDC_USEBITRATE,
+                                     IDC_USEQUALITY);
+
+          switch (HIWORD(wParam))
+          {
+           
+          case EN_UPDATE:
+            (void) memset(&buf2, 0, sizeof(buf2));
+            buf2.buflen = sizeof(buf2.buf);
+            len = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_GETLINE,
+              (WPARAM) 0, (LPARAM) buf2.buf);
+
+            for (i=0; i<len; i++)
+              if ( ! isdigit(buf2.buf[i]) && buf2.buf[i] != '.')
+              {
+                buf2.buf[i] = '\0';
+                SendDlgItemMessage(hwndDlg, IDC_EDIT1, WM_SETTEXT,
+                  (WPARAM) 0, (LPARAM) buf2.buf);
+              }
+
+            
+            break;
+
+          case EN_CHANGE:
+            {
+              float v=0.0;
+
+            (void) memset(&buf2, 0, sizeof(buf2));
+            buf2.buflen = sizeof(buf2.buf);
+            len = SendDlgItemMessage(hwndDlg, IDC_EDIT1, EM_GETLINE,
+              (WPARAM) 0, (LPARAM) buf2.buf);
+            //MessageBox(g_hwnd, buf2.buf, "Second", 0);
+
+            (void)sscanf(buf2.buf, "%f", &v); 
+
+            SendDlgItemMessage(hwndDlg, IDC_SLIDER1, TBM_SETPOS, 
+              (WPARAM) TRUE,                   // redraw flag 
+              (LPARAM)(int)(v*10.0f));
+            }
+
+            
+          default:
+            break;
+          }
+
         default: 
             break; 
-      } 
+      }
+      break; 
+
+
+      default:
+        break;
   } 
   return FALSE; 
 } 

1.3       +22 -89    win32-tools/oggdrop/oggdrop.opt

Index: oggdrop.opt
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/oggdrop.opt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
Binary files /tmp/cvsmCe3oU and /tmp/cvsUByAPK differ

1.7       +5 -1      win32-tools/oggdrop/resource.h

Index: resource.h
===================================================================
RCS file: /usr/local/cvsroot/win32-tools/oggdrop/resource.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- resource.h	2001/12/31 04:26:52	1.6
+++ resource.h	2002/01/03 07:44:59	1.7
@@ -19,6 +19,10 @@
 #define IDI_ICON1                       130
 #define IDC_SLIDER1                     1000
 #define IDC_BUTTON1                     1001
+#define IDC_EDIT1                       1005
+#define IDC_USEQUALITY                  1009
+#define IDC_USEBITRATE                  1014
+#define IDC_BITRATE                     1020
 #define IDM_QUIT                        40005
 #define IDM_BITRATE128                  40006
 #define IDM_BITRATE256                  40007
@@ -39,7 +43,7 @@
 #define _APS_NO_MFC                     1
 #define _APS_NEXT_RESOURCE_VALUE        133
 #define _APS_NEXT_COMMAND_VALUE         40017
-#define _APS_NEXT_CONTROL_VALUE         1002
+#define _APS_NEXT_CONTROL_VALUE         1021
 #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