From: Loren Merritt Date: Fri, 11 Feb 2005 19:04:44 +0000 (+0000) Subject: VfW: x264_log now creates a window for error messages X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=dc270b76915975ab1ea6e16992aa79e96e6801f7;p=x264.git VfW: x264_log now creates a window for error messages git-svn-id: svn://svn.videolan.org/x264/trunk@121 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/vfw/codec.c b/vfw/codec.c index c60063af..281281c5 100644 --- a/vfw/codec.c +++ b/vfw/codec.c @@ -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; } diff --git a/vfw/config.c b/vfw/config.c index 2e098589..cb28b102 100644 --- a/vfw/config.c +++ b/vfw/config.c @@ -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; +} diff --git a/vfw/resource.h b/vfw/resource.h index 3aeb1274..eece9a38 100644 --- a/vfw/resource.h +++ b/vfw/resource.h @@ -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 @@ -63,14 +64,16 @@ #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 diff --git a/vfw/resource.rc b/vfw/resource.rc index b50ed0bd..696bebb9 100644 --- a/vfw/resource.rc +++ b/vfw/resource.rc @@ -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 ///////////////////////////////////////////////////////////////////////////// // diff --git a/vfw/x264vfw.h b/vfw/x264vfw.h index 0505441e..bfbb5894 100644 --- a/vfw/x264vfw.h +++ b/vfw/x264vfw.h @@ -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;