VfW: expose option "Nth pass" (i.e. simultaneously read and update the multipass...
authorLoren Merritt <pengvado@videolan.org>
Sun, 23 Jan 2005 09:38:42 +0000 (09:38 +0000)
committerLoren Merritt <pengvado@videolan.org>
Sun, 23 Jan 2005 09:38:42 +0000 (09:38 +0000)
Patch by Riccardo Stievano.

git-svn-id: svn://svn.videolan.org/x264/trunk@105 df754926-b1dd-0310-bc7b-ec298dee348c

vfw/codec.c
vfw/config.c
vfw/resource.h
vfw/resource.rc
vfw/x264vfw.h

index 8620912..efffa34 100644 (file)
@@ -132,7 +132,6 @@ LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiO
 {
     CONFIG *config = &codec->config;
     x264_param_t param;
-    static char statsfile[] = ".\\x264.stats";
 
     /* Destroy previous handle */
     if( codec->h != NULL )
@@ -197,7 +196,7 @@ LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiO
             break;
         default:
         case 2: /* 2 PASS */
-            param.rc.psz_stat_out = param.rc.psz_stat_in = statsfile;
+            param.rc.psz_stat_out = param.rc.psz_stat_in = config->stats;
             if (config->i_pass == 1)
             {
                 param.rc.b_stat_write = 1;
@@ -218,6 +217,8 @@ LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiO
                 param.rc.i_bitrate = config->i_2passbitrate;
                 param.rc.b_stat_read = 1;
                 param.rc.b_cbr = 1;
+                if( config->b_updatestats )
+                    param.rc.b_stat_write = 1;
             }
             break;
     }
index 267ae91..5b13f64 100644 (file)
@@ -46,7 +46,7 @@
 
 /* description */
 #define X264_NAME        "x264"
-#define X264_DEF_TEXT    "Are you sure you want to load default values"
+#define X264_DEF_TEXT    "Are you sure you want to load default values?"
 
 /* Registery handling */
 typedef struct
@@ -73,6 +73,7 @@ static const reg_int_t reg_int_table[] =
     { "passbitrate",    &reg.i_2passbitrate,    800 },
     { "pass_number",    &reg.i_pass,            1 },
     { "fast1pass",      &reg.b_fast1pass,       1 },
+    { "updatestats",    &reg.b_updatestats,     0 },
 
     /* Advance dialog */
     { "cabac",          &reg.b_cabac,           1 },
@@ -99,7 +100,8 @@ static const reg_int_t reg_int_table[] =
 
 static const reg_str_t reg_str_table[] =
 {
-    { "fourcc",         reg.fcc,                "h264" }
+    { "fourcc",         reg.fcc,                "h264" },
+    { "statsfile",      reg.stats,              ".\\x264.stats" }
 };
 
 void config_reg_load( CONFIG *config )
@@ -124,12 +126,12 @@ void config_reg_load( CONFIG *config )
     /* Read strings */
     for( i = 0; i < sizeof( reg_str_table )/sizeof( reg_str_t); i++ )
     {
-        i_size = 5;   /* fourcc + 1 FIXME ugly */
+        i_size = MAX_PATH;
         if( RegQueryValueEx( hKey, reg_str_table[i].reg_value, 0, 0,
                              (LPBYTE)reg_str_table[i].config_str,
                              &i_size ) != ERROR_SUCCESS )
-            memcpy( reg_str_table[i].config_str,
-                    reg_str_table[i].default_str, 5 );
+            lstrcpy( reg_str_table[i].config_str,
+                     reg_str_table[i].default_str );
     }
 
     RegCloseKey( hKey );
@@ -166,7 +168,7 @@ void config_reg_save( CONFIG *config )
     {
         RegSetValueEx( hKey, reg_str_table[i].reg_value, 0, REG_SZ,
                        (LPBYTE)reg_str_table[i].config_str,
-                        5 );    /* FIXME */
+                        MAX_PATH );
     }
 
     RegCloseKey( hKey );
@@ -210,6 +212,9 @@ static void main_enable_item( HWND hDlg, CONFIG * config )
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE ), FALSE );
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE_S ), FALSE );
         EnableWindow( GetDlgItem( hDlg, IDC_FAST1PASS ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_UPDATESTATS ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE_BROWSE ), FALSE );
         break;
 
     case 1 : /* 1 Pass, Quantizer Based */
@@ -224,6 +229,9 @@ static void main_enable_item( HWND hDlg, CONFIG * config )
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE ), FALSE );
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE_S ), FALSE );
         EnableWindow( GetDlgItem( hDlg, IDC_FAST1PASS ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_UPDATESTATS ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE ), FALSE );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE_BROWSE ), FALSE );
         break;
     
     case 2 : /* 2 Pass */
@@ -238,6 +246,9 @@ static void main_enable_item( HWND hDlg, CONFIG * config )
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE ), config->i_pass > 1 );
         EnableWindow( GetDlgItem( hDlg, IDC_2PASSBITRATE_S ), config->i_pass > 1 );
         EnableWindow( GetDlgItem( hDlg, IDC_FAST1PASS ), config->i_pass == 1);
+        EnableWindow( GetDlgItem( hDlg, IDC_UPDATESTATS ), config->i_pass > 1 );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE ), TRUE );
+        EnableWindow( GetDlgItem( hDlg, IDC_STATSFILE_BROWSE ), TRUE );
         break;
     }
 
@@ -256,6 +267,7 @@ static void main_update_dlg( HWND hDlg, CONFIG * config )
     SetDlgItemInt( hDlg, IDC_BITRATEEDIT, config->bitrate, FALSE );
     SetDlgItemInt( hDlg, IDC_QUANTEDIT, config->i_qp, FALSE );
     SetDlgItemInt( hDlg, IDC_2PASSBITRATE, config->i_2passbitrate, FALSE );
+    SetDlgItemText( hDlg, IDC_STATSFILE, config->stats );
 
     switch( config->i_encoding_type )
     {
@@ -290,6 +302,7 @@ static void main_update_dlg( HWND hDlg, CONFIG * config )
     SendDlgItemMessage( hDlg, IDC_2PASSBITRATE_S, TBM_SETPOS, TRUE,
                         config->i_2passbitrate );
     CheckDlgButton( hDlg, IDC_FAST1PASS, config->b_fast1pass ? BST_CHECKED : BST_UNCHECKED );
+    CheckDlgButton( hDlg, IDC_UPDATESTATS, config->b_updatestats ? BST_CHECKED : BST_UNCHECKED );
 
 }
 
@@ -318,7 +331,7 @@ BOOL CALLBACK callback_main( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
             {
             case IDOK :
                 config->b_save = TRUE;
-                EndDialog( hDlg, LOWORD(wParam) );
+                           EndDialog( hDlg, LOWORD(wParam) );
                 break;
             case IDCANCEL :
                 config->b_save = FALSE;
@@ -365,6 +378,34 @@ BOOL CALLBACK callback_main( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
             case IDC_FAST1PASS :
                 config->b_fast1pass = ( IsDlgButtonChecked( hDlg, IDC_FAST1PASS ) == BST_CHECKED );
                 break;
+            case IDC_UPDATESTATS :
+                config->b_updatestats = ( IsDlgButtonChecked( hDlg, IDC_UPDATESTATS ) == BST_CHECKED );
+                break;
+            case IDC_STATSFILE_BROWSE :
+                {
+                OPENFILENAME ofn;
+                char tmp[MAX_PATH];
+
+                GetDlgItemText( hDlg, IDC_STATSFILE, tmp, MAX_PATH );
+
+                memset( &ofn, 0, sizeof( OPENFILENAME ) );
+                ofn.lStructSize = sizeof( OPENFILENAME );
+
+                ofn.hwndOwner = hDlg;
+                ofn.lpstrFilter = "Statsfile (*.stats)\0*.stats\0All files (*.*)\0*.*\0\0";
+                ofn.lpstrFile = tmp;
+                ofn.nMaxFile = MAX_PATH;
+                ofn.Flags = OFN_PATHMUSTEXIST;
+
+                if( config->i_pass == 1 )
+                    ofn.Flags |= OFN_OVERWRITEPROMPT;
+                else ofn.Flags |= OFN_FILEMUSTEXIST;
+
+                if( ( config->i_pass == 1 && GetSaveFileName( &ofn ) ) || 
+                    ( config->i_pass > 1 && GetOpenFileName( &ofn ) ) )
+                    SetDlgItemText( hDlg, IDC_STATSFILE, tmp );
+                }
+                break;
             }
             break;
         case EN_CHANGE :
@@ -382,6 +423,10 @@ BOOL CALLBACK callback_main( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam
                 config->i_2passbitrate = GetDlgItemInt( hDlg, IDC_2PASSBITRATE, FALSE, FALSE );
                 SendDlgItemMessage( hDlg, IDC_2PASSBITRATE_S, TBM_SETPOS, TRUE, config->i_2passbitrate );
                 break;
+            case IDC_STATSFILE :
+                if( GetDlgItemText( hDlg, IDC_STATSFILE, config->stats, MAX_PATH ) == 0 )
+                    lstrcpy( config->stats, ".\\x264.stats" );
+                break;
             }
             break;
         default:
@@ -500,10 +545,8 @@ static void adv_update_dlg( HWND hDlg, CONFIG * config )
 
     EnableWindow( GetDlgItem( hDlg, IDC_P8X8 ), config->b_psub16x16 );
 
-
     memcpy( fourcc, config->fcc, 4 );
     fourcc[4] = '\0';
-
     SetDlgItemText( hDlg, IDC_FOURCC, fourcc );
 }
 
index a4d9574..3aeb127 100644 (file)
@@ -60,6 +60,9 @@
 #define IDC_IPRATIO                     1050
 #define IDC_PBRATIO                     1051
 #define IDC_CURVECOMP                   1052
+#define IDC_UPDATESTATS                 1053
+#define IDC_STATSFILE                   1054
+#define IDC_STATSFILE_BROWSE            1055
 
 // Next default values for new objects
 // 
@@ -67,7 +70,7 @@
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        104
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1053
+#define _APS_NEXT_CONTROL_VALUE         1056
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
index 80af664..b6d07e7 100644 (file)
@@ -64,39 +64,45 @@ BEGIN
     PUSHBUTTON      "Cancel",IDCANCEL,168,210,50,14
     CONTROL         "Slider1",IDC_BITRATESLIDER,"msctls_trackbar32",TBS_BOTH | 
                     TBS_NOTICKS | WS_TABSTOP,13,31,175,15
-    EDITTEXT        IDC_BITRATEEDIT,189,32,27,14,ES_AUTOHSCROLL | ES_NUMBER
+    EDITTEXT        IDC_BITRATEEDIT,189,32,26,14,ES_AUTOHSCROLL | ES_NUMBER
     LTEXT           "Average Bitrate (kbps)",IDC_STATIC,59,20,73,8
     GROUPBOX        "",IDC_STATIC,7,7,211,47
-    LTEXT           "0",IDC_BITRATELOW,14,19,22,8
-    LTEXT           "5000",IDC_BITRATEHIGH,166,21,17,8
+    LTEXT           "0",IDC_BITRATELOW,16,20,22,8
+    LTEXT           "5000",IDC_BITRATEHIGH,166,20,17,8
     PUSHBUTTON      "Load Defaults",IDC_DEFAULTS,7,210,57,14
     PUSHBUTTON      "Advanced",IDC_ADVANCED,67,210,49,14
     CONTROL         "Slider1",IDC_QUANTSLIDER,"msctls_trackbar32",TBS_BOTH | 
                     TBS_NOTICKS | WS_TABSTOP,13,81,175,15
-    EDITTEXT        IDC_QUANTEDIT,189,82,27,14,ES_AUTOHSCROLL | ES_NUMBER
-    LTEXT           "Quantizer",IDC_STATIC,81,71,31,8
+    EDITTEXT        IDC_QUANTEDIT,189,82,26,14,ES_AUTOHSCROLL | ES_NUMBER
+    LTEXT           "Quantizer",IDC_STATIC,83,71,31,8
     GROUPBOX        "",IDC_STATIC,7,57,211,47
-    LTEXT           "0 (High Quality)",IDC_BITRATELOW2,14,70,50,8
+    LTEXT           "0 (High Quality)",IDC_BITRATELOW2,16,71,50,8
     LTEXT           "51 (Low Quality)",IDC_BITRATEHIGH2,131,71,53,8
-    GROUPBOX        "",IDC_STATIC,7,109,211,73
-    CONTROL         "1 Pass, Bitrate",IDC_RADIOBITRATE,"Button",
-                    BS_AUTORADIOBUTTON,13,7,58,10
-    CONTROL         "1 Pass, Quantizer",IDC_RADIOQUANT,"Button",
-                    BS_AUTORADIOBUTTON,13,57,75,10
+    GROUPBOX        "",IDC_STATIC,7,108,211,95
+    CONTROL         "Single Pass - Bitrate",IDC_RADIOBITRATE,"Button",
+                    BS_AUTORADIOBUTTON,13,7,77,10
+    CONTROL         "Single Pass - Quantizer",IDC_RADIOQUANT,"Button",
+                    BS_AUTORADIOBUTTON,13,57,87,10
     CONTROL         "Two Pass",IDC_RADIOTWOPASS,"Button",BS_AUTORADIOBUTTON,
-                    13,109,43,10
+                    13,108,45,10
     CONTROL         "First Pass",IDC_2PASS1,"Button",BS_AUTORADIOBUTTON | 
-                    WS_GROUP,27,126,46,10
+                    WS_GROUP,27,123,46,10
     CONTROL         "Second Pass",IDC_2PASS2,"Button",BS_AUTORADIOBUTTON,87,
-                    126,58,10
+                    123,58,10
     CONTROL         "Slider1",IDC_2PASSBITRATE_S,"msctls_trackbar32",
                     TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,13,148,175,15
-    EDITTEXT        IDC_2PASSBITRATE,189,148,27,14,ES_AUTOHSCROLL | 
+    EDITTEXT        IDC_2PASSBITRATE,189,148,26,14,ES_AUTOHSCROLL | 
                     ES_NUMBER
-    LTEXT           "0",IDC_BITRATELOW3,14,136,22,8
-    LTEXT           "5000",IDC_BITRATEHIGH3,166,136,17,8
+    LTEXT           "Target Bitrate (kbps)",IDC_STATIC,63,137,73,8
+    LTEXT           "0",IDC_BITRATELOW3,16,137,22,8
+    LTEXT           "5000",IDC_BITRATEHIGH3,166,137,17,8
     CONTROL         "Fast first pass",IDC_FAST1PASS,"Button",BS_AUTOCHECKBOX |
-                    WS_TABSTOP,20,166,61,10
+                    WS_TABSTOP,20,167,61,10
+    CONTROL         "Update statsfile",IDC_UPDATESTATS,"Button",
+                    BS_AUTOCHECKBOX | WS_TABSTOP,112,167,80,10
+    LTEXT           "Statsfile name:",IDC_STATIC,20,185,52,8
+    EDITTEXT        IDC_STATSFILE,72,184,100,13,ES_AUTOHSCROLL | WS_TABSTOP
+    PUSHBUTTON      "...",IDC_STATSFILE_BROWSE,177,185,18,11
 END
 
 IDD_ADVANCED DIALOG DISCARDABLE  0, 0, 302, 262
index 8ff823f..0505441 100644 (file)
@@ -44,6 +44,7 @@ typedef struct
     int i_pass;
 
     int b_fast1pass;    /* turns off some flags during 1st pass */    
+    int b_updatestats;  /* updates the statsfile during 2nd pass */
 
     /* Our config */
     int i_refmax;