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();
}
}
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
}
}
+ 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) );
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 );