]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_subpictures.c
Correctly handle (avoid deadlocks) always on top when switching fullscreen.
[vlc] / src / video_output / vout_subpictures.c
index eed1925f161d01735ee95f415df96e0f29eed9b2..ce7f6cf466555c9d613b7d2fdc4891a43a306a91 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                                /* free() */
-#include <stdio.h>                                              /* sprintf() */
-#include <string.h>                                            /* strerror() */
-
 #include <vlc/vlc.h>
 #include <vlc_vout.h>
 #include <vlc_block.h>
@@ -534,7 +530,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
         }
 
         /* Load the text rendering module */
-        if( !p_spu->p_text && p_region && p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
+        if( !p_spu->p_text && p_region
+         && p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
         {
             char *psz_modulename = NULL;
 
@@ -567,8 +564,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
         }
         if( p_spu->p_text )
         {
-            if( p_subpic->i_original_picture_height > 0 &&
-                p_subpic->i_original_picture_width  > 0 )
+            if( (p_subpic->i_original_picture_height > 0) &&
+                (p_subpic->i_original_picture_width  > 0) )
             {
                 p_spu->p_text->fmt_out.video.i_width =
                     p_spu->p_text->fmt_out.video.i_visible_width =
@@ -591,8 +588,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
         i_scale_width = i_scale_width_orig;
         i_scale_height = i_scale_height_orig;
 
-        if( p_subpic->i_original_picture_height > 0 &&
-            p_subpic->i_original_picture_width  > 0 )
+        if( (p_subpic->i_original_picture_height > 0) &&
+            (p_subpic->i_original_picture_width  > 0) )
         {
             i_scale_width = i_scale_width * p_fmt->i_width /
                              p_subpic->i_original_picture_width;
@@ -631,8 +628,9 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
         }
 
         /* Load the scaling module */
-        if( !p_spu->p_scale && (i_scale_width != 1000 ||
-            i_scale_height != 1000) )
+        if( !p_spu->p_scale &&
+            ((i_scale_width > 0) || (i_scale_height > 0)) &&
+            ((i_scale_width != 1000) || (i_scale_height != 1000)) )
         {
             p_spu->p_scale = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
             vlc_object_attach( p_spu->p_scale, p_spu );
@@ -665,21 +663,24 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 {
                     vlc_value_t  val;
 
-                    /* Setup 3 variables which can be used to render time-dependent
-                     * text (and effects). The first indicates the total amount of
-                     * time the text will be on screen, the second the amount of time
-                     * it has already been on screen (can be a negative value as text
-                     * is layed out before it is rendered) and the third is a feedback
-                     * variable from the renderer - if the renderer sets it then this
-                     * particular text is time-dependent, eg. the visual progress bar
-                     * inside the text in karaoke and the text needs to be rendered
-                     * multiple times in order for the effect to work - we therefore
-                     * need to return the region to its original state at the end of
-                     * the loop, instead of leaving it in YUVA or YUVP
-                     * Any renderer which is unaware of how to render time-dependent
-                     * text can happily ignore the variables and render the text the
-                     * same as usual - it should at least show up on screen, but the
-                     * effect won't change the text over time.
+                    /* Setup 3 variables which can be used to render
+                     * time-dependent text (and effects). The first indicates
+                     * the total amount of time the text will be on screen,
+                     * the second the amount of time it has already been on
+                     * screen (can be a negative value as text is layed out
+                     * before it is rendered) and the third is a feedback
+                     * variable from the renderer - if the renderer sets it
+                     * then this particular text is time-dependent, eg. the
+                     * visual progress bar inside the text in karaoke and the
+                     * text needs to be rendered multiple times in order for
+                     * the effect to work - we therefore need to return the
+                     * region to its original state at the end of the loop,
+                     * instead of leaving it in YUVA or YUVP.
+                     * Any renderer which is unaware of how to render
+                     * time-dependent text can happily ignore the variables
+                     * and render the text the same as usual - it should at
+                     * least show up on screen, but the effect won't change
+                     * the text over time.
                      */
 
                     var_Create( p_spu->p_text, "spu-duration", VLC_VAR_TIME );
@@ -734,7 +735,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 }
             }
 
-            if( (i_scale_width != 1000 || i_scale_height != 1000) &&
+            if( ((i_scale_width != 1000) || (i_scale_height != 1000)) &&
+                ((i_scale_width > 0) || (i_scale_height > 0)) &&
                 p_spu->p_scale && !p_region->p_cache )
             {
                 picture_t *p_pic;
@@ -776,7 +778,8 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                     free( p_pic );
                 }
             }
-            if( (i_scale_width != 1000 || i_scale_height != 1000) &&
+            if( ((i_scale_width != 1000) || (i_scale_height != 1000)) &&
+                ((i_scale_width > 0) || (i_scale_height > 0)) &&
                 p_spu->p_scale && p_region->p_cache )
             {
                 p_region = p_region->p_cache;
@@ -818,11 +821,14 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
             {
                 int i_diff = 0;
                 int i_low = i_y_offset - p_spu->i_margin;
-                int i_high = i_y_offset + p_region->fmt.i_height - p_spu->i_margin;
+                int i_high = i_y_offset + p_region->fmt.i_height
+                             - p_spu->i_margin;
 
                 /* crop extra margin to keep within bounds */
-                if( i_low < 0 ) i_diff = i_low;
-                if( i_high > (int)p_fmt->i_height ) i_diff = i_high - p_fmt->i_height;
+                if( i_low < 0 )
+                    i_diff = i_low;
+                if( i_high > (int)p_fmt->i_height )
+                    i_diff = i_high - p_fmt->i_height;
                 i_y_offset -= ( p_spu->i_margin + i_diff );
             }
 
@@ -895,9 +901,10 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
 
             if( b_rerender_text )
             {
-                /* Some forms of subtitles need to be re-rendered more than once,
-                 * eg. karaoke. We therefore restore the region to its pre-rendered
-                 * state, so the next time through everything is calculated again.
+                /* Some forms of subtitles need to be re-rendered more than
+                 * once, eg. karaoke. We therefore restore the region to its
+                 * pre-rendered state, so the next time through everything is
+                 * calculated again.
                  */
                 p_region->picture.pf_release( &p_region->picture );
                 memset( &p_region->picture, 0, sizeof( picture_t ) );