From effb3f376005040ebff1c167d3be2c50f9c1d7a7 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sat, 15 Jan 2011 21:15:47 +0000 Subject: fix problem with large ssa subtitle batches stalling the pipeline. ssa subtitles can come in a large batch. since each subtitle gets it's own buffer, a large batch of them was filling the fifo and causing a stall. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3748 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/work.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libhb') diff --git a/libhb/work.c b/libhb/work.c index 5944286b4..53ab3fe9b 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -23,6 +23,8 @@ static void work_func(); static void do_job( hb_job_t *, int cpu_count ); static void work_loop( void * ); +#define FIFO_UNBOUNDED 65536 +#define FIFO_UNBOUNDED_WAKE 65535 #define FIFO_LARGE 32 #define FIFO_LARGE_WAKE 16 #define FIFO_SMALL 16 @@ -767,7 +769,15 @@ static void do_job( hb_job_t * job, int cpu_count ) if( subtitle ) { subtitle->fifo_in = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE ); - subtitle->fifo_raw = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE ); + // Must set capacity of the raw-FIFO to be set >= the maximum number of subtitle + // lines that could be decoded prior to a video frame in order to prevent the following + // deadlock condition: + // 1. Subtitle decoder blocks trying to generate more subtitle lines than will fit in the FIFO. + // 2. Blocks the processing of further subtitle packets read from the input stream. + // 3. And that blocks the processing of any further video packets read from the input stream. + // 4. And that blocks the sync work-object from running, which is needed to consume the subtitle lines in the raw-FIFO. + // Since that number is unbounded, the FIFO must be made (effectively) unbounded in capacity. + subtitle->fifo_raw = hb_fifo_init( FIFO_UNBOUNDED, FIFO_UNBOUNDED_WAKE ); subtitle->fifo_sync = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE ); subtitle->fifo_out = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE ); -- cgit v1.2.3