/*****************************************************************************
* deinterlace.c : deinterlacer plugin for vlc
*****************************************************************************
- * Copyright (C) 2000-2011 the VideoLAN team
+ * Copyright (C) 2000-2011 VLC authors and VideoLAN
* $Id$
*
* Author: Sam Hocevar <sam@zoy.org>
* Juha Jeronen <juha.jeronen@jyu.fi>
* ...and others
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
*****************************************************************************/
#define MODE_TEXT N_("Deinterlace mode")
-#define MODE_LONGTEXT N_("Deinterlace method to use for local playback.")
#define SOUT_MODE_TEXT N_("Streaming deinterlace mode")
#define SOUT_MODE_LONGTEXT N_("Deinterlace method to use for streaming.")
add_string( FILTER_CFG_PREFIX "mode", "blend", SOUT_MODE_TEXT,
SOUT_MODE_LONGTEXT, false )
- change_string_list( mode_list, mode_list_text, 0 )
+ change_string_list( mode_list, mode_list_text )
change_safe ()
add_integer( FILTER_CFG_PREFIX "phosphor-chroma", 2, PHOSPHOR_CHROMA_TEXT,
PHOSPHOR_CHROMA_LONGTEXT, true )
* SetFilterMethod: setup the deinterlace method to use.
*****************************************************************************/
-void SetFilterMethod( filter_t *p_filter, const char *psz_method )
+/**
+ * Setup the deinterlace method to use.
+ *
+ * FIXME: extract i_chroma from p_filter automatically?
+ *
+ * @param p_filter The filter instance.
+ * @param psz_method Desired method. See mode_list for available choices.
+ * @see mode_list
+ */
+static void SetFilterMethod( filter_t *p_filter, const char *psz_method )
{
filter_sys_t *p_sys = p_filter->p_sys;
if( !psz_method )
psz_method = "";
+ p_sys->b_double_rate = false;
+ p_sys->b_half_height = false;
+ p_sys->b_use_frame_history = false;
+
if( !strcmp( psz_method, "mean" ) )
{
p_sys->i_mode = DEINTERLACE_MEAN;
- p_sys->b_double_rate = false;
p_sys->b_half_height = true;
- p_sys->b_use_frame_history = false;
}
else if( !strcmp( psz_method, "bob" )
|| !strcmp( psz_method, "progressive-scan" ) )
{
p_sys->i_mode = DEINTERLACE_BOB;
p_sys->b_double_rate = true;
- p_sys->b_half_height = false;
- p_sys->b_use_frame_history = false;
}
else if( !strcmp( psz_method, "linear" ) )
{
p_sys->i_mode = DEINTERLACE_LINEAR;
p_sys->b_double_rate = true;
- p_sys->b_half_height = false;
- p_sys->b_use_frame_history = false;
}
else if( !strcmp( psz_method, "x" ) && p_sys->chroma->pixel_size == 1 )
{
p_sys->i_mode = DEINTERLACE_X;
- p_sys->b_double_rate = false;
- p_sys->b_half_height = false;
- p_sys->b_use_frame_history = false;
}
- else if( !strcmp( psz_method, "yadif" ) && p_sys->chroma->pixel_size == 1 )
+ else if( !strcmp( psz_method, "yadif" ) )
{
p_sys->i_mode = DEINTERLACE_YADIF;
- p_sys->b_double_rate = false;
- p_sys->b_half_height = false;
p_sys->b_use_frame_history = true;
}
- else if( !strcmp( psz_method, "yadif2x" ) && p_sys->chroma->pixel_size == 1 )
+ else if( !strcmp( psz_method, "yadif2x" ) )
{
p_sys->i_mode = DEINTERLACE_YADIF2X;
p_sys->b_double_rate = true;
- p_sys->b_half_height = false;
p_sys->b_use_frame_history = true;
}
else if( !strcmp( psz_method, "phosphor" ) && p_sys->chroma->pixel_size == 1 )
{
p_sys->i_mode = DEINTERLACE_PHOSPHOR;
p_sys->b_double_rate = true;
- p_sys->b_half_height = false;
p_sys->b_use_frame_history = true;
}
else if( !strcmp( psz_method, "ivtc" ) && p_sys->chroma->pixel_size == 1 )
{
p_sys->i_mode = DEINTERLACE_IVTC;
- p_sys->b_double_rate = false;
- p_sys->b_half_height = false;
p_sys->b_use_frame_history = true;
}
else if( !strcmp( psz_method, "discard" ) )
{
p_sys->i_mode = DEINTERLACE_DISCARD;
- p_sys->b_double_rate = false;
p_sys->b_half_height = true;
- p_sys->b_use_frame_history = false;
}
else
{
"no valid/compatible deinterlace mode provided, using \"blend\"" );
p_sys->i_mode = DEINTERLACE_BLEND;
- p_sys->b_double_rate = false;
- p_sys->b_half_height = false;
- p_sys->b_use_frame_history = false;
}
p_sys->i_frame_offset = 0; /* reset to default when method changes */
msg_Dbg( p_filter, "using %s deinterlace method", psz_method );
}
-/*****************************************************************************
- * GetOutputFormat: return which format the chosen algorithm outputs.
- *****************************************************************************/
-
-void GetOutputFormat( filter_t *p_filter,
+/**
+ * Get the output video format of the chosen deinterlace method
+ * for the given input video format.
+ *
+ * Note that each algorithm is allowed to specify its output format,
+ * which may (for some input formats) differ from the input format.
+ *
+ * @param p_filter The filter instance.
+ * @param[out] p_dst Output video format. The structure must be allocated by ca
+ * @param[in] p_src Input video format.
+ * @see SetFilterMethod()
+ */
+static void GetOutputFormat( filter_t *p_filter,
video_format_t *p_dst, const video_format_t *p_src )
{
filter_sys_t *p_sys = p_filter->p_sys;
p_dst->i_sar_den *= 2;
}
+ if( p_sys->b_double_rate )
+ {
+ p_dst->i_frame_rate *= 2;
+ }
+
if( p_sys->i_mode == DEINTERLACE_PHOSPHOR &&
2 * p_sys->chroma->p[1].h.num == p_sys->chroma->p[1].h.den &&
2 * p_sys->chroma->p[2].h.num == p_sys->chroma->p[2].h.den &&
if( !p_sys )
return VLC_ENOMEM;
+ config_ChainParse( p_filter, FILTER_CFG_PREFIX, ppsz_filter_options,
+ p_filter->p_cfg );
+ char *psz_mode = var_InheritString( p_filter, FILTER_CFG_PREFIX "mode" );
+ SetFilterMethod( p_filter, psz_mode );
+ free( psz_mode );
+
p_sys->chroma = chroma;
- p_sys->i_mode = DEINTERLACE_BLEND;
- p_sys->b_double_rate = false;
- p_sys->b_half_height = true;
- p_sys->b_use_frame_history = false;
for( int i = 0; i < METADATA_SIZE; i++ )
{
p_sys->meta.pi_date[i] = VLC_TS_INVALID;
p_sys->pf_merge = MergeAltivec;
else
#endif
-#if defined(CAN_COMPILE_SSE)
- if( (vlc_CPU() & CPU_CAPABILITY_SSE2) )
+#if defined(CAN_COMPILE_SSE2)
+ if( vlc_CPU_SSE2() )
{
p_sys->pf_merge = chroma->pixel_size == 1 ? Merge8BitSSE2 : Merge16BitSSE2;
p_sys->pf_end_merge = EndMMX;
else
#endif
#if defined(CAN_COMPILE_MMXEXT)
- if( chroma->pixel_size == 1 && (vlc_CPU() & CPU_CAPABILITY_MMXEXT) )
+ if( chroma->pixel_size == 1 && vlc_CPU_MMXEXT() )
{
p_sys->pf_merge = MergeMMXEXT;
p_sys->pf_end_merge = EndMMX;
else
#endif
#if defined(CAN_COMPILE_3DNOW)
- if( chroma->pixel_size == 1 && (vlc_CPU() & CPU_CAPABILITY_3DNOW) )
+ if( chroma->pixel_size == 1 && vlc_CPU_3dNOW() )
{
p_sys->pf_merge = Merge3DNow;
p_sys->pf_end_merge = End3DNow;
}
else
#endif
-#if defined __ARM_NEON__ // FIXME: runtime detect support
- if( chroma->pixel_size == 1 && vlc_CPU_ARM_NEON() )
- p_sys->pf_merge = MergeNEON;
+#if defined(CAN_COMPILE_ARM)
+ if( vlc_CPU_ARM_NEON() )
+ p_sys->pf_merge =
+ (chroma->pixel_size == 1) ? merge8_arm_neon : merge16_arm_neon;
+ else
+ if( vlc_CPU_ARMv6() )
+ p_sys->pf_merge =
+ (chroma->pixel_size == 1) ? merge8_armv6 : merge16_armv6;
else
#endif
{
}
/* */
- config_ChainParse( p_filter, FILTER_CFG_PREFIX, ppsz_filter_options,
- p_filter->p_cfg );
-
- char *psz_mode = var_GetNonEmptyString( p_filter, FILTER_CFG_PREFIX "mode" );
- SetFilterMethod( p_filter, psz_mode );
- free( psz_mode );
-
if( p_sys->i_mode == DEINTERLACE_PHOSPHOR )
{
int i_c420 = var_GetInteger( p_filter,