// an eof buf. syncWork returns done when all
// bits are clear.
/* Video */
- hb_subtitle_t * subtitle;
int64_t pts_offset;
int64_t next_start; /* start time of next output frame */
int64_t next_pts; /* start time of next input frame */
/* Initialize libsamplerate for every audio track we have */
if ( ! job->indepth_scan )
{
- for( i = 0; i < hb_list_count( title->list_audio ); i++ )
+ for( i = 0; i < hb_list_count( title->list_audio ) && i < 8; i++ )
{
pv->busy |= ( 1 << (i + 1) );
InitAudio( w, i );
}
}
- /* Get subtitle info, if any */
- pv->subtitle = hb_list_item( title->list_subtitle, 0 );
-
return 0;
}
hb_work_private_t * pv = w->private_data;
hb_buffer_t * cur, * next, * sub = NULL;
hb_job_t * job = pv->job;
+ hb_subtitle_t *subtitle;
+ int i;
if( !pv->cur && !( pv->cur = hb_fifo_get( job->fifo_raw ) ) )
{
*/
pv->video_sequence = cur->sequence;
- /* Look for a subtitle for this frame */
- if( pv->subtitle )
+ /*
+ * Look for a subtitle for this frame.
+ *
+ * If found then it will be tagged onto a video buffer of the correct time and
+ * sent in to the render pipeline. This only needs to be done for VOBSUBs which
+ * get rendered, other types of subtitles can just sit in their raw_queue until
+ * delt with at muxing.
+ */
+ for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
{
- hb_buffer_t * sub2;
- while( ( sub = hb_fifo_see( pv->subtitle->fifo_raw ) ) )
+ subtitle = hb_list_item( job->list_subtitle, i );
+ if( subtitle->dest == RENDERSUB )
{
- /* If two subtitles overlap, make the first one stop
- when the second one starts */
- sub2 = hb_fifo_see2( pv->subtitle->fifo_raw );
- if( sub2 && sub->stop > sub2->start )
- sub->stop = sub2->start;
-
- // hb_log("0x%x: video seq: %lld subtitle sequence: %lld",
- // sub, cur->sequence, sub->sequence);
-
- if( sub->sequence > cur->sequence )
+ hb_buffer_t * sub2;
+ while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) )
{
+ /* If two subtitles overlap, make the first one stop
+ when the second one starts */
+ sub2 = hb_fifo_see2( subtitle->fifo_raw );
+ if( sub2 && sub->stop > sub2->start )
+ sub->stop = sub2->start;
+
+ // hb_log("0x%x: video seq: %lld subtitle sequence: %lld",
+ // sub, cur->sequence, sub->sequence);
+
+ if( sub->sequence > cur->sequence )
+ {
+ /*
+ * The video is behind where we are, so wait until
+ * it catches up to the same reader point on the
+ * DVD. Then our PTS should be in the same region
+ * as the video.
+ */
+ sub = NULL;
+ break;
+ }
+
+ if( sub->stop > cur->start ) {
+ /*
+ * The stop time is in the future, so fall through
+ * and we'll deal with it in the next block of
+ * code.
+ */
+ break;
+ }
+
/*
- * The video is behind where we are, so wait until
- * it catches up to the same reader point on the
- * DVD. Then our PTS should be in the same region
- * as the video.
- */
- sub = NULL;
- break;
- }
-
- if( sub->stop > cur->start ) {
- /*
- * The stop time is in the future, so fall through
- * and we'll deal with it in the next block of
- * code.
+ * The subtitle is older than this picture, trash it
*/
- break;
+ sub = hb_fifo_get( subtitle->fifo_raw );
+ hb_buffer_close( &sub );
}
-
+
/*
- * The subtitle is older than this picture, trash it
+ * There is a valid subtitle, is it time to display it?
*/
- sub = hb_fifo_get( pv->subtitle->fifo_raw );
- hb_buffer_close( &sub );
- }
-
- /*
- * There is a valid subtitle, is it time to display it?
- */
- if( sub )
- {
- if( sub->stop > sub->start)
+ if( sub )
{
- /*
- * Normal subtitle which ends after it starts, check to
- * see that the current video is between the start and end.
- */
- if( cur->start > sub->start &&
- cur->start < sub->stop )
+ if( sub->stop > sub->start)
{
/*
- * We should be playing this, so leave the
- * subtitle in place.
- *
- * fall through to display
+ * Normal subtitle which ends after it starts, check to
+ * see that the current video is between the start and end.
*/
- if( ( sub->stop - sub->start ) < ( 3 * 90000 ) )
+ if( cur->start > sub->start &&
+ cur->start < sub->stop )
{
/*
- * Subtitle is on for less than three seconds, extend
- * the time that it is displayed to make it easier
- * to read. Make it 3 seconds or until the next
- * subtitle is displayed.
+ * We should be playing this, so leave the
+ * subtitle in place.
*
- * This is in response to Indochine which only
- * displays subs for 1 second - too fast to read.
+ * fall through to display
*/
- sub->stop = sub->start + ( 3 * 90000 );
-
- sub2 = hb_fifo_see2( pv->subtitle->fifo_raw );
-
- if( sub2 && sub->stop > sub2->start )
+ if( ( sub->stop - sub->start ) < ( 3 * 90000 ) )
{
- sub->stop = sub2->start;
+ /*
+ * Subtitle is on for less than three seconds, extend
+ * the time that it is displayed to make it easier
+ * to read. Make it 3 seconds or until the next
+ * subtitle is displayed.
+ *
+ * This is in response to Indochine which only
+ * displays subs for 1 second - too fast to read.
+ */
+ sub->stop = sub->start + ( 3 * 90000 );
+
+ sub2 = hb_fifo_see2( subtitle->fifo_raw );
+
+ if( sub2 && sub->stop > sub2->start )
+ {
+ sub->stop = sub2->start;
+ }
}
}
+ else
+ {
+ /*
+ * Defer until the play point is within the subtitle
+ */
+ sub = NULL;
+ }
}
else
{
/*
- * Defer until the play point is within the subtitle
- */
- sub = NULL;
- }
- }
- else
- {
- /*
- * The end of the subtitle is less than the start, this is a
- * sign of a PTS discontinuity.
- */
- if( sub->start > cur->start )
- {
- /*
- * we haven't reached the start time yet, or
- * we have jumped backwards after having
- * already started this subtitle.
+ * The end of the subtitle is less than the start, this is a
+ * sign of a PTS discontinuity.
*/
- if( cur->start < sub->stop )
+ if( sub->start > cur->start )
{
/*
- * We have jumped backwards and so should
- * continue displaying this subtitle.
- *
- * fall through to display.
+ * we haven't reached the start time yet, or
+ * we have jumped backwards after having
+ * already started this subtitle.
*/
- }
- else
- {
+ if( cur->start < sub->stop )
+ {
+ /*
+ * We have jumped backwards and so should
+ * continue displaying this subtitle.
+ *
+ * fall through to display.
+ */
+ }
+ else
+ {
+ /*
+ * Defer until the play point is within the subtitle
+ */
+ sub = NULL;
+ }
+ } else {
/*
- * Defer until the play point is within the subtitle
+ * Play this subtitle as the start is greater than our
+ * video point.
+ *
+ * fall through to display/
*/
- sub = NULL;
}
- } else {
- /*
- * Play this subtitle as the start is greater than our
- * video point.
- *
- * fall through to display/
- */
}
}
}
- }
+ if( sub )
+ {
+ /*
+ * Don't overwrite the current sub, we'll check the
+ * other subtitle streams on the next video buffer.
+ *
+ * It doesn't make much sense having multiple rendered
+ * subtitle tracks anyway.
+ */
+ break;
+ }
+ } // end subtitles
/*
* Adjust the pts of the current frame so that it's contiguous
job->subtitle_force = 0;
/*
- * subtitle of -1 is a scan
+ * If scanning we need to do some extra setup of the job.
*/
- if( job->subtitle == -1 )
+ if( job->indepth_scan == 1 )
{
char *x264opts_tmp;
*/
job->pass = -1;
x264opts_tmp = job->x264opts;
- job->subtitle = -1;
job->x264opts = NULL;
else
job->select_subtitle = NULL;
- /* No subtitle were selected, so reset the subtitle to -1 (which before
- * this point meant we were scanning
- */
- if( job->subtitle == -2 )
- job->subtitle = -1;
-
if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 )
{
hb_subtitle_t **subtitle_tmp = job->select_subtitle;
}
/* Subtitle settings */
- job->subtitle = [fSubPopUp indexOfSelectedItem] - 2;
+ switch( [fSubPopUp indexOfSelectedItem] - 2 )
+ {
+ case -2:
+ /*
+ * No subtitles selected
+ */
+ break;
+ case -1:
+ /*
+ * Subtitle scan selected
+ */
+ job->indepth_scan = 1;
+ break;
+ default:
+ /*
+ * Subtitle selected, add it into the job from the title.
+ */
+ job->indepth_scan = 0;
+ hb_subtitle_t *subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, [fSubPopUp indexOfSelectedItem] - 2 );
+ hb_list_add( job->list_subtitle, subtitle );
+ break;
+ }
/* Audio tracks and mixdowns */
/* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
job->grayscale = [[queueToApply objectForKey:@"VideoGrayScale"] intValue];
/* Subtitle settings */
- job->subtitle = [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2;
+ switch( [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2 )
+ {
+ case -2:
+ /*
+ * No subtitles selected
+ */
+ break;
+ case -1:
+ /*
+ * Subtitle scan selected
+ */
+ job->indepth_scan = 1;
+ break;
+ default:
+ /*
+ * Subtitle selected, add it into the job from the title.
+ */
+ job->indepth_scan = 0;
+ hb_subtitle_t *subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle,
+ [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2 );
+ hb_list_add( job->list_subtitle, subtitle );
+ break;
+ }
+
/* Audio tracks and mixdowns */
/* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
int audiotrack_count = hb_list_count(job->list_audio);