]> granicus.if.org Git - libx264/commitdiff
VfW: x264_log now creates a window for error messages
authorLoren Merritt <pengvado@videolan.org>
Fri, 11 Feb 2005 19:04:44 +0000 (19:04 +0000)
committerLoren Merritt <pengvado@videolan.org>
Fri, 11 Feb 2005 19:04:44 +0000 (19:04 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@121 df754926-b1dd-0310-bc7b-ec298dee348c

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

index c60063af9f9b8e16a10746279d96aea4e0f990f0..281281c51a35c1b199cc72dd3a33964f663543b9 100644 (file)
@@ -131,6 +131,32 @@ LRESULT compress_frames_info(CODEC * codec, ICCOMPRESSFRAMES * icf )
     return ICERR_OK;
 }
 
+static void x264_log_vfw( void *p_private, int i_level, const char *psz_fmt, va_list arg )
+{ 
+    char error_msg[1024];
+    int idx;
+    HWND *hCons = p_private;
+
+    vsprintf( error_msg, psz_fmt, arg );
+    
+    /* strip final linefeeds (required) */
+    idx=strlen( error_msg ) - 1;
+    while( idx >= 0 && error_msg[idx] == '\n' )
+        error_msg[idx--] = 0;
+
+    if(!( *hCons ) ) {
+        *hCons = CreateDialog( g_hInst, MAKEINTRESOURCE( IDD_ERRCONSOLE ), NULL, 
+                 callback_err_console );
+        //ShowWindow( *hCons, SW_SHOW );
+    }
+    idx = SendDlgItemMessage( *hCons, IDC_CONSOLE, LB_ADDSTRING, 0, ( LPARAM )error_msg );
+    
+    /* make sure that the last item added is visible (autoscroll) */
+    if( idx >= 0 ) 
+        SendDlgItemMessage( *hCons, IDC_CONSOLE, LB_SETTOPINDEX, ( WPARAM )idx, 0 );
+
+}
+
 static void statsfilename_renumber( char *dest, char *src, int i_pass )
 {
     char *last_dot = strrchr( src, '.' );
@@ -169,8 +195,13 @@ LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiO
 
     param.rc.psz_stat_out = malloc (MAX_PATH);
     param.rc.psz_stat_in = malloc (MAX_PATH);
+  
+    param.i_log_level = X264_LOG_ERROR;
+    param.pf_log = x264_log_vfw;
+    param.p_log_private = malloc( sizeof( HWND ) );
+    *( ( HWND * )param.p_log_private ) = NULL; /* error console window handle */
+    codec->hCons = ( HWND * )param.p_log_private;
 
-    param.i_log_level = X264_LOG_NONE;
     param.analyse.b_psnr = 0;
     param.analyse.inter = 0;
     param.analyse.intra = X264_ANALYSE_I4x4;
@@ -294,6 +325,7 @@ LRESULT compress_end(CODEC * codec)
         codec->h = NULL;
     }
 
+    free( codec->hCons );
     return ICERR_OK;
 }
 
index 2e098589e3463fd0e89bce4efe7bb40f6f6fbe29..cb28b102ff83177e11e7bc47947cb78f137b44d4 100644 (file)
@@ -685,3 +685,75 @@ BOOL CALLBACK callback_advanced( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
     return 1;
 }
 
+/* error console dialog process */
+BOOL CALLBACK callback_err_console( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
+{
+    switch( uMsg )
+    {
+    case WM_INITDIALOG :
+        break;
+    case WM_DESTROY : 
+        break;
+    case WM_COMMAND :
+        if( HIWORD( wParam ) == BN_CLICKED ) {
+            switch( LOWORD( wParam ) ) {
+            case IDOK :
+                DestroyWindow( hWnd );
+                break;
+            case IDC_COPYCLIP :
+                if( OpenClipboard( hWnd ) )
+                    {
+                        int i;
+                        int num_lines = SendDlgItemMessage( hWnd, IDC_CONSOLE, 
+                                        LB_GETCOUNT, 0, 0 );
+                        int text_size;
+                        char *buffer;
+                        HGLOBAL clipbuffer;
+
+                        if( num_lines <= 0 )
+                            break;
+
+                        /* calculate text size */
+                        for( i = 0, text_size = 0; i < num_lines; i++ )
+                            text_size += SendDlgItemMessage( hWnd, IDC_CONSOLE, 
+                                   LB_GETTEXTLEN, ( WPARAM )i, 0 );
+
+                        /* CR-LF for each line + terminating NULL */
+                        text_size += 2 * num_lines + 1;
+                        
+                        EmptyClipboard( );
+                        clipbuffer = GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE,
+                                     text_size );
+                        buffer = (char *)GlobalLock( clipbuffer );
+
+                        /* concatenate lines of text in the global buffer */
+                        for( i = 0; i < num_lines; i++ )
+                        {                            
+                            char msg_buf[1024];
+                            
+                            SendDlgItemMessage( hWnd, IDC_CONSOLE, LB_GETTEXT,
+                                              ( WPARAM )i, ( LPARAM )msg_buf );
+                            strcat( msg_buf, "\r\n" );
+                            memcpy( buffer, msg_buf, strlen( msg_buf ) );
+                            buffer += strlen( msg_buf );
+                        }
+                        *buffer = 0; /* null-terminate the buffer */
+
+                        GlobalUnlock( clipbuffer );
+                        SetClipboardData( CF_TEXT, clipbuffer );
+                        CloseClipboard( );
+                    }
+                break;
+            default :
+                return 0;
+            }
+            break;
+        }
+        break;
+
+    default :
+        return DefWindowProc( hWnd, uMsg, wParam, lParam );
+    }
+
+    return 0;
+}
index 3aeb12740b8d03d4c2781af7678b8281dbf079f2..eece9a38f20aa2fc5a44459c7d2e4845210f464e 100644 (file)
@@ -6,6 +6,7 @@
 #define IDD_MAINCONFIG                  101
 #define IDD_ADVANCED                    102
 #define IDD_ABOUT                       103
+#define IDD_ERRCONSOLE                  104
 #define IDC_BITRATESLIDER               1002
 #define IDC_BITRATEEDIT                 1003
 #define IDC_BITRATESLIDER2              1004
 #define IDC_UPDATESTATS                 1053
 #define IDC_STATSFILE                   1054
 #define IDC_STATSFILE_BROWSE            1055
+#define IDC_CONSOLE                     1056
+#define IDC_COPYCLIP                    1057
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        104
+#define _APS_NEXT_RESOURCE_VALUE        105
 #define _APS_NEXT_COMMAND_VALUE         40001
-#define _APS_NEXT_CONTROL_VALUE         1056
+#define _APS_NEXT_CONTROL_VALUE         1058
 #define _APS_NEXT_SYMED_VALUE           101
 #endif
 #endif
index b50ed0bdcc1e7350922c15e5d1e1ce2d4b080854..696bebb962fbfcaf81153ea99fcf084d937ac356 100644 (file)
@@ -173,6 +173,15 @@ BEGIN
     LTEXT           "x264 - H.264/MPEG-4 AVC codec",IDC_X264,53,8,145,8,SS_CENTERIMAGE
 END
 
+IDD_ERRCONSOLE DIALOG DISCARDABLE  0, 0, 264, 130
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_VISIBLE
+CAPTION "x264 error console"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,68,110,48,14,WS_TABSTOP
+    DEFPUSHBUTTON   "Copy",IDC_COPYCLIP,148,110,48,14,WS_TABSTOP
+    LISTBOX         IDC_CONSOLE,6,8,251,95,LBS_NOSEL | LBS_NOINTEGRALHEIGHT
+END
 
 /////////////////////////////////////////////////////////////////////////////
 //
index 0505441e14bdfc39f699695bf9fd86efe6532b0b..bfbb5894a95334efe82a10996d8eb5558b099b2a 100644 (file)
@@ -88,6 +88,9 @@ typedef struct
     /* handle */
     x264_t *h;
 
+    /* error console handle */
+    HWND *hCons;
+
     /* XXX: needed ? */
     unsigned int fincr;
     unsigned int fbase;
@@ -112,6 +115,7 @@ void config_reg_save( CONFIG * config );
 BOOL CALLBACK callback_about( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
 BOOL CALLBACK callback_main ( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
 BOOL CALLBACK callback_advanced( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
+BOOL CALLBACK callback_err_console( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
 
 /* Dll instance */
 extern HINSTANCE g_hInst;