+ sub = hb_fifo_get( subtitle->fifo_raw );
+ hb_buffer_close( &sub );
+ }
+ }
+
+ /* If we have a subtitle for this picture, copy it */
+ /* FIXME: we should avoid this memcpy */
+ if( sub )
+ {
+ if( sub->size > 0 )
+ {
+ if( subtitle->config.dest == RENDERSUB )
+ {
+ if ( cur->sub == NULL )
+ {
+ /*
+ * Tack onto the video buffer for rendering
+ */
+ cur->sub = hb_buffer_init( sub->size );
+ cur->sub->x = sub->x;
+ cur->sub->y = sub->y;
+ cur->sub->width = sub->width;
+ cur->sub->height = sub->height;
+ memcpy( cur->sub->data, sub->data, sub->size );
+ }
+ } else {
+ /*
+ * Pass-Through, pop it off of the raw queue,
+ * rewrite times and make it available to be
+ * reencoded.
+ */
+ uint64_t sub_duration;
+ sub = hb_fifo_get( subtitle->fifo_raw );
+ sub_duration = sub->stop - sub->start;
+ sub->start = cur->start;
+ buf_tmp = hb_fifo_see( job->fifo_raw );
+ int64_t duration = buf_tmp->start - cur->start;
+ sub->stop = sub->start + duration;
+ hb_fifo_push( subtitle->fifo_sync, sub );
+ }
+ } else {
+ /*
+ * EOF - consume for rendered, else pass through
+ */
+ if( subtitle->config.dest == RENDERSUB )
+ {
+ sub = hb_fifo_get( subtitle->fifo_raw );
+ hb_buffer_close( &sub );
+ } else {
+ sub = hb_fifo_get( subtitle->fifo_raw );
+ hb_fifo_push( subtitle->fifo_out, sub );
+ }