OSDN Git Service

jbrjake's loose pixel ratio patch.
[handbrake-jp/handbrake-jp-git.git] / libhb / common.c
index d0b0155..39e6140 100644 (file)
@@ -36,6 +36,8 @@ int hb_audio_bitrates_count = sizeof( hb_audio_bitrates ) /
                               sizeof( hb_rate_t );
 int hb_audio_bitrates_default = 8; /* 128 kbps */
 
+static hb_error_handler_t *error_handler = NULL;
+
 hb_mixdown_t hb_audio_mixdowns[] =
 { { "Mono",               "HB_AMIXDOWN_MONO",      "mono",   HB_AMIXDOWN_MONO      },
   { "Stereo",             "HB_AMIXDOWN_STEREO",    "stereo", HB_AMIXDOWN_STEREO    },
@@ -175,6 +177,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
        case HB_MUX_MP4:
        case HB_MUX_PSP:
                case HB_MUX_IPOD:
+               case HB_MUX_MKV:
             overhead = 6;
             break; 
         case HB_MUX_AVI:
@@ -489,7 +492,7 @@ void hb_list_close( hb_list_t ** _l )
  * hb_log
  **********************************************************************
  * If verbose mode is one, print message with timestamp. Messages
- * longer than 80 characters are stripped ;p
+ * longer than 180 characters are stripped ;p
  *********************************************************************/
 void hb_log( char * log, ... )
 {
@@ -523,6 +526,37 @@ void hb_log( char * log, ... )
 }
 
 /**********************************************************************
+ * hb_error
+ **********************************************************************
+ * Using whatever output is available display this error. 
+ *********************************************************************/
+void hb_error( char * log, ... )
+{
+    char        string[181]; /* 180 chars + \0 */
+    va_list     args;
+
+    /* Convert the message to a string */
+    va_start( args, log );
+    vsnprintf( string, 180, log, args );
+    va_end( args );
+
+    /*
+     * Got the error in a single string, send it off to be dispatched.
+     */
+    if( error_handler )
+    {
+        error_handler( string );
+    } else {
+        hb_log( string );
+    }
+}
+
+void hb_register_error_handler( hb_error_handler_t * handler )
+{
+    error_handler = handler;
+}
+
+/**********************************************************************
  * hb_title_init
  **********************************************************************
  *