Index: libhb/render.c =================================================================== --- libhb/render.c (revision 1047) +++ libhb/render.c (working copy) @@ -19,6 +19,7 @@ AVPicture pic_tmp_out; hb_buffer_t * buf_scale; hb_fifo_t * subtitle_queue; + hb_fifo_t * delay_queue; }; int renderInit( hb_work_object_t *, hb_job_t * ); @@ -292,6 +293,24 @@ hb_buffer_copy_settings( buf_render, buf_tmp_in ); } + /* + * At this point we may or may not have a buffer in *buf_out to push + * upstream. If we do put it on our delay queue. + * + * When the delay queue reaches our current maximum we pop the last one + * off the end and put that in *buf_out + */ + if( *buf_out ) + { + hb_fifo_push( pv->delay_queue, *buf_out ); + *buf_out = NULL; + } + + if( hb_fifo_size( pv->delay_queue ) >= 3 ) + { + *buf_out = hb_fifo_get( pv->delay_queue ); + } + return HB_WORK_OK; } @@ -304,7 +323,12 @@ { hb_fifo_close( &pv->subtitle_queue ); } - + + if( pv->delay_queue ) + { + hb_fifo_close( &pv->delay_queue ); + } + /* Cleanup filters */ /* TODO: Move to work.c? */ if( pv->job->filters ) @@ -351,7 +375,8 @@ } /* Setup FIFO queue for subtitle cache */ - pv->subtitle_queue = hb_fifo_init( 8 ); + pv->subtitle_queue = hb_fifo_init( 8 ); + pv->delay_queue = hb_fifo_init( 8 ); /* Setup filters */ /* TODO: Move to work.c? */