OSDN Git Service

Leave video tracks on the 90KHz MPEG timebase so we don't end up with constantly...
[handbrake-jp/handbrake-jp-git.git] / libhb / common.c
index c8cc8dd..88a8ea8 100644 (file)
@@ -234,6 +234,7 @@ int hb_calc_bitrate( hb_job_t * job, int size )
                 samples_per_frame = 1152;
                 break;
             case HB_ACODEC_AC3:
+            case HB_ACODEC_DCA:
                 samples_per_frame = 1536;
                 break;
             default:
@@ -549,6 +550,44 @@ void hb_log( char * log, ... )
     fprintf( stderr, "%s", string );
 }
 
+int global_verbosity_level; //Necessary for hb_deep_log
+/**********************************************************************
+ * hb_deep_log
+ **********************************************************************
+ * If verbose mode is >= level, print message with timestamp. Messages
+ * longer than 360 characters are stripped ;p
+ *********************************************************************/
+void hb_deep_log( hb_debug_level_t level, char * log, ... )
+{
+    char        string[362]; /* 360 chars + \n + \0 */
+    time_t      _now;
+    struct tm * now;
+    va_list     args;
+
+    if( global_verbosity_level < level )
+    {
+        /* Hiding message */
+        return;
+    }
+
+    /* Get the time */
+    _now = time( NULL );
+    now  = localtime( &_now );
+    sprintf( string, "[%02d:%02d:%02d] ",
+             now->tm_hour, now->tm_min, now->tm_sec );
+
+    /* Convert the message to a string */
+    va_start( args, log );
+    vsnprintf( string + 11, 349, log, args );
+    va_end( args );
+
+    /* Add the end of line */
+    strcat( string, "\n" );
+
+    /* Print it */
+    fprintf( stderr, "%s", string );
+}
+
 /**********************************************************************
  * hb_error
  **********************************************************************
@@ -636,6 +675,15 @@ void hb_title_close( hb_title_t ** _t )
     }
     hb_list_close( &t->list_subtitle );
 
+    if( t->metadata )
+    {
+        if( t->metadata->coverart )
+        {
+            free( t->metadata->coverart );
+        }
+        free( t->metadata );
+    }
+
     free( t );
     *_t = NULL;
 }
@@ -667,8 +715,13 @@ void hb_filter_close( hb_filter_object_t ** _f )
  *********************************************************************/
 hb_audio_t *hb_audio_copy(const hb_audio_t *src)
 {
-    hb_audio_t *audio = calloc(1, sizeof(*audio));
-    memcpy(audio, src, sizeof(*audio));
+    hb_audio_t *audio = NULL;
+
+    if( src )
+    {
+        audio = calloc(1, sizeof(*audio));
+        memcpy(audio, src, sizeof(*audio));
+    }
     return audio;
 }
 
@@ -684,6 +737,8 @@ void hb_audio_config_init(hb_audio_config_t * audiocfg)
     audiocfg->in.bitrate = -1;
     audiocfg->in.samplerate = -1;
     audiocfg->in.channel_layout = 0;
+    audiocfg->in.version = 0;
+    audiocfg->in.mode = 0;
     audiocfg->flags.ac3 = 0;
     audiocfg->lang.description[0] = 0;
     audiocfg->lang.simple[0] = 0;
@@ -696,6 +751,7 @@ void hb_audio_config_init(hb_audio_config_t * audiocfg)
     audiocfg->out.samplerate = 44100;
     audiocfg->out.mixdown = HB_AMIXDOWN_DOLBYPLII;
     audiocfg->out.dynamic_range_compression = 0;
+    audiocfg->out.name = NULL;
 }
 
 /**********************************************************************