diff options
author | jstebbins <[email protected]> | 2008-11-11 16:05:16 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-11-11 16:05:16 +0000 |
commit | 1111f7b15abdea2dea8f242c355fee9e77978ca0 (patch) | |
tree | 73b7b3d2cd04f37bbd8d34c7822d2c50b7b130ac /libhb | |
parent | e5770abbe687333605b529a7e4656e571ce08cf1 (diff) |
libhb support for live preview
set job->start_at_preview to the preview frame you want to start at
set job->pts_to_stop to the number of 90khz ticks duration
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1915 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.h | 8 | ||||
-rw-r--r-- | libhb/reader.c | 69 | ||||
-rw-r--r-- | libhb/sync.c | 17 |
3 files changed, 65 insertions, 29 deletions
diff --git a/libhb/common.h b/libhb/common.h index adf7a2da4..44706afb7 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -222,6 +222,14 @@ struct hb_job_s int subtitle_force; char * native_language; + 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 + // at the position of preview n (1-10) + uint32_t frames_to_skip; // decode but discard this many frames + // initially (for frame accurate positioning + // to non-I frames). + #ifdef __LIBHB__ /* Internal data */ hb_handle_t * h; diff --git a/libhb/reader.c b/libhb/reader.c index c93c2a0cc..9dfd915e4 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -181,30 +181,41 @@ static void ReaderFunc( void * _r ) if (r->dvd) { - /* - * XXX this code is a temporary hack that should go away if/when - * chapter merging goes away in libhb/dvd.c - * map the start and end chapter numbers to on-media chapter - * numbers since chapter merging could cause the handbrake numbers - * to diverge from the media numbers and, if our chapter_end is after - * a media chapter that got merged, we'll stop ripping too early. - */ - int start = r->job->chapter_start; - hb_chapter_t * chap = hb_list_item( r->title->list_chapter, chapter_end - 1 ); - - chapter_end = chap->index; - if (start > 1) - { - chap = hb_list_item( r->title->list_chapter, start - 1 ); - start = chap->index; - } - /* end chapter mapping XXX */ - - if( !hb_dvd_start( r->dvd, r->title->index, start ) ) - { - hb_dvd_close( &r->dvd ); - return; - } + /* + * XXX this code is a temporary hack that should go away if/when + * chapter merging goes away in libhb/dvd.c + * map the start and end chapter numbers to on-media chapter + * numbers since chapter merging could cause the handbrake numbers + * to diverge from the media numbers and, if our chapter_end is after + * a media chapter that got merged, we'll stop ripping too early. + */ + int start = r->job->chapter_start; + hb_chapter_t *chap = hb_list_item( r->title->list_chapter, chapter_end - 1 ); + + chapter_end = chap->index; + if (start > 1) + { + chap = hb_list_item( r->title->list_chapter, start - 1 ); + start = chap->index; + } + /* end chapter mapping XXX */ + + if( !hb_dvd_start( r->dvd, r->title->index, start ) ) + { + hb_dvd_close( &r->dvd ); + return; + } + + if ( r->job->start_at_preview ) + { + // XXX code from DecodePreviews - should go into its own routine + hb_dvd_seek( r->dvd, (float)r->job->start_at_preview / 11. ); + } + } + else if ( r->stream && r->job->start_at_preview ) + { + // XXX code from DecodePreviews - should go into its own routine + hb_stream_seek( r->stream, (float)( r->job->start_at_preview - 1 ) / 11. ); } list = hb_list_init(); @@ -351,7 +362,16 @@ static void ReaderFunc( void * _r ) } } if ( buf->start != -1 ) + { buf->start -= r->scr_offset; + if ( r->job->pts_to_stop && buf->start > r->job->pts_to_stop ) + { + // we're doing a subset of the input and we've hit the + // stopping point. + hb_buffer_close( &buf ); + goto done; + } + } buf->sequence = r->sequence++; /* if there are mutiple output fifos, send a copy of the @@ -374,6 +394,7 @@ static void ReaderFunc( void * _r ) } } + done: // send empty buffers downstream to video & audio decoders to signal we're done. push_buf( r, r->job->fifo_mpeg2, hb_buffer_init(0) ); diff --git a/libhb/sync.c b/libhb/sync.c index 0c359f1dd..03de54c45 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -97,14 +97,21 @@ int syncInit( hb_work_object_t * w, hb_job_t * job ) pv->pts_offset = INT64_MIN; /* Calculate how many video frames we are expecting */ - duration = 0; - for( i = job->chapter_start; i <= job->chapter_end; i++ ) + if (job->pts_to_stop) { - chapter = hb_list_item( title->list_chapter, i - 1 ); - duration += chapter->duration; + duration = job->pts_to_stop + 90000; } - duration += 90000; + else + { + duration = 0; + for( i = job->chapter_start; i <= job->chapter_end; i++ ) + { + chapter = hb_list_item( title->list_chapter, i - 1 ); + duration += chapter->duration; + } + duration += 90000; /* 1 second safety so we're sure we won't miss anything */ + } pv->count_frames_max = duration * job->vrate / job->vrate_base / 90000; hb_log( "sync: expecting %d video frames", pv->count_frames_max ); |