OSDN Git Service

Change subtitle position to prevent displaying within a 2% margin of the height of...
[handbrake-jp/handbrake-jp-git.git] / libhb / muxmkv.c
index cb69efa..856554c 100644 (file)
@@ -53,6 +53,14 @@ static int MKVInit( hb_mux_object_t * m )
 
     m->file = mk_createWriter(job->file, 1000000, 1);
 
+    if( !m->file )
+    {
+        hb_error( "Could not create output file, Disk Full?" );
+        job->mux_data = NULL;
+        *job->die = 1;
+        return 0;
+    }
+
     /* Video track */
     mux_data      = calloc(1, sizeof( hb_mux_data_t ) );
     job->mux_data = mux_data;
@@ -104,16 +112,16 @@ static int MKVInit( hb_mux_object_t * m )
             return 0;
     }
 
-    track->video.pixelWidth = job->width;
-    track->video.pixelHeight = job->height;
-    track->video.displayHeight = job->height;
+    track->extra.video.pixelWidth = job->width;
+    track->extra.video.pixelHeight = job->height;
+    track->extra.video.displayHeight = job->height;
     if(job->pixel_ratio)
     {
-        track->video.displayWidth = job->width * ((double)job->pixel_aspect_width / (double)job->pixel_aspect_height);
+        track->extra.video.displayWidth = job->width * ((double)job->pixel_aspect_width / (double)job->pixel_aspect_height);
     }
     else
     {
-        track->video.displayWidth = job->width;
+        track->extra.video.displayWidth = job->width;
     }
 
 
@@ -183,8 +191,8 @@ static int MKVInit( hb_mux_object_t * m )
         track->flagEnabled = 1;
         track->trackType = MK_TRACK_AUDIO;
         track->language = audio->iso639_2;
-        track->audio.samplingFreq = (float)job->arate;
-        track->audio.channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->amixdown);
+        track->extra.audio.samplingFreq = (float)job->arate;
+        track->extra.audio.channels = (job->acodec == HB_ACODEC_AC3) ? HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(audio->input_channel_layout) : HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(audio->amixdown);
 //        track->defaultDuration = job->arate * 1000;
         mux_data->track = mk_createTrack(m->file, track);
         if (job->acodec == HB_ACODEC_VORBIS && track->codecPrivate != NULL)
@@ -216,9 +224,9 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
     if (mux_data == job->mux_data)
     {
         /* Video */
-        if ((job->vcodec == HB_VCODEC_X264) && (buf->frametype & HB_FRAME_REF))
+        if ((job->vcodec == HB_VCODEC_X264) && (job->areBframes))
         {
-            timecode = (buf->start + (buf->renderOffset - 1000000)) * TIMECODE_SCALE;
+            timecode = (buf->start + (buf->renderOffset)) * TIMECODE_SCALE;
         }
         else
         {
@@ -268,7 +276,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
 
     if( mk_startFrame(m->file, mux_data->track) < 0)
     {
-        hb_error( "Failed to write start frame to output file, Disk Full?" );
+        hb_error( "Failed to write frame to output file, Disk Full?" );
         *job->die = 1;
     }
     mk_addFrameData(m->file, mux_data->track, buf->data, buf->size);
@@ -282,10 +290,20 @@ static int MKVEnd( hb_mux_object_t * m )
     hb_job_t  *job = m->job;
     hb_mux_data_t *mux_data = job->mux_data;
     hb_title_t  *title = job->title;
-    hb_chapter_t *chapter_data = hb_list_item( title->list_chapter, mux_data->current_chapter++ );
+    hb_chapter_t *chapter_data;
     char tmp_buffer[1024];
     char *string = tmp_buffer;
 
+    if( !job->mux_data )
+    {
+        /*
+         * We must have failed to create the file in the first place.
+         */
+        return 0;
+    }
+
+    chapter_data = hb_list_item( title->list_chapter, mux_data->current_chapter++ );
+
     if(job->chapter_markers)
     {
         tmp_buffer[0] = '\0';