X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fmuxcommon.c;h=1f39df11d92ab52c14ac5fa398aca98ae72dab46;hb=033e32de9c380f54c7d1362a3979da205ebc3a29;hp=b64ebff857acf642bb43ccb1ca9483e97027a959;hpb=9da25f6c44cde68e69b0d721908593e3d988ec13;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/muxcommon.c b/libhb/muxcommon.c index b64ebff8..1f39df11 100644 --- a/libhb/muxcommon.c +++ b/libhb/muxcommon.c @@ -141,6 +141,12 @@ static hb_buffer_t *mf_pull( hb_track_t *track ) return b; } +static hb_buffer_t *mf_peek( hb_track_t *track ) +{ + return track->mf.out == track->mf.in ? + NULL : track->mf.fifo[track->mf.out & (track->mf.flen - 1)]; +} + static void MoveToInternalFifos( hb_mux_t *mux ) { int i; @@ -188,18 +194,12 @@ static void OutputTrackChunk( hb_mux_t *mux, hb_track_t *track, hb_mux_object_t { hb_buffer_t *buf; - while ( ( buf = mf_pull( track ) ) != NULL ) + while ( ( buf = mf_peek( track ) ) != NULL && buf->start < mux->pts ) { - m->mux( m, track->mux_data, buf ); + m->mux( m, track->mux_data, mf_pull( track ) ); track->frames += 1; track->bytes += buf->size; - - uint64_t pts = buf->stop; hb_buffer_close( &buf ); - if ( pts >= mux->pts ) - { - break; - } } } @@ -258,6 +258,14 @@ static void MuxerFunc( void * _mux ) add_mux_track( mux, audio->priv.fifo_out, audio->priv.mux_data, 1 ); } + for( i = 0; i < hb_list_count( title->list_subtitle ); i++ ) + { + hb_subtitle_t *subtitle = hb_list_item( title->list_subtitle, i ); + + if (subtitle->config.dest != PASSTHRUSUB) + continue; + add_mux_track( mux, subtitle->fifo_out, subtitle->mux_data, 0 ); + } // The following 'while' is the main muxing loop. @@ -265,7 +273,7 @@ static void MuxerFunc( void * _mux ) while( !*job->die ) { MoveToInternalFifos( mux ); - if ( mux->rdy != mux->allRdy ) + if ( ( mux->rdy & mux->allRdy ) != mux->allRdy ) { hb_snooze( thread_sleep_interval ); continue; @@ -273,7 +281,7 @@ static void MuxerFunc( void * _mux ) // all tracks have at least 'interleave' ticks of data. Output // all that we can in 'interleave' size chunks. - while ( mux->rdy == mux->allRdy ) + while ( ( mux->rdy & mux->allRdy ) == mux->allRdy ) { for ( i = 0; i < mux->ntracks; ++i ) { @@ -319,13 +327,12 @@ finished: struct stat sb; uint64_t bytes_total, frames_total; -#define p state.param.muxing /* Update the UI */ hb_state_t state; - state.state = HB_STATE_MUXING; - p.progress = 0; + state.state = HB_STATE_MUXING; + state.param.muxing.progress = 0; hb_set_state( job->h, &state ); -#undef p + if( m ) { m->end( m ); @@ -333,23 +340,22 @@ finished: if( !stat( job->file, &sb ) ) { - hb_deep_log( 2, "mux: file size, %lld bytes", (uint64_t) sb.st_size ); + hb_deep_log( 2, "mux: file size, %"PRId64" bytes", (uint64_t) sb.st_size ); bytes_total = 0; frames_total = 0; for( i = 0; i < mux->ntracks; ++i ) { track = mux->track[i]; - hb_log( "mux: track %d, %lld frames, %lld bytes, %.2f kbps, fifo %d", + hb_log( "mux: track %d, %"PRId64" frames, %"PRId64" bytes, %.2f kbps, fifo %d", i, track->frames, track->bytes, 90000.0 * track->bytes / mux->pts / 125, track->mf.flen ); if( !i && ( job->vquality < 0.0 || job->vquality > 1.0 ) ) { /* Video */ - hb_deep_log( 2, "mux: video bitrate error, %+lld bytes", - track->bytes - mux->pts * job->vbitrate * - 125 / 90000 ); + hb_deep_log( 2, "mux: video bitrate error, %+"PRId64" bytes", + (int64_t)(track->bytes - mux->pts * job->vbitrate * 125 / 90000) ); } bytes_total += track->bytes; frames_total += track->frames;