]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_subpictures.c
Re-enable random.
[vlc] / src / video_output / vout_subpictures.c
index 12814124b34baeee2b9c8c08ddd4d934cb2f418b..5d1c19a755f5fb95fd338e5135cc5183ae3d6cd5 100644 (file)
@@ -256,7 +256,7 @@ subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
     p_region->p_cache = 0;
     p_region->fmt = *p_fmt;
     p_region->psz_text = 0;
-    p_region->i_text_color = 0xFFFFFF;
+    p_region->p_style = NULL;
 
     if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
         p_fmt->p_palette = p_region->fmt.p_palette =
@@ -299,7 +299,7 @@ subpicture_region_t *__spu_MakeRegion( vlc_object_t *p_this,
     p_region->p_cache = 0;
     p_region->fmt = *p_fmt;
     p_region->psz_text = 0;
-    p_region->i_text_color = 0xFFFFFF;
+    p_region->p_style = NULL;
 
     if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
         p_fmt->p_palette = p_region->fmt.p_palette =
@@ -324,7 +324,6 @@ void __spu_DestroyRegion( vlc_object_t *p_this, subpicture_region_t *p_region )
     if( p_region->picture.pf_release )
         p_region->picture.pf_release( &p_region->picture );
     if( p_region->fmt.p_palette ) free( p_region->fmt.p_palette );
-    if( p_region->psz_text ) free( p_region->psz_text );
     if( p_region->p_cache ) __spu_DestroyRegion( p_this, p_region->p_cache );
     free( p_region );
 }
@@ -498,44 +497,76 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
         }
 
         /* Load the text rendering module */
-        if( !p_spu->p_text && p_region )
+        if( !p_spu->p_text && p_region && p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
         {
+            char *psz_modulename = NULL;
+
             p_spu->p_text = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
             vlc_object_attach( p_spu->p_text, p_spu );
 
             p_spu->p_text->fmt_out.video.i_width =
                 p_spu->p_text->fmt_out.video.i_visible_width =
-                    p_fmt->i_width;
+                p_fmt->i_width;
             p_spu->p_text->fmt_out.video.i_height =
                 p_spu->p_text->fmt_out.video.i_visible_height =
-                    p_fmt->i_height;
+                p_fmt->i_height;
 
             p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
             p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
-            p_spu->p_text->p_module =
-                module_Need( p_spu->p_text, "text renderer", 0, 0 );
+
+            psz_modulename = var_CreateGetString( p_spu, "text-renderer" );
+            if( psz_modulename && *psz_modulename )
+            {
+                p_spu->p_text->p_module =
+                    module_Need( p_spu->p_text, "text renderer", psz_modulename, VLC_TRUE );
+            }
+            if( !p_spu->p_text->p_module )
+            {
+                p_spu->p_text->p_module =
+                    module_Need( p_spu->p_text, "text renderer", 0, 0 );
+            }
+            if( psz_modulename ) free( psz_modulename );
         }
-        else if( p_region )
+        if( p_spu->p_text )
         {
-            p_spu->p_text->fmt_out.video.i_width =
-                p_spu->p_text->fmt_out.video.i_visible_width =
+            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 =
+                    p_subpic->i_original_picture_width;
+                p_spu->p_text->fmt_out.video.i_height =
+                    p_spu->p_text->fmt_out.video.i_visible_height =
+                    p_subpic->i_original_picture_height;
+            }
+            else
+            {
+                p_spu->p_text->fmt_out.video.i_width =
+                    p_spu->p_text->fmt_out.video.i_visible_width =
                     p_fmt->i_width;
-            p_spu->p_text->fmt_out.video.i_height =
-                p_spu->p_text->fmt_out.video.i_visible_height =
+                p_spu->p_text->fmt_out.video.i_height =
+                    p_spu->p_text->fmt_out.video.i_visible_height =
                     p_fmt->i_height;
+            }
         }
 
         i_scale_width = i_scale_width_orig;
         i_scale_height = i_scale_height_orig;
 
-        if( p_subpic->i_original_picture_width &&
-            p_subpic->i_original_picture_height )
+        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;
             i_scale_height = i_scale_height * p_fmt->i_height /
                              p_subpic->i_original_picture_height;
         }
+        else if( p_subpic->i_original_picture_height > 0 )
+        {
+            i_scale_height = i_scale_height * p_fmt->i_height /
+                             p_subpic->i_original_picture_height;
+            i_scale_width = i_scale_height * i_scale_height / p_fmt->i_height; 
+        }
 
         /* Set default subpicture aspect ratio */
         if( p_region && p_region->fmt.i_aspect &&
@@ -592,7 +623,7 @@ void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
                 if( p_spu->p_text && p_spu->p_text->p_module &&
                     p_spu->p_text->pf_render_text )
                 {
-                    p_region->i_text_align = p_subpic->i_flags & 0x3;
+                    p_region->i_align = p_subpic->i_flags;
                     p_spu->p_text->pf_render_text( p_spu->p_text,
                                                    p_region, p_region ); 
                 }