summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjbrjake <[email protected]>2009-03-31 17:19:37 +0000
committerjbrjake <[email protected]>2009-03-31 17:19:37 +0000
commita9b9604524e9348f61dc1cd5f299d9b1703e41cc (patch)
treec73b1564ac1659d47cd369572e88cb704c16a6d8 /libhb
parent276345b4d92a23bd125215f07786fee9449ce3cf (diff)
Adds a job->frame_to_stop variable similar to the existing pts_to_stop parameter, for ending an encode after a certain number of decoded frames.
CLI: Replaces --stop-at-pts and --stop-at-duration with a general --stop-at option. The argument is in the form unit:amount. So --stop-at duration:10 for a 10 second encode, --stop-at pts:300300 to end when that timestamp is reached, or --stop-at frame:1000 to stop after reading 1000 frames. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2286 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/common.h1
-rw-r--r--libhb/sync.c22
2 files changed, 23 insertions, 0 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 1121ae8ec..19b8d2217 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -231,6 +231,7 @@ struct hb_job_s
int subtitle_force;
char * native_language;
+ int frame_to_stop; // declare eof when we hit this frame
int64_t pts_to_stop; // declare eof when we pass this pts in
// the time-linearized input stream
int start_at_preview; // if non-zero, encoding will start
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.