diff options
Diffstat (limited to 'libhb/sync.c')
-rw-r--r-- | libhb/sync.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libhb/sync.c b/libhb/sync.c index c391945b0..920a0e388 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -100,6 +100,11 @@ int syncInit( hb_work_object_t * w, hb_job_t * job ) { duration = job->pts_to_stop + 90000; } + else if( job->frame_to_stop ) + { + /* Set the duration to a rough estimate */ + duration = ( job->frame_to_stop / ( job->vrate / job->vrate_base ) ) * 90000; + } else { duration = 0; @@ -621,6 +626,17 @@ static void SyncVideo( hb_work_object_t * w ) /* Update UI */ UpdateState( w ); + + if( job->frame_to_stop && pv->count_frames > job->frame_to_stop ) + { + // Drop an empty buffer into our output to ensure that things + // get flushed all the way out. + hb_fifo_push( job->fifo_sync, hb_buffer_init( 0 ) ); + pv->busy &=~ 1; + hb_log( "sync: reached %d frames, exiting early (%i busy)", + pv->count_frames, pv->busy ); + return; + } /* Make sure we won't get more frames then expected */ if( pv->count_frames >= pv->count_frames_max * 2) @@ -734,6 +750,12 @@ static void SyncAudio( hb_work_object_t * w, int i ) pv->busy &=~ (1 << (i + 1) ); return; } + if( job->frame_to_stop && pv->count_frames >= job->frame_to_stop ) + { + hb_fifo_push( fifo, hb_buffer_init(0) ); + pv->busy &=~ (1 << (i + 1) ); + return; + } if ( (int64_t)( buf->start - sync->next_pts ) < 0 ) { // audio time went backwards. |