]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_subpictures.c
Spu pause support.
[vlc] / src / video_output / vout_subpictures.c
index fb366403c6de47ae1697f6064b2b697ae4bd51ae..3161e488d5ce8f714e286a15f4b37a97fb854114 100644 (file)
@@ -36,6 +36,7 @@
 #include <vlc_filter.h>
 #include <vlc_osd.h>
 #include "../libvlc.h"
+#include "vout_internal.h"
 
 #include <assert.h>
 #include <limits.h>
@@ -90,6 +91,8 @@ struct spu_private_t
 
     /* */
     mtime_t i_last_sort_date;
+    /* */
+    mtime_t i_last_render_date;
 };
 
 /* */
@@ -191,7 +194,7 @@ spu_t *__spu_Create( vlc_object_t *p_this )
 {
     spu_t *p_spu;
     spu_private_t *p_sys;
-    
     p_spu = vlc_custom_create( p_this, sizeof(spu_t) + sizeof(spu_private_t),
                                VLC_OBJECT_GENERIC, "subpicture" );
 
@@ -228,6 +231,7 @@ spu_t *__spu_Create( vlc_object_t *p_this )
 
     /* */
     p_sys->i_last_sort_date = -1;
+    p_sys->i_last_render_date = -1;
 
     return p_spu;
 }
@@ -363,7 +367,7 @@ void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
 void spu_RenderSubpictures( spu_t *p_spu,
                             picture_t *p_pic_dst, const video_format_t *p_fmt_dst,
                             subpicture_t *p_subpic_list,
-                            const video_format_t *p_fmt_src )
+                            const video_format_t *p_fmt_src, bool b_paused )
 {
     spu_private_t *p_sys = p_spu->p;
 
@@ -389,18 +393,23 @@ void spu_RenderSubpictures( spu_t *p_spu,
                 p_subpic = p_subpic->p_next )
     {
         /* */
-        if( p_subpic->pf_pre_render )
+        if( !b_paused && p_subpic->pf_pre_render )
             p_subpic->pf_pre_render( p_spu, p_subpic, p_fmt_dst );
 
-        if( p_subpic->pf_update_regions )
+        if( !b_paused && p_subpic->pf_update_regions )
         {
+            mtime_t i_render_date;
             video_format_t fmt_org = *p_fmt_dst;
             fmt_org.i_width =
             fmt_org.i_visible_width = i_source_video_width;
             fmt_org.i_height =
             fmt_org.i_visible_height = i_source_video_height;
 
-            p_subpic->pf_update_regions( p_spu, p_subpic, &fmt_org, i_current_date );
+            i_render_date = i_current_date;
+            if( p_subpic->b_subtitle && b_paused && p_sys->i_last_render_date > 0 )
+                i_render_date = p_sys->i_last_render_date;
+
+            p_subpic->pf_update_regions( p_spu, p_subpic, &fmt_org, i_render_date );
         }
 
         /* */
@@ -414,6 +423,9 @@ void spu_RenderSubpictures( spu_t *p_spu,
         pp_subpicture[i_subpicture++] = p_subpic;
     }
 
+    if( !b_paused )
+        p_sys->i_last_render_date = i_current_date;
+
     /* Be sure we have at least 1 picture to process */
     if( i_subpicture <= 0 )
     {
@@ -613,7 +625,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
             b_late = b_stop_valid && p_current->i_stop <= display_date;
 
             /* start_date will be used for correct automatic overlap support
-             * in case picture that should not be displayed anymore (display_time) 
+             * in case picture that should not be displayed anymore (display_time)
              * overlap with a picture to be displayed (p_current->i_start)  */
             if( !b_late && !p_current->b_ephemer )
                 start_date = p_current->i_start;
@@ -655,6 +667,27 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
     return p_subpic;
 }
 
+void spu_OffsetSubtitleDate( spu_t *p_spu, mtime_t i_duration )
+{
+    spu_private_t *p_sys = p_spu->p;
+
+    vlc_mutex_lock( &p_sys->lock );
+    for( int i = 0; i < VOUT_MAX_SUBPICTURES; i++ )
+    {
+        spu_heap_entry_t *p_entry = &p_sys->heap.p_entry[i];
+        subpicture_t *p_current = p_entry->p_subpicture;
+
+        if( p_current && p_current->b_subtitle )
+        {
+            if( p_current->i_start > 0 )
+                p_current->i_start += i_duration;
+            if( p_current->i_stop > 0 )
+                p_current->i_stop += i_duration;
+        }
+    }
+    vlc_mutex_unlock( &p_sys->lock );
+}
+
 /*****************************************************************************
  * subpicture_t allocation
  *****************************************************************************/
@@ -1601,7 +1634,7 @@ static int IntegerCmp( int64_t i0, int64_t i1 )
     return i0 < i1 ? -1 : i0 > i1 ? 1 : 0;
 }
 /**
- * This function compares 2 subpictures using the following properties 
+ * This function compares 2 subpictures using the following properties
  * (ordered by priority)
  * 1. absolute positionning
  * 2. start time