[vlc-devel] [PATCH 2/2] lib/media_player: add "auto" deinterlace mode
Thomas Guillem
thomas at gllm.fr
Wed Jan 25 09:25:45 CET 2017
On Tue, Jan 24, 2017, at 17:34, Rémi Denis-Courmont wrote:
> This looks wrong on several levels. First the mode is supposed to be the
> "how", not the "when".
OK, maybe we can add "default" to set the default deinterlace mode then
(but not changing the when).
Should we add a new function to enable/disable/auto deinterlacing ?
>
> Second, there is a whole lot of code in setter, which seems contradictory
> for
> something automatic (though that might be a consequence of the first
> problem).
>
> Le tiistaina 24. tammikuuta 2017, 13.32.15 EET Thomas Guillem a écrit :
> > ---
> > include/vlc/libvlc_media_player.h | 5 +++--
> > lib/video.c | 40
> > +++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+),
> > 16 deletions(-)
> >
> > diff --git a/include/vlc/libvlc_media_player.h
> > b/include/vlc/libvlc_media_player.h index 97069f795b..586e86db69 100644
> > --- a/include/vlc/libvlc_media_player.h
> > +++ b/include/vlc/libvlc_media_player.h
> > @@ -1420,10 +1420,11 @@ int libvlc_video_take_snapshot(
> > libvlc_media_player_t *p_mi, unsigned num, * Enable or disable deinterlace
> > filter
> > *
> > * \param p_mi libvlc media player
> > - * \param psz_mode type of deinterlace filter, NULL to disable
> > + * \param psz_mode type of deinterlace filter, NULL to disable, "auto" for
> > + * automatic (default behavior)
> > */
> > LIBVLC_API void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
> > - const char *psz_mode );
> > + const char *psz_mode );
> >
> > /**
> > * Get an integer marquee option value
> > diff --git a/lib/video.c b/lib/video.c
> > index 46f9935025..f37dcff10f 100644
> > --- a/lib/video.c
> > +++ b/lib/video.c
> > @@ -614,23 +614,38 @@ end:
> > void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
> > const char *psz_mode )
> > {
> > - if (psz_mode == NULL)
> > - psz_mode = "";
> > - if (*psz_mode
> > + if (psz_mode
> > && strcmp (psz_mode, "blend") && strcmp (psz_mode, "bob")
> > && strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
> > && strcmp (psz_mode, "mean") && strcmp (psz_mode, "x")
> > && strcmp (psz_mode, "yadif") && strcmp (psz_mode, "yadif2x")
> > - && strcmp (psz_mode, "phosphor") && strcmp (psz_mode, "ivtc"))
> > + && strcmp (psz_mode, "phosphor") && strcmp (psz_mode, "ivtc")
> > + && strcmp (psz_mode, "auto"))
> > return;
> >
> > - if (*psz_mode)
> > + char *psz_parent_mode = NULL;
> > + int i_mode;
> > + if (psz_mode != NULL)
> > {
> > - var_SetString (p_mi, "deinterlace-mode", psz_mode);
> > - var_SetInteger (p_mi, "deinterlace", 1);
> > + if (strcmp (psz_mode, "auto") == 0)
> > + {
> > + /* Recover the initial "deinterlace-mode" value */
> > + psz_mode = psz_parent_mode =
> > + var_InheritString(p_mi->obj.parent, "deinterlace-mode");
> > + i_mode = psz_mode != NULL ? -1 /* auto */ : 0 /* disabled */;
> > + }
> > + else
> > + i_mode = 1;
> > }
> > else
> > - var_SetInteger (p_mi, "deinterlace", 0);
> > + i_mode = 0;
> > +
> > + if (i_mode != 0)
> > + {
> > + assert (psz_mode);
> > + var_SetString (p_mi, "deinterlace-mode", psz_mode);
> > + }
> > + var_SetInteger (p_mi, "deinterlace", i_mode);
> >
> > size_t n;
> > vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
> > @@ -638,16 +653,13 @@ void libvlc_video_set_deinterlace(
> > libvlc_media_player_t *p_mi, {
> > vout_thread_t *p_vout = pp_vouts[i];
> >
> > - if (*psz_mode)
> > - {
> > + if (i_mode != 0)
> > var_SetString (p_vout, "deinterlace-mode", psz_mode);
> > - var_SetInteger (p_vout, "deinterlace", 1);
> > - }
> > - else
> > - var_SetInteger (p_vout, "deinterlace", 0);
> > + var_SetInteger (p_vout, "deinterlace", i_mode);
> > vlc_object_release (p_vout);
> > }
> > free (pp_vouts);
> > + free (psz_parent_mode);
> > }
> >
> > /* ************** */
>
>
> --
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list