/*****************************************************************************
* i420_yuy2.c : YUV to YUV conversion module for vlc
*****************************************************************************
- * Copyright (C) 2000, 2001 the VideoLAN team
+ * Copyright (C) 2000, 2001 VLC authors and VideoLAN
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Damien Fouilleul <damien@videolan.org>
*
- * 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.
*****************************************************************************/
/*****************************************************************************
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
-#include <vlc_vout.h>
+#include <vlc_cpu.h>
#if defined (MODULE_NAME_IS_i420_yuy2_altivec) && defined(HAVE_ALTIVEC_H)
# include <altivec.h>
#if defined (MODULE_NAME_IS_i420_yuy2)
# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv,Y211"
+# define VLC_TARGET
#elif defined (MODULE_NAME_IS_i420_yuy2_mmx)
# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv"
+# define VLC_TARGET VLC_MMX
#elif defined (MODULE_NAME_IS_i420_yuy2_sse2)
# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,IUYV,cyuv"
+# define VLC_TARGET VLC_SSE
#elif defined (MODULE_NAME_IS_i420_yuy2_altivec)
# define DEST_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422"
+# define VLC_TARGET
#endif
/*****************************************************************************
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
-vlc_module_begin();
+vlc_module_begin ()
#if defined (MODULE_NAME_IS_i420_yuy2)
- set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) );
- set_capability( "video filter2", 80 );
+ set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
+ set_capability( "video filter2", 80 )
+# define vlc_CPU_capable() (true)
#elif defined (MODULE_NAME_IS_i420_yuy2_mmx)
- set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) );
- set_capability( "video filter2", 100 );
- add_requirement( MMX );
+ set_description( N_("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) )
+ set_capability( "video filter2", 160 )
+# define vlc_CPU_capable() vlc_CPU_MMX()
#elif defined (MODULE_NAME_IS_i420_yuy2_sse2)
- set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) );
- set_capability( "video filter2", 120 );
- add_requirement( SSE2 );
+ set_description( N_("SSE2 conversions from " SRC_FOURCC " to " DEST_FOURCC) )
+ set_capability( "video filter2", 250 )
+# define vlc_CPU_capable() vlc_CPU_SSE2()
#elif defined (MODULE_NAME_IS_i420_yuy2_altivec)
set_description(
_("AltiVec conversions from " SRC_FOURCC " to " DEST_FOURCC) );
- set_capability( "video filter2", 100 );
- add_requirement( ALTIVEC );
+ set_capability( "video filter2", 250 )
+# define vlc_CPU_capable() vlc_CPU_ALTIVEC()
#endif
- set_callbacks( Activate, NULL );
-vlc_module_end();
+ set_callbacks( Activate, NULL )
+vlc_module_end ()
/*****************************************************************************
* Activate: allocate a chroma function
{
filter_t *p_filter = (filter_t *)p_this;
+ if( !vlc_CPU_capable() )
+ return VLC_EGENERIC;
if( p_filter->fmt_in.video.i_width & 1
|| p_filter->fmt_in.video.i_height & 1 )
{
return -1;
}
+ if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
+ || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height
+ || p_filter->fmt_in.video.orientation != p_filter->fmt_out.video.orientation )
+ return -1;
+
switch( p_filter->fmt_in.video.i_chroma )
{
- case VLC_FOURCC('Y','V','1','2'):
- case VLC_FOURCC('I','4','2','0'):
- case VLC_FOURCC('I','Y','U','V'):
+ case VLC_CODEC_YV12:
+ case VLC_CODEC_I420:
switch( p_filter->fmt_out.video.i_chroma )
{
- case VLC_FOURCC('Y','U','Y','2'):
- case VLC_FOURCC('Y','U','N','V'):
+ case VLC_CODEC_YUYV:
p_filter->pf_video_filter = I420_YUY2_Filter;
break;
- case VLC_FOURCC('Y','V','Y','U'):
+ case VLC_CODEC_YVYU:
p_filter->pf_video_filter = I420_YVYU_Filter;
break;
- case VLC_FOURCC('U','Y','V','Y'):
- case VLC_FOURCC('U','Y','N','V'):
- case VLC_FOURCC('Y','4','2','2'):
+ case VLC_CODEC_UYVY:
p_filter->pf_video_filter = I420_UYVY_Filter;
break;
#if !defined (MODULE_NAME_IS_i420_yuy2_altivec)
p_filter->pf_video_filter = I420_IUYV_Filter;
break;
- case VLC_FOURCC('c','y','u','v'):
+ case VLC_CODEC_CYUV:
p_filter->pf_video_filter = I420_cyuv_Filter;
break;
#endif
#if defined (MODULE_NAME_IS_i420_yuy2)
- case VLC_FOURCC('Y','2','1','1'):
+ case VLC_CODEC_Y211:
p_filter->pf_video_filter = I420_Y211_Filter;
break;
#endif
/*****************************************************************************
* I420_YUY2: planar YUV 4:2:0 to packed YUYV 4:2:2
*****************************************************************************/
+VLC_TARGET
static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
}
}
}
+#warning FIXME: converting widths % 16 but !widths % 32 is broken on altivec
+#if 0
else if( !( ( p_filter->fmt_in.video.i_width % 16 ) |
( p_filter->fmt_in.video.i_height % 4 ) ) )
{
{
/* Line 1 and 2, pixels 0 to ( width - 16 ) */
VEC_NEXT_LINES( );
- for( i_x = p_fiter->fmt_in.video.i_width / 32 ; i_x-- ; )
+ for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
{
VEC_LOAD_UV( );
VEC_MERGE( vec_mergeh );
}
}
}
+#endif
else
{
/* Crap, use the C version */
/*****************************************************************************
* I420_YVYU: planar YUV 4:2:0 to packed YVYU 4:2:2
*****************************************************************************/
+VLC_TARGET
static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
/*****************************************************************************
* I420_UYVY: planar YUV 4:2:0 to packed UYVY 4:2:2
*****************************************************************************/
+VLC_TARGET
static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{
/*****************************************************************************
* I420_cyuv: planar YUV 4:2:0 to upside-down packed UYVY 4:2:2
*****************************************************************************/
+VLC_TARGET
static void I420_cyuv( filter_t *p_filter, picture_t *p_source,
picture_t *p_dest )
{