]> granicus.if.org Git - handbrake/commitdiff
Push an EOF onto the subtitle fifos from the reader for DVD VOBSUBs and also from...
authoreddyg <eddyg.hb@myreflection.org>
Wed, 6 May 2009 02:25:58 +0000 (02:25 +0000)
committereddyg <eddyg.hb@myreflection.org>
Wed, 6 May 2009 02:25:58 +0000 (02:25 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2388 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/deccc608sub.c
libhb/decmpeg2.c
libhb/muxmp4.c
libhb/reader.c
libhb/sync.c

index 2b0b199fac42d91c4496c8d4f3ac07a3f282f6b1..0451b251ef929c922d263db117a495a4d0088bd3 100644 (file)
@@ -2048,10 +2048,18 @@ void handle_command (/*const */ unsigned char c1, const unsigned char c2, struct
 }
 
 void handle_end_of_data (struct s_write *wb)
-{
+{ 
+    hb_buffer_t *buffer;
+
     // We issue a EraseDisplayedMemory here so if there's any captions pending
     // they get written to file. 
     handle_command (0x14, 0x2c, wb); // EDM
+
+    /*
+     * At the end of the subtitle stream HB wants an empty buffer
+     */
+    buffer = hb_buffer_init( 0 );
+    hb_fifo_push( wb->subtitle->fifo_raw, buffer );
 }
 
 void handle_double (const unsigned char c1, const unsigned char c2, struct s_write *wb)
index 9d28c97755ca89026d9c229549c3f77a15e3296b..756eb9768fb4d049cd4017860090482d578d9968 100644 (file)
@@ -658,6 +658,13 @@ static int decmpeg2Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
         hb_list_add( pv->list, *buf_in );
         *buf_in = NULL;
         status = HB_WORK_DONE;
+        /*
+         * Let the Closed Captions know that it is the end of the data.
+         */
+        if( pv->libmpeg2->subtitle )
+        {
+            handle_end_of_data( &pv->libmpeg2->cc608 );
+        }
     }
 
     *buf_out = NULL;
index bdeea8c423c160de794829991ca67bc3226809c7..6795a33ec3add80a17bac96204aad70f94076cc5 100644 (file)
@@ -598,15 +598,25 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
 
             while( ( sub = hb_fifo_see( subtitle->fifo_out )) != NULL )
             {
-                if (sub->start < buf->start ) {
+                if( sub->size == 0 )
+                {
+                    /*
+                     * EOF 
+                     */ 
+                    hb_log("MuxMP4: Text Sub: EOF");
                     sub = hb_fifo_get( subtitle->fifo_out );
-                    hb_log("MuxMP4: Text Sub:%lld: %s", sub->start, sub->data);
                     hb_buffer_close( &sub );
                 } else {
-                    /*
-                     * Not time yet
-                     */
-                    break;
+                    if( sub->start < buf->start ) {
+                        sub = hb_fifo_get( subtitle->fifo_out );
+                        hb_log("MuxMP4: Text Sub:%lld: %s", sub->start, sub->data);
+                        hb_buffer_close( &sub );
+                    } else {
+                        /*
+                         * Not time yet
+                         */
+                        break;
+                    }
                 }
             }
         }
index e0345378f09407d6b8655c26962b0957f2f248d1..f7470bfa2634237efdf04460d878cb4a1fbc4e7f 100644 (file)
@@ -457,6 +457,13 @@ static void ReaderFunc( void * _r )
             push_buf( r, audio->priv.fifo_in, hb_buffer_init(0) );
     }
 
+    hb_subtitle_t *subtitle;
+    for( n = 0; ( subtitle = hb_list_item( r->job->title->list_subtitle, n ) ); ++n )
+    {
+        if ( subtitle->fifo_in )
+            push_buf( r, subtitle->fifo_in, hb_buffer_init(0) );
+    }
+
     hb_list_empty( &list );
     hb_buffer_close( &ps );
     if (r->dvd)
index b102b49f79d15e7bb65f16ee73fc41a278602a63..39be41310cd0e71afb19dd92d0bd1421cc5ec1ab 100644 (file)
@@ -414,7 +414,7 @@ static void SyncVideo( hb_work_object_t * w )
                      * What about discontinuity boundaries - not delt
                      * with here - Van?
                      */
-                    if( sub->start < cur->start )
+                    if( sub->size == 0 || sub->start < cur->start )
                     {
                         sub = hb_fifo_get( subtitle->fifo_raw );
                         sub->start = pv->next_start;
@@ -431,6 +431,14 @@ static void SyncVideo( hb_work_object_t * w )
                 hb_buffer_t * sub2;
                 while( ( sub = hb_fifo_see( subtitle->fifo_raw ) ) )
                 {
+                    if( sub->size == 0 )
+                    {
+                        /*
+                         * EOF, pass it through immediately.
+                         */
+                        break;
+                    }
+
                     /* If two subtitles overlap, make the first one stop
                        when the second one starts */
                     sub2 = hb_fifo_see2( subtitle->fifo_raw );
@@ -468,6 +476,14 @@ static void SyncVideo( hb_work_object_t * w )
                     hb_buffer_close( &sub );
                 }
                 
+                if( sub && sub->size == 0 )
+                {
+                    /* 
+                     * Continue immediately on subtitle EOF
+                     */
+                    break;
+                }
+
                 /*
                  * There is a valid subtitle, is it time to display it?
                  */
@@ -606,28 +622,43 @@ static void SyncVideo( hb_work_object_t * w )
         if( sub && subtitle && 
             subtitle->format == PICTURESUB )
         {
-            if( subtitle->dest == RENDERSUB )
+            if( sub->size > 0 )
             {
-                /*
-                 * Tack onto the video buffer for rendering
-                 */
-                buf_tmp->sub         = hb_buffer_init( sub->size );
-                buf_tmp->sub->x      = sub->x;
-                buf_tmp->sub->y      = sub->y;
-                buf_tmp->sub->width  = sub->width;
-                buf_tmp->sub->height = sub->height;
-                memcpy( buf_tmp->sub->data, sub->data, sub->size ); 
+                if( subtitle->dest == RENDERSUB )
+                {
+                    /*
+                     * Tack onto the video buffer for rendering
+                     */
+                    buf_tmp->sub         = hb_buffer_init( sub->size );
+                    buf_tmp->sub->x      = sub->x;
+                    buf_tmp->sub->y      = sub->y;
+                    buf_tmp->sub->width  = sub->width;
+                    buf_tmp->sub->height = sub->height;
+                    memcpy( buf_tmp->sub->data, sub->data, sub->size ); 
+                } else {
+                    /*
+                     * Pass-Through, pop it off of the raw queue, rewrite times and
+                     * make it available to be muxed.
+                     */
+                    uint64_t sub_duration;
+                    sub = hb_fifo_get( subtitle->fifo_raw );
+                    sub_duration = sub->stop - sub->start;
+                    sub->start = buf_tmp->start;
+                    sub->stop = sub->start + duration;
+                    hb_fifo_push( subtitle->fifo_out, sub );
+                }
             } else {
                 /*
-                 * Pass-Through, pop it off of the raw queue, rewrite times and
-                 * make it available to be muxed.
+                 * EOF - consume for rendered, else pass through
                  */
-                uint64_t sub_duration;
-                sub = hb_fifo_get( subtitle->fifo_raw );
-                sub_duration = sub->stop - sub->start;
-                sub->start = buf_tmp->start;
-                sub->stop = sub->start + duration;
-                hb_fifo_push( subtitle->fifo_out, sub );
+                if( subtitle->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 );
+                }
             }
         }