X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fdeinterlace.c;h=4ec8333340263f2b8b58aac34e0be95215aaf830;hb=be378fbc80c384e2541517d6853b59411b7e67de;hp=cb852280437b76273baea039333e32d3323ebe4b;hpb=b7c52465b1500d1c0aacbeb93080f97294ac34d6;p=vlc diff --git a/modules/video_filter/deinterlace.c b/modules/video_filter/deinterlace.c index cb85228043..4ec8333340 100644 --- a/modules/video_filter/deinterlace.c +++ b/modules/video_filter/deinterlace.c @@ -1,7 +1,7 @@ /***************************************************************************** * deinterlace.c : deinterlacer plugin for vlc ***************************************************************************** - * Copyright (C) 2000, 2001, 2002, 2003 VideoLAN + * Copyright (C) 2000, 2001, 2002, 2003 the VideoLAN team * $Id$ * * Author: Sam Hocevar @@ -18,25 +18,29 @@ * * 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., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include /* malloc(), free() */ -#include -#include -#include -#include -#include "vlc_filter.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #ifdef HAVE_ALTIVEC_H # include #endif +#include +#include +#include +#include +#include "vlc_filter.h" + #ifdef CAN_COMPILE_MMXEXT # include "mmx.h" #endif @@ -65,14 +69,17 @@ static void RenderBob ( vout_thread_t *, picture_t *, picture_t *, int ); static void RenderMean ( vout_thread_t *, picture_t *, picture_t * ); static void RenderBlend ( vout_thread_t *, picture_t *, picture_t * ); static void RenderLinear ( vout_thread_t *, picture_t *, picture_t *, int ); -static void RenderX ( vout_thread_t *, picture_t *, picture_t * ); +static void RenderX ( picture_t *, picture_t * ); static void MergeGeneric ( void *, const void *, const void *, size_t ); #if defined(CAN_COMPILE_C_ALTIVEC) static void MergeAltivec ( void *, const void *, const void *, size_t ); #endif #if defined(CAN_COMPILE_MMXEXT) -static void MergeMMX ( void *, const void *, const void *, size_t ); +static void MergeMMXEXT ( void *, const void *, const void *, size_t ); +#endif +#if defined(CAN_COMPILE_3DNOW) +static void Merge3DNow ( void *, const void *, const void *, size_t ); #endif #if defined(CAN_COMPILE_SSE) static void MergeSSE2 ( void *, const void *, const void *, size_t ); @@ -80,6 +87,9 @@ static void MergeSSE2 ( void *, const void *, const void *, size_t ); #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE) static void EndMMX ( void ); #endif +#if defined(CAN_COMPILE_3DNOW) +static void End3DNow ( void ); +#endif static int SendEvents ( vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void * ); @@ -100,23 +110,28 @@ static int FilterCallback ( vlc_object_t *, char const *, * Module descriptor *****************************************************************************/ #define MODE_TEXT N_("Deinterlace mode") -#define MODE_LONGTEXT N_("You can choose the default 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.") #define FILTER_CFG_PREFIX "sout-deinterlace-" -static char *mode_list[] = { "discard", "blend", "mean", "bob", "linear", "x" }; -static char *mode_list_text[] = { N_("Discard"), N_("Blend"), N_("Mean"), - N_("Bob"), N_("Linear"), "X" }; +static const char *const mode_list[] = { + "discard", "blend", "mean", "bob", "linear", "x" }; +static const char *const mode_list_text[] = { + N_("Discard"), N_("Blend"), N_("Mean"), N_("Bob"), N_("Linear"), "X" }; vlc_module_begin(); - set_description( _("Deinterlacing video filter") ); + set_description( N_("Deinterlacing video filter") ); set_shortname( N_("Deinterlace" )); set_capability( "video filter", 0 ); set_category( CAT_VIDEO ); set_subcategory( SUBCAT_VIDEO_VFILTER ); + set_section( N_("Display"),NULL); add_string( "deinterlace-mode", "discard", NULL, MODE_TEXT, - MODE_LONGTEXT, VLC_FALSE ); + MODE_LONGTEXT, false ); change_string_list( mode_list, mode_list_text, 0 ); add_shortcut( "deinterlace" ); @@ -124,13 +139,14 @@ vlc_module_begin(); add_submodule(); set_capability( "video filter2", 0 ); - add_string( FILTER_CFG_PREFIX "mode", "blend", NULL, MODE_TEXT, - MODE_LONGTEXT, VLC_FALSE ); + set_section( N_("Streaming"),NULL); + add_string( FILTER_CFG_PREFIX "mode", "blend", NULL, SOUT_MODE_TEXT, + SOUT_MODE_LONGTEXT, false ); change_string_list( mode_list, mode_list_text, 0 ); set_callbacks( OpenFilter, CloseFilter ); vlc_module_end(); -static const char *ppsz_filter_options[] = { +static const char *const ppsz_filter_options[] = { "mode", NULL }; @@ -143,7 +159,7 @@ static const char *ppsz_filter_options[] = { struct vout_sys_t { int i_mode; /* Deinterlace mode */ - vlc_bool_t b_double_rate; /* Shall we double the framerate? */ + bool b_double_rate; /* Shall we double the framerate? */ mtime_t last_date; mtime_t next_date; @@ -177,10 +193,7 @@ static int Create( vlc_object_t *p_this ) /* Allocate structure */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) - { - msg_Err( p_vout, "out of memory" ); return VLC_ENOMEM; - } p_vout->pf_init = Init; p_vout->pf_end = End; @@ -190,13 +203,13 @@ static int Create( vlc_object_t *p_this ) p_vout->pf_control = Control; p_vout->p_sys->i_mode = DEINTERLACE_DISCARD; - p_vout->p_sys->b_double_rate = 0; + p_vout->p_sys->b_double_rate = false; p_vout->p_sys->last_date = 0; p_vout->p_sys->p_vout = 0; - vlc_mutex_init( p_vout, &p_vout->p_sys->filter_lock ); + vlc_mutex_init( &p_vout->p_sys->filter_lock ); #if defined(CAN_COMPILE_C_ALTIVEC) - if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_ALTIVEC ) + if( vlc_CPU() & CPU_CAPABILITY_ALTIVEC ) { p_vout->p_sys->pf_merge = MergeAltivec; p_vout->p_sys->pf_end_merge = NULL; @@ -204,7 +217,7 @@ static int Create( vlc_object_t *p_this ) else #endif #if defined(CAN_COMPILE_SSE) - if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_SSE2 ) + if( vlc_CPU() & CPU_CAPABILITY_SSE2 ) { p_vout->p_sys->pf_merge = MergeSSE2; p_vout->p_sys->pf_end_merge = EndMMX; @@ -212,12 +225,20 @@ static int Create( vlc_object_t *p_this ) else #endif #if defined(CAN_COMPILE_MMXEXT) - if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_MMX ) + if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) { - p_vout->p_sys->pf_merge = MergeMMX; + p_vout->p_sys->pf_merge = MergeMMXEXT; p_vout->p_sys->pf_end_merge = EndMMX; } else +#endif +#if defined(CAN_COMPILE_3DNOW) + if( vlc_CPU() & CPU_CAPABILITY_3DNOW ) + { + p_vout->p_sys->pf_merge = Merge3DNow; + p_vout->p_sys->pf_end_merge = End3DNow; + } + else #endif { p_vout->p_sys->pf_merge = MergeGeneric; @@ -253,35 +274,35 @@ static void SetFilterMethod( vout_thread_t *p_vout, char *psz_method ) if( !strcmp( psz_method, "discard" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_DISCARD; - p_vout->p_sys->b_double_rate = 0; + p_vout->p_sys->b_double_rate = false; } else if( !strcmp( psz_method, "mean" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_MEAN; - p_vout->p_sys->b_double_rate = 0; + p_vout->p_sys->b_double_rate = false; } else if( !strcmp( psz_method, "blend" ) || !strcmp( psz_method, "average" ) || !strcmp( psz_method, "combine-fields" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_BLEND; - p_vout->p_sys->b_double_rate = 0; + p_vout->p_sys->b_double_rate = false; } else if( !strcmp( psz_method, "bob" ) || !strcmp( psz_method, "progressive-scan" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_BOB; - p_vout->p_sys->b_double_rate = 1; + p_vout->p_sys->b_double_rate = true; } else if( !strcmp( psz_method, "linear" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_LINEAR; - p_vout->p_sys->b_double_rate = 1; + p_vout->p_sys->b_double_rate = true; } else if( !strcmp( psz_method, "x" ) ) { p_vout->p_sys->i_mode = DEINTERLACE_X; - p_vout->p_sys->b_double_rate = 0; + p_vout->p_sys->b_double_rate = false; } else { @@ -314,6 +335,7 @@ static int Init( vout_thread_t *p_vout ) p_vout->output.i_width = p_vout->render.i_width; p_vout->output.i_height = p_vout->render.i_height; p_vout->output.i_aspect = p_vout->render.i_aspect; + p_vout->fmt_out = p_vout->fmt_in; break; default: @@ -349,17 +371,12 @@ static int Init( vout_thread_t *p_vout ) static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout ) { vout_thread_t *p_real_vout = NULL; - video_format_t fmt = {0}; + video_format_t fmt; + memset( &fmt, 0, sizeof( video_format_t ) ); msg_Dbg( p_vout, "spawning the real video output" ); - fmt.i_width = fmt.i_visible_width = p_vout->output.i_width; - fmt.i_height = fmt.i_visible_height = p_vout->output.i_height; - fmt.i_x_offset = fmt.i_y_offset = 0; - fmt.i_chroma = p_vout->output.i_chroma; - fmt.i_aspect = p_vout->output.i_aspect; - fmt.i_sar_num = p_vout->output.i_aspect * fmt.i_height / fmt.i_width; - fmt.i_sar_den = VOUT_ASPECT_FACTOR; + fmt = p_vout->fmt_out; switch( p_vout->render.i_chroma ) { @@ -370,7 +387,8 @@ static vout_thread_t *SpawnRealVout( vout_thread_t *p_vout ) { case DEINTERLACE_MEAN: case DEINTERLACE_DISCARD: - fmt.i_height = fmt.i_visible_height = p_vout->output.i_height / 2; + fmt.i_height /= 2; fmt.i_visible_height /= 2; fmt.i_y_offset /= 2; + fmt.i_sar_den *= 2; p_real_vout = vout_Create( p_vout, &fmt ); break; @@ -402,6 +420,11 @@ static void End( vout_thread_t *p_vout ) { int i_index; + DEL_PARENT_CALLBACKS( SendEventsToChild ); + + if( p_vout->p_sys->p_vout ) + DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents ); + /* Free the fake output buffers we allocated */ for( i_index = I_OUTPUTPICTURES ; i_index ; ) { @@ -410,13 +433,7 @@ static void End( vout_thread_t *p_vout ) } if( p_vout->p_sys->p_vout ) - { - DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents ); - vlc_object_detach( p_vout->p_sys->p_vout ); - vout_Destroy( p_vout->p_sys->p_vout ); - } - - DEL_PARENT_CALLBACKS( SendEventsToChild ); + vout_CloseAndRelease( p_vout->p_sys->p_vout ); } /***************************************************************************** @@ -440,22 +457,41 @@ static void Destroy( vlc_object_t *p_this ) *****************************************************************************/ static void Render ( vout_thread_t *p_vout, picture_t *p_pic ) { + vout_sys_t *p_sys = p_vout->p_sys; picture_t *pp_outpic[2]; + p_vout->fmt_out.i_x_offset = p_sys->p_vout->fmt_in.i_x_offset = + p_vout->fmt_in.i_x_offset; + p_vout->fmt_out.i_y_offset = p_sys->p_vout->fmt_in.i_y_offset = + p_vout->fmt_in.i_y_offset; + p_vout->fmt_out.i_visible_width = p_sys->p_vout->fmt_in.i_visible_width = + p_vout->fmt_in.i_visible_width; + p_vout->fmt_out.i_visible_height = p_sys->p_vout->fmt_in.i_visible_height = + p_vout->fmt_in.i_visible_height; + if( p_vout->p_sys->i_mode == DEINTERLACE_MEAN || + p_vout->p_sys->i_mode == DEINTERLACE_DISCARD ) + { + p_vout->fmt_out.i_y_offset /= 2; p_sys->p_vout->fmt_in.i_y_offset /= 2; + p_vout->fmt_out.i_visible_height /= 2; + p_sys->p_vout->fmt_in.i_visible_height /= 2; + } + + pp_outpic[0] = pp_outpic[1] = NULL; + vlc_mutex_lock( &p_vout->p_sys->filter_lock ); /* Get a new picture */ while( ( pp_outpic[0] = vout_CreatePicture( p_vout->p_sys->p_vout, - 0, 0, 0 ) ) + 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vlc_mutex_unlock( &p_vout->p_sys->filter_lock ); return; } msleep( VOUT_OUTMEM_SLEEP ); - } + } vout_DatePicture( p_vout->p_sys->p_vout, pp_outpic[0], p_pic->date ); @@ -466,7 +502,7 @@ static void Render ( vout_thread_t *p_vout, picture_t *p_pic ) 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->p_vout, pp_outpic[0] ); vlc_mutex_unlock( &p_vout->p_sys->filter_lock ); @@ -497,16 +533,16 @@ static void Render ( vout_thread_t *p_vout, picture_t *p_pic ) break; case DEINTERLACE_BOB: - RenderBob( p_vout, pp_outpic[0], p_pic, 0 ); + RenderBob( p_vout, pp_outpic[0], p_pic, p_pic->b_top_field_first ? 0 : 1 ); vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] ); - RenderBob( p_vout, pp_outpic[1], p_pic, 1 ); + RenderBob( p_vout, pp_outpic[1], p_pic, p_pic->b_top_field_first ? 1 : 0 ); vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] ); break; case DEINTERLACE_LINEAR: - RenderLinear( p_vout, pp_outpic[0], p_pic, 0 ); + RenderLinear( p_vout, pp_outpic[0], p_pic, p_pic->b_top_field_first ? 0 : 1 ); vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] ); - RenderLinear( p_vout, pp_outpic[1], p_pic, 1 ); + RenderLinear( p_vout, pp_outpic[1], p_pic, p_pic->b_top_field_first ? 1 : 0 ); vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[1] ); break; @@ -521,7 +557,7 @@ static void Render ( vout_thread_t *p_vout, picture_t *p_pic ) break; case DEINTERLACE_X: - RenderX( p_vout, pp_outpic[0], p_pic ); + RenderX( pp_outpic[0], p_pic ); vout_DisplayPicture( p_vout->p_sys->p_vout, pp_outpic[0] ); break; } @@ -557,10 +593,9 @@ static void RenderDiscard( vout_thread_t *p_vout, for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += 2 * p_pic->p[i_plane].i_pitch; } break; @@ -573,12 +608,10 @@ static void RenderDiscard( vout_thread_t *p_vout, { for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; p_in += i_increment; } } @@ -586,9 +619,8 @@ static void RenderDiscard( vout_thread_t *p_vout, { for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; p_in += i_increment; } } @@ -626,38 +658,33 @@ static void RenderBob( vout_thread_t *p_vout, /* For BOTTOM field we need to add the first line */ if( i_field == 1 ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } p_out_end -= 2 * p_outpic->p[i_plane].i_pitch; for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); p_in += 2 * p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); /* For TOP field we need to add the last line */ if( i_field == 0 ) { p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); } break; @@ -665,10 +692,9 @@ static void RenderBob( vout_thread_t *p_vout, /* For BOTTOM field we need to add the first line */ if( i_field == 1 ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } p_out_end -= 2 * p_outpic->p[i_plane].i_pitch; @@ -677,40 +703,35 @@ static void RenderBob( vout_thread_t *p_vout, { for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); p_in += 2 * p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } } else { for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += 2 * p_pic->p[i_plane].i_pitch; } } - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); /* For TOP field we need to add the last line */ if( i_field == 0 ) { p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); } break; } @@ -741,38 +762,34 @@ static void RenderLinear( vout_thread_t *p_vout, /* For BOTTOM field we need to add the first line */ if( i_field == 1 ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } p_out_end -= 2 * p_outpic->p[i_plane].i_pitch; for( ; p_out < p_out_end ; ) { - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; Merge( p_out, p_in, p_in + 2 * p_pic->p[i_plane].i_pitch, p_pic->p[i_plane].i_pitch ); p_in += 2 * p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; } - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); /* For TOP field we need to add the last line */ if( i_field == 0 ) { p_in += p_pic->p[i_plane].i_pitch; - p_out += p_pic->p[i_plane].i_pitch; - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); } } EndMerge(); @@ -800,7 +817,7 @@ static void RenderMean( vout_thread_t *p_vout, Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += 2 * p_pic->p[i_plane].i_pitch; } } @@ -829,9 +846,8 @@ static void RenderBlend( vout_thread_t *p_vout, case VLC_FOURCC('I','Y','U','V'): case VLC_FOURCC('Y','V','1','2'): /* First line: simple copy */ - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; /* Remaining lines: mean value */ for( ; p_out < p_out_end ; ) @@ -839,16 +855,15 @@ static void RenderBlend( vout_thread_t *p_vout, Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += p_pic->p[i_plane].i_pitch; } break; case VLC_FOURCC('I','4','2','2'): /* First line: simple copy */ - p_vout->p_vlc->pf_memcpy( p_out, p_in, - p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + vlc_memcpy( p_out, p_in, p_pic->p[i_plane].i_pitch ); + p_out += p_outpic->p[i_plane].i_pitch; /* Remaining lines: mean value */ if( i_plane == Y_PLANE ) @@ -858,7 +873,7 @@ static void RenderBlend( vout_thread_t *p_vout, Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += p_pic->p[i_plane].i_pitch; } } @@ -870,7 +885,7 @@ static void RenderBlend( vout_thread_t *p_vout, Merge( p_out, p_in, p_in + p_pic->p[i_plane].i_pitch, p_pic->p[i_plane].i_pitch ); - p_out += p_pic->p[i_plane].i_pitch; + p_out += p_outpic->p[i_plane].i_pitch; p_in += 2*p_pic->p[i_plane].i_pitch; } } @@ -911,8 +926,8 @@ static void MergeGeneric( void *_p_dest, const void *_p_s1, } #if defined(CAN_COMPILE_MMXEXT) -static void MergeMMX( void *_p_dest, const void *_p_s1, const void *_p_s2, - size_t i_bytes ) +static void MergeMMXEXT( void *_p_dest, const void *_p_s1, const void *_p_s2, + size_t i_bytes ) { uint8_t* p_dest = (uint8_t*)_p_dest; const uint8_t *p_s1 = (const uint8_t *)_p_s1; @@ -939,6 +954,35 @@ static void MergeMMX( void *_p_dest, const void *_p_s1, const void *_p_s2, } #endif +#if defined(CAN_COMPILE_3DNOW) +static void Merge3DNow( void *_p_dest, const void *_p_s1, const void *_p_s2, + size_t i_bytes ) +{ + uint8_t* p_dest = (uint8_t*)_p_dest; + const uint8_t *p_s1 = (const uint8_t *)_p_s1; + const uint8_t *p_s2 = (const uint8_t *)_p_s2; + uint8_t* p_end = p_dest + i_bytes - 8; + while( p_dest < p_end ) + { + __asm__ __volatile__( "movq %2,%%mm1;" + "pavgusb %1, %%mm1;" + "movq %%mm1, %0" :"=m" (*p_dest): + "m" (*p_s1), + "m" (*p_s2) ); + p_dest += 8; + p_s1 += 8; + p_s2 += 8; + } + + p_end += 8; + + while( p_dest < p_end ) + { + *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1; + } +} +#endif + #if defined(CAN_COMPILE_SSE) static void MergeSSE2( void *_p_dest, const void *_p_s1, const void *_p_s2, size_t i_bytes ) @@ -947,10 +991,10 @@ static void MergeSSE2( void *_p_dest, const void *_p_s1, const void *_p_s2, const uint8_t *p_s1 = (const uint8_t *)_p_s1; const uint8_t *p_s2 = (const uint8_t *)_p_s2; uint8_t* p_end; - while( (int)p_s1 % 16 ) + while( (uintptr_t)p_s1 % 16 ) { *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1; - } + } p_end = p_dest + i_bytes - 16; while( p_dest < p_end ) { @@ -980,6 +1024,13 @@ static void EndMMX( void ) } #endif +#if defined(CAN_COMPILE_3DNOW) +static void End3DNow( void ) +{ + __asm__ __volatile__( "femms" :: ); +} +#endif + #ifdef CAN_COMPILE_C_ALTIVEC static void MergeAltivec( void *_p_dest, const void *_p_s1, const void *_p_s2, size_t i_bytes ) @@ -1095,7 +1146,7 @@ static inline int XDeint8x8DetectC( uint8_t *src, int i_src ) src += 2*i_src; } - return fc < 1 ? VLC_FALSE : VLC_TRUE; + return fc < 1 ? false : true; } #ifdef CAN_COMPILE_MMXEXT static inline int XDeint8x8DetectMMXEXT( uint8_t *src, int i_src ) @@ -1212,7 +1263,7 @@ static inline void XDeint8x8MergeMMXEXT( uint8_t *dst, int i_dst, uint8_t *src1, int i_src1, uint8_t *src2, int i_src2 ) { - static const uint64_t m_4 = I64C(0x0004000400040004); + static const uint64_t m_4 = INT64_C(0x0004000400040004); int y, x; /* Progressive */ @@ -1648,7 +1699,7 @@ static inline void XDeint8x8FieldMotion( uint8_t *dst, int i_dst, #if 0 /* Kernel interpolation (1,-5,20,20,-5,1) - * Loose a bit more details+add aliasing than edge interpol but avoid + * Lose a bit more details+add aliasing than edge interpol but avoid * more artifacts */ static inline uint8_t clip1( int a ) @@ -1717,7 +1768,7 @@ static inline int XDeintNxNDetect( uint8_t *src, int i_src, fc++; } - return fc < 2 ? VLC_FALSE : VLC_TRUE; + return fc < 2 ? false : true; } static inline void XDeintNxNFrame( uint8_t *dst, int i_dst, @@ -1869,10 +1920,8 @@ static inline void XDeintBand8x8MMXEXT( uint8_t *dst, int i_dst, } #endif -static void RenderX( vout_thread_t *p_vout, - picture_t *p_outpic, picture_t *p_pic ) +static void RenderX( picture_t *p_outpic, picture_t *p_pic ) { - vout_sys_t *p_sys = p_vout->p_sys; int i_plane; /* Copy image and skip lines */ @@ -1895,7 +1944,7 @@ static void RenderX( vout_thread_t *p_vout, uint8_t *src = &p_pic->p[i_plane].p_pixels[8*y*i_src]; #ifdef CAN_COMPILE_MMXEXT - if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT ) + if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) XDeintBand8x8MMXEXT( dst, i_dst, src, i_src, i_mbx, i_modx ); else #endif @@ -1922,7 +1971,7 @@ static void RenderX( vout_thread_t *p_vout, } #ifdef CAN_COMPILE_MMXEXT - if( p_vout->p_libvlc->i_cpu & CPU_CAPABILITY_MMXEXT ) + if( vlc_CPU() & CPU_CAPABILITY_MMXEXT ) emms(); #endif } @@ -1933,6 +1982,7 @@ static void RenderX( vout_thread_t *p_vout, static int SendEvents( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *_p_vout ) { + VLC_UNUSED(p_this); VLC_UNUSED(oldval); vout_thread_t *p_vout = (vout_thread_t *)_p_vout; vlc_value_t sentval = newval; @@ -1959,6 +2009,7 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { + VLC_UNUSED(psz_cmd); VLC_UNUSED(p_data); VLC_UNUSED(oldval); vout_thread_t * p_vout = (vout_thread_t *)p_this; int i_old_mode = p_vout->p_sys->i_mode; @@ -2009,11 +2060,11 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd, } /* We need to kill the old vout */ - - DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents ); - - vlc_object_detach( p_vout->p_sys->p_vout ); - vout_Destroy( p_vout->p_sys->p_vout ); + if( p_vout->p_sys->p_vout ) + { + DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents ); + vout_CloseAndRelease( p_vout->p_sys->p_vout ); + } /* Try to open a new video output */ p_vout->p_sys->p_vout = SpawnRealVout( p_vout ); @@ -2039,6 +2090,7 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd, static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { + VLC_UNUSED(p_data); VLC_UNUSED(oldval); vout_thread_t *p_vout = (vout_thread_t *)p_this; var_Set( p_vout->p_sys->p_vout, psz_var, newval ); return VLC_SUCCESS; @@ -2054,12 +2106,9 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) picture_t *p_pic_dst; /* Request output picture */ - p_pic_dst = p_filter->pf_vout_buffer_new( p_filter ); + p_pic_dst = filter_NewPicture( p_filter ); if( p_pic_dst == NULL ) - { - msg_Warn( p_filter, "can't get output picture" ); - return NULL; - } + return p_pic; switch( p_vout->p_sys->i_mode ) { @@ -2068,7 +2117,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) RenderDiscard( p_vout, p_pic_dst, p_pic, 0 ); #endif msg_Err( p_vout, "discarding lines is not supported yet" ); - p_pic_dst->pf_release( p_pic_dst ); + picture_Release( p_pic_dst ); return p_pic; break; @@ -2085,7 +2134,7 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) RenderLinear( p_vout, pp_outpic[1], p_pic, 1 ); #endif msg_Err( p_vout, "doubling the frame rate is not supported yet" ); - p_pic_dst->pf_release( p_pic_dst ); + picture_Release( p_pic_dst ); return p_pic; break; @@ -2098,17 +2147,14 @@ static picture_t *Deinterlace( filter_t *p_filter, picture_t *p_pic ) break; case DEINTERLACE_X: - RenderX( p_vout, p_pic_dst, p_pic ); + RenderX( p_pic_dst, p_pic ); break; } - p_pic_dst->date = p_pic->date; - p_pic_dst->b_force = p_pic->b_force; - p_pic_dst->i_nb_fields = p_pic->i_nb_fields; - p_pic_dst->b_progressive = VLC_TRUE; - p_pic_dst->b_top_field_first = p_pic->b_top_field_first; + picture_CopyProperties( p_pic_dst, p_pic ); + p_pic_dst->b_progressive = true; - p_pic->pf_release( p_pic ); + picture_Release( p_pic ); return p_pic_dst; } @@ -2136,7 +2182,7 @@ static int OpenFilter( vlc_object_t *p_this ) p_filter->p_sys = (filter_sys_t *)p_vout; p_vout->render.i_chroma = p_filter->fmt_in.video.i_chroma; - sout_CfgParse( p_filter, FILTER_CFG_PREFIX, ppsz_filter_options, + config_ChainParse( p_filter, FILTER_CFG_PREFIX, ppsz_filter_options, p_filter->p_cfg ); var_Get( p_filter, FILTER_CFG_PREFIX "mode", &val ); var_Create( p_filter, "deinterlace-mode", VLC_VAR_STRING );