]> git.sesse.net Git - vlc/blobdiff - src/video_output/video_output.c
Renamed "deinterlace" into "deinterlace-mode" at the core level.
[vlc] / src / video_output / video_output.c
index f4788b3d073ff36c176edbf1ca82ab02e211502f..31738fbd43d34d2ecd6a6970b427510acaf2b57f 100644 (file)
@@ -494,31 +494,21 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
     /* */
     DeinterlaceEnable( p_vout );
 
-    vlc_object_set_destructor( p_vout, vout_Destructor );
+    if( p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain )
+        p_vout->p->psz_module_type = "video filter";
+    else
+        p_vout->p->psz_module_type = "video output";
+    p_vout->p->psz_module_name = psz_name;
+    p_vout->p_module = NULL;
 
     /* */
-    p_vout->p_module = module_need( p_vout,
-        ( p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain ) ?
-        "video filter" : "video output", psz_name, p_vout->p->psz_filter_chain && *p_vout->p->psz_filter_chain );
-    free( psz_name );
-
-    if( p_vout->p_module == NULL )
-    {
-        msg_Err( p_vout, "no suitable vout module" );
-        spu_Attach( p_vout->p_spu, VLC_OBJECT(p_vout), false );
-        spu_Destroy( p_vout->p_spu );
-        p_vout->p_spu = NULL;
-        vlc_object_release( p_vout );
-        return NULL;
-    }
+    vlc_object_set_destructor( p_vout, vout_Destructor );
 
     /* */
     vlc_cond_init( &p_vout->p->change_wait );
     if( vlc_clone( &p_vout->p->thread, RunThread, p_vout,
                    VLC_THREAD_PRIORITY_OUTPUT ) )
     {
-        module_unneed( p_vout, p_vout->p_module );
-        p_vout->p_module = NULL;
         spu_Attach( p_vout->p_spu, VLC_OBJECT(p_vout), false );
         spu_Destroy( p_vout->p_spu );
         p_vout->p_spu = NULL;
@@ -565,8 +555,6 @@ void vout_Close( vout_thread_t *p_vout )
     vout_snapshot_End( &p_vout->p->snapshot );
 
     vlc_join( p_vout->p->thread, NULL );
-    module_unneed( p_vout, p_vout->p_module );
-    p_vout->p_module = NULL;
 }
 
 /* */
@@ -577,6 +565,8 @@ static void vout_Destructor( vlc_object_t * p_this )
     /* Make sure the vout was stopped first */
     assert( !p_vout->p_module );
 
+    free( p_vout->p->psz_module_name );
+
     /* */
     if( p_vout->p_spu )
         spu_Destroy( p_vout->p_spu );
@@ -985,26 +975,30 @@ static void* RunThread( void *p_this )
     int             i_idle_loops = 0;  /* loops without displaying a picture */
     int             i_picture_qtype_last = QTYPE_NONE;
 
-    bool            b_drop_late;
+
+    vlc_mutex_lock( &p_vout->change_lock );
 
     /*
      * Initialize thread
      */
-    vlc_mutex_lock( &p_vout->change_lock );
-    p_vout->b_error = InitThread( p_vout );
-
-    b_drop_late = var_CreateGetBool( p_vout, "drop-late-frames" );
+    p_vout->p_module = module_need( p_vout,
+                                    p_vout->p->psz_module_type,
+                                    p_vout->p->psz_module_name,
+                                    !strcmp(p_vout->p->psz_module_type, "video filter") );
+    if( p_vout->p_module )
+        p_vout->b_error = InitThread( p_vout );
+    else
+        p_vout->b_error = true;
 
     /* signal the creation of the vout */
     p_vout->p->b_ready = true;
     vlc_cond_signal( &p_vout->p->change_wait );
 
     if( p_vout->b_error )
-    {
-        EndThread( p_vout );
-        vlc_mutex_unlock( &p_vout->change_lock );
-        return NULL;
-    }
+        goto exit_thread;
+
+    /* */
+    const bool b_drop_late = var_CreateGetBool( p_vout, "drop-late-frames" );
 
     /*
      * Main loop - it is not executed if an error occurred during
@@ -1311,7 +1305,7 @@ static void* RunThread( void *p_this )
             if( p_vout->pf_init( p_vout ) )
             {
                 msg_Err( p_vout, "cannot resize display" );
-                /* FIXME: pf_end will be called again in EndThread() */
+                /* FIXME: pf_end will be called again in CleanThread()? */
                 p_vout->b_error = 1;
             }
 
@@ -1396,11 +1390,18 @@ static void* RunThread( void *p_this )
     if( p_vout->b_error )
         ErrorThread( p_vout );
 
-    /* End of thread */
+    /* Clean thread */
     CleanThread( p_vout );
+
+exit_thread:
+    /* End of thread */
     EndThread( p_vout );
     vlc_mutex_unlock( &p_vout->change_lock );
 
+    if( p_vout->p_module )
+        module_unneed( p_vout, p_vout->p_module );
+    p_vout->p_module = NULL;
+
     return NULL;
 }
 
@@ -1777,7 +1778,6 @@ static void DisplayTitleOnOSD( vout_thread_t *p_vout )
 typedef struct
 {
     const char *psz_mode;
-    const char *psz_description;
     bool       b_vout_filter;
 } deinterlace_mode_t;
 
@@ -1786,14 +1786,16 @@ typedef struct
  * same (width/height/chroma/fps), at least for now.
  */
 static const deinterlace_mode_t p_deinterlace_mode[] = {
-    { "",           "Disable",  false },
-    { "discard",    "Discard",  true },
-    { "blend",      "Blend",    false },
-    { "mean",       "Mean",     true  },
-    { "bob",        "Bob",      true },
-    { "linear",     "Linear",   true },
-    { "x",          "X",        false },
-    { NULL, NULL, true }
+    { "",        false },
+    { "discard", true },
+    { "blend",   false },
+    { "mean",    true  },
+    { "bob",     true },
+    { "linear",  true },
+    { "x",       false },
+    { "yadif",   true },
+    { "yadif2x", true },
+    { NULL,      true }
 };
 
 static char *FilterFind( char *psz_filter_base, const char *psz_module )
@@ -1904,11 +1906,11 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd,
     input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
     if( p_input )
     {
-        var_Create( p_input, "vout-deinterlace", VLC_VAR_STRING );
-        var_SetString( p_input, "vout-deinterlace", p_mode->psz_mode );
-
         var_Create( p_input, "deinterlace-mode", VLC_VAR_STRING );
-        var_SetString( p_input, "deinterlace-mode", p_mode->psz_mode );
+        var_SetString( p_input, "deinterlace-mode", *p_mode->psz_mode ? p_mode->psz_mode : "disable" );
+
+        var_Create( p_input, "filter-deinterlace-mode", VLC_VAR_STRING );
+        var_SetString( p_input, "filter-deinterlace-mode", p_mode->psz_mode );
 
         var_Create( p_input, "sout-deinterlace-mode", VLC_VAR_STRING );
         var_SetString( p_input, "sout-deinterlace-mode", p_mode->psz_mode );
@@ -1920,7 +1922,7 @@ static int DeinterlaceCallback( vlc_object_t *p_this, char const *psz_cmd,
 
     if( p_mode->b_vout_filter )
     {
-        psz_old = var_CreateGetString( p_vout, "deinterlace-mode" );
+        psz_old = var_CreateGetString( p_vout, "filter-deinterlace-mode" );
     }
     else
     {
@@ -1961,31 +1963,38 @@ static void DeinterlaceEnable( vout_thread_t *p_vout )
     msg_Dbg( p_vout, "Deinterlacing available" );
 
     /* Create the configuration variable */
-    var_Create( p_vout, "deinterlace", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-    text.psz_string = _("Deinterlace");
-    var_Change( p_vout, "deinterlace", VLC_VAR_SETTEXT, &text, NULL );
+    var_Create( p_vout, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT | VLC_VAR_HASCHOICE );
+    char *psz_deinterlace = var_GetNonEmptyString( p_vout, "deinterlace-mode" );
+
+    text.psz_string = _("Deinterlace mode");
+    var_Change( p_vout, "deinterlace-mode", VLC_VAR_SETTEXT, &text, NULL );
 
-    for( int i = 0; p_deinterlace_mode[i].psz_mode; i++ )
+    const module_config_t *p_opt = config_FindConfig( VLC_OBJECT(p_vout), "deinterlace-mode" );
+    var_Change( p_vout, "deinterlace-mode", VLC_VAR_CLEARCHOICES, NULL, NULL );
+    for( int i = 0; p_opt && i < p_opt->i_list; i++ )
     {
-        val.psz_string  = (char*)p_deinterlace_mode[i].psz_mode;
-        text.psz_string = (char*)vlc_gettext(p_deinterlace_mode[i].psz_description);
-        var_Change( p_vout, "deinterlace", VLC_VAR_ADDCHOICE, &val, &text );
+        val.psz_string  = p_opt->ppsz_list[i];
+        text.psz_string = (char*)vlc_gettext(p_opt->ppsz_list_text[i]);
+        var_Change( p_vout, "deinterlace-mode", VLC_VAR_ADDCHOICE, &val, &text );
     }
-    var_AddCallback( p_vout, "deinterlace", DeinterlaceCallback, NULL );
+    var_AddCallback( p_vout, "deinterlace-mode", DeinterlaceCallback, NULL );
 
     /* */
-    char *psz_mode = NULL;
-    if( var_Type( p_vout, "vout-deinterlace" ) != 0 )
-        psz_mode = var_CreateGetNonEmptyString( p_vout, "vout-deinterlace" );
+    char *psz_mode = psz_deinterlace;
+    if( psz_mode && !strcmp( psz_mode, "disable" ) )
+    {
+        free( psz_mode );
+        psz_mode = strdup( "" );
+    }
     if( !psz_mode )
     {
-        /* Get the initial value */
+        /* Get the initial value from filters if present */
         if( DeinterlaceIsPresent( p_vout, true ) )
-            psz_mode = var_CreateGetNonEmptyString( p_vout, "deinterlace-mode" );
+            psz_mode = var_CreateGetNonEmptyString( p_vout, "filter-deinterlace-mode" );
         else if( DeinterlaceIsPresent( p_vout, false ) )
             psz_mode = var_CreateGetNonEmptyString( p_vout, "sout-deinterlace-mode" );
     }
-    var_SetString( p_vout, "deinterlace", psz_mode ? psz_mode : "" );
+    var_SetString( p_vout, "deinterlace-mode", psz_mode ? psz_mode : "" );
     free( psz_mode );
 }