]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_subpictures.c
No functionnal changes.
[vlc] / src / video_output / vout_subpictures.c
index 58680f26e482714edae50ccac512f03dde1e485a..8b8a44825950b6758da8ea5d4858b9dd5bf1e910 100644 (file)
@@ -30,6 +30,9 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+#include <limits.h>
+
 #include <vlc_common.h>
 #include <vlc_vout.h>
 #include <vlc_block.h>
@@ -39,9 +42,6 @@
 #include "vout_internal.h"
 #include <vlc_image.h>
 
-#include <assert.h>
-#include <limits.h>
-
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -184,21 +184,23 @@ static void FilterRelease( filter_t *p_filter );
 /*****************************************************************************
  * Public API
  *****************************************************************************/
+
+#undef spu_Create
 /**
  * Creates the subpicture unit
  *
  * \param p_this the parent object which creates the subpicture unit
  */
-spu_t *__spu_Create( vlc_object_t *p_this )
+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" );
-
     if( !p_spu )
         return NULL;
+    vlc_object_attach( p_spu, p_this );
 
     /* Initialize spu fields */
     p_spu->pf_control = SpuControl;
@@ -214,13 +216,11 @@ spu_t *__spu_Create( vlc_object_t *p_this )
     p_sys->p_scale = NULL;
     p_sys->p_scale_yuvp = NULL;
 
-    p_sys->i_margin = config_GetInt( p_spu, "sub-margin" );
+    p_sys->i_margin = var_InheritInteger( p_spu, "sub-margin" );
 
     /* Register the default subpicture channel */
     p_sys->i_channel = 2;
 
-    vlc_object_attach( p_spu, p_this );
-
     p_sys->psz_chain_update = NULL;
     p_sys->p_chain = filter_chain_New( p_spu, "sub filter", false,
                                        SubFilterAllocationInit,
@@ -302,6 +302,7 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
     if( b_attach )
     {
         UpdateSPU( p_spu, VLC_OBJECT(p_input) );
+        var_Create( p_input, "highlight", VLC_VAR_BOOL );
         var_AddCallback( p_input, "highlight", CropCallback, p_spu );
         var_AddCallback( p_input, "sub-margin", MarginCallback, p_spu->p );
 
@@ -313,9 +314,10 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
     }
     else
     {
-        /* Delete callback */
-        var_DelCallback( p_input, "highlight", CropCallback, p_spu );
+        /* Delete callbacks */
         var_DelCallback( p_input, "sub-margin", MarginCallback, p_spu->p );
+        var_DelCallback( p_input, "highlight", CropCallback, p_spu );
+        var_Destroy( p_input, "highlight" );
         vlc_object_release( p_input );
     }
 }
@@ -475,16 +477,8 @@ void spu_RenderSubpictures( spu_t *p_spu,
         p_region = p_subpic->p_region;
         if( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den )
         {
-            if( p_region->fmt.i_aspect != 0 )
-            {
-                p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
-                p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
-            }
-            else
-            {
-                p_region->fmt.i_sar_den = p_fmt_dst->i_sar_den;
-                p_region->fmt.i_sar_num = p_fmt_dst->i_sar_num;
-            }
+            p_region->fmt.i_sar_den = p_fmt_dst->i_sar_den;
+            p_region->fmt.i_sar_num = p_fmt_dst->i_sar_num;
         }
 
         /* Take care of the aspect ratio */
@@ -778,7 +772,6 @@ subpicture_t *subpicture_NewFromPicture( vlc_object_t *p_obj,
     p_subpic->i_original_picture_width  = fmt_out.i_width;
     p_subpic->i_original_picture_height = fmt_out.i_height;
 
-    fmt_out.i_aspect = 0;
     fmt_out.i_sar_num =
     fmt_out.i_sar_den = 0;
 
@@ -825,7 +818,7 @@ subpicture_region_t *subpicture_region_New( const video_format_t *p_fmt )
     p_region->p_picture = picture_NewFromFormat( p_fmt );
     if( !p_region->p_picture )
     {
-        free( p_fmt->p_palette );
+        free( p_region->fmt.p_palette );
         free( p_region );
         return NULL;
     }
@@ -965,7 +958,6 @@ static void FilterRelease( filter_t *p_filter )
     if( p_filter->p_module )
         module_unneed( p_filter, p_filter->p_module );
 
-    vlc_object_detach( p_filter );
     vlc_object_release( p_filter );
 }
 
@@ -1035,8 +1027,8 @@ static filter_t *CreateAndLoadScale( vlc_object_t *p_obj,
     p_scale->fmt_out.video.i_width =
     p_scale->fmt_out.video.i_height = b_resize ? 16 : 32;
 
-    p_scale->pf_vout_buffer_new = spu_new_video_buffer;
-    p_scale->pf_vout_buffer_del = spu_del_video_buffer;
+    p_scale->pf_video_buffer_new = spu_new_video_buffer;
+    p_scale->pf_video_buffer_del = spu_del_video_buffer;
 
     vlc_object_attach( p_scale, p_obj );
     p_scale->p_module = module_need( p_scale, "video filter2", NULL, false );