OSDN Git Service

fix problem with large ssa subtitle batches stalling the pipeline.
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 15 Jan 2011 21:15:47 +0000 (21:15 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 15 Jan 2011 21:15:47 +0000 (21:15 +0000)
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://localhost/HandBrake/trunk@3748 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/work.c

index 5944286..53ab3fe 100644 (file)
@@ -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 );