/*****************************************************************************
* swscale.c: scaling and chroma conversion using libswscale
*****************************************************************************
- * Copyright (C) 1999-2008 the VideoLAN team
+ * Copyright (C) 1999-2008 VLC authors and VideoLAN
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Gildas Bazin <gbazin@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_filter.h>
#include <vlc_cpu.h>
-#ifdef HAVE_LIBSWSCALE_SWSCALE_H
-# include <libswscale/swscale.h>
-#elif defined(HAVE_FFMPEG_SWSCALE_H)
-# include <ffmpeg/swscale.h>
+#include <libswscale/swscale.h>
+
+#ifdef __APPLE__
+# include <TargetConditionals.h>
#endif
#include "../codec/avcodec/chroma.h" // Chroma Avutil <-> VLC conversion
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_VFILTER )
set_callbacks( OpenScaler, CloseScaler )
- add_integer( "swscale-mode", 2, NULL, SCALEMODE_TEXT, SCALEMODE_LONGTEXT, true )
- change_integer_list( pi_mode_values, ppsz_mode_descriptions, NULL )
+ add_integer( "swscale-mode", 2, SCALEMODE_TEXT, SCALEMODE_LONGTEXT, true )
+ change_integer_list( pi_mode_values, ppsz_mode_descriptions )
vlc_module_end ()
/* Version checking */
* Local prototypes
****************************************************************************/
-void *( *swscale_fast_memcpy )( void *, const void *, size_t );
-
/**
* Internal swscale filter structure.
*/
if( ( p_filter->p_sys = p_sys = malloc(sizeof(filter_sys_t)) ) == NULL )
return VLC_ENOMEM;
- /* FIXME pointer assignment may not be atomic */
- swscale_fast_memcpy = vlc_memcpy;
-
/* Set CPU capabilities */
p_sys->i_cpu_mask = GetSwsCpuMask();
*****************************************************************************/
static int GetSwsCpuMask(void)
{
- const unsigned int i_cpu = vlc_CPU();
int i_sws_cpu = 0;
- if( i_cpu & CPU_CAPABILITY_MMX )
+#if defined(__i386__) || defined(__x86_64__)
+ if( vlc_CPU_MMX() )
i_sws_cpu |= SWS_CPU_CAPS_MMX;
#if (LIBSWSCALE_VERSION_INT >= ((0<<16)+(5<<8)+0))
- if( i_cpu & CPU_CAPABILITY_MMXEXT )
+ if( vlc_CPU_MMXEXT() )
i_sws_cpu |= SWS_CPU_CAPS_MMX2;
#endif
- if( i_cpu & CPU_CAPABILITY_3DNOW )
+ if( vlc_CPU_3dNOW() )
i_sws_cpu |= SWS_CPU_CAPS_3DNOW;
-
- if( i_cpu & CPU_CAPABILITY_ALTIVEC )
+#elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
+ if( vlc_CPU_ALTIVEC() )
i_sws_cpu |= SWS_CPU_CAPS_ALTIVEC;
+#endif
return i_sws_cpu;
}
bool b_swap_uvi = false;
bool b_swap_uvo = false;
- GetFfmpegChroma( &i_fmti, *p_fmti );
- GetFfmpegChroma( &i_fmto, *p_fmto );
+ GetFfmpegChroma( &i_fmti, p_fmti );
+ GetFfmpegChroma( &i_fmto, p_fmto );
if( p_fmti->i_chroma == p_fmto->i_chroma )
{
FixParameters( &i_fmti, &b_has_ai, &b_swap_uvi, p_fmti->i_chroma );
FixParameters( &i_fmto, &b_has_ao, &b_swap_uvo, p_fmto->i_chroma );
+#if !defined (__ANDROID__) && !defined(TARGET_OS_IPHONE)
/* FIXME TODO removed when ffmpeg is fixed
* Without SWS_ACCURATE_RND the quality is really bad for some conversions */
switch( i_fmto )
i_sws_flags |= SWS_ACCURATE_RND;
break;
}
+#endif
if( p_cfg )
{
{
filter_sys_t *p_sys = p_filter->p_sys;
const video_format_t *p_fmti = &p_filter->fmt_in.video;
- const video_format_t *p_fmto = &p_filter->fmt_out.video;
+ video_format_t *p_fmto = &p_filter->fmt_out.video;
if( IsFmtSimilar( p_fmti, &p_sys->fmt_in ) &&
IsFmtSimilar( p_fmto, &p_sys->fmt_out ) &&
p_sys->p_src_e = picture_New( p_fmti->i_chroma, i_fmti_width, p_fmti->i_height, 0, 1 );
p_sys->p_dst_e = picture_New( p_fmto->i_chroma, i_fmto_width, p_fmto->i_height, 0, 1 );
- memset( p_sys->p_src_e->p[0].p_pixels, 0, p_sys->p_src_e->p[0].i_pitch * p_sys->p_src_e->p[0].i_lines );
- memset( p_sys->p_dst_e->p[0].p_pixels, 0, p_sys->p_dst_e->p[0].i_pitch * p_sys->p_dst_e->p[0].i_lines );
+ if( p_sys->p_src_e )
+ memset( p_sys->p_src_e->p[0].p_pixels, 0, p_sys->p_src_e->p[0].i_pitch * p_sys->p_src_e->p[0].i_lines );
+ if( p_sys->p_dst_e )
+ memset( p_sys->p_dst_e->p[0].p_pixels, 0, p_sys->p_dst_e->p[0].i_pitch * p_sys->p_dst_e->p[0].i_lines );
}
if( !p_sys->ctx ||
p_sys->b_swap_uvi = cfg.b_swap_uvi;
p_sys->b_swap_uvo = cfg.b_swap_uvo;
+ video_format_ScaleCropAr( p_fmto, p_fmti );
#if 0
msg_Dbg( p_filter, "%ix%i chroma: %4.4s -> %ix%i chroma: %4.4s extend by %d",
p_fmti->i_width, p_fmti->i_height, (char *)&p_fmti->i_chroma,