Commit 8512cab6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

avcodec: remove the VLC DSP mask (except on Android on ARM)

libavutil will always check for all CPU features that it understands,
even those VLC masked. Thus masking features provides no savings.

libavutil runs more tests than VLC. Depending on the platform and
operating system combination, libavutil is either as conservative or
more conservative than VLC. As such masking features provides no extra
safety.

So overall, GetVlcDspMask() is useless, at least nowadays.

Android ARM NEON seems controversial so it is kept for now.
parent 93ae604c
......@@ -409,7 +409,7 @@ libaccess_realrtsp_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(accessdir)'
access_LTLIBRARIES += $(LTLIBaccess_realrtsp)
EXTRA_LTLIBRARIES += libaccess_realrtsp_plugin.la
libavio_plugin_la_SOURCES = access/avio.c access/avio.h codec/avcodec/cpu.c
libavio_plugin_la_SOURCES = access/avio.c access/avio.h
libavio_plugin_la_CFLAGS = $(AM_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS)
libavio_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(SYMBOLIC_LDFLAGS)
libavio_plugin_la_LIBADD = $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(LIBM)
......
......@@ -244,7 +244,6 @@ libavcodec_plugin_la_SOURCES = \
codec/avcodec/video.c \
codec/avcodec/subtitle.c \
codec/avcodec/audio.c \
codec/avcodec/cpu.c \
codec/avcodec/fourcc.c \
codec/avcodec/chroma.c codec/avcodec/chroma.h \
codec/avcodec/va.c codec/avcodec/va.h \
......
......@@ -301,11 +301,6 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context->debug = var_InheritInteger( p_dec, "avcodec-debug" );
p_context->opaque = (void *)p_this;
/* set CPU capabilities */
#if !LIBAVUTIL_VERSION_CHECK(51, 25, 0, 42, 100)
p_context->dsp_mask = GetVlcDspMask();
#endif
p_dec->b_need_packetized = true;
switch( i_cat )
{
......
......@@ -36,8 +36,6 @@
#include "avcommon_compat.h"
unsigned GetVlcDspMask(void);
#ifdef HAVE_LIBAVUTIL_AVUTIL_H
# include <libavutil/avutil.h>
# include <libavutil/dict.h>
......@@ -83,9 +81,10 @@ static inline void vlc_init_avutil(vlc_object_t *obj)
av_log_set_level(level);
#if LIBAVUTIL_VERSION_CHECK(51, 25, 0, 42, 100)
av_set_cpu_flags_mask( INT_MAX & ~GetVlcDspMask() );
#endif
# if defined (__arm__) && defined (__ANDROID__)
if (!vlc_CPU_ARM_NEON())
av_set_cpu_flags(AV_CPU_FLAG_NEON);
# endif
msg_Dbg(obj, "CPU flags: 0x%08x", av_get_cpu_flags());
}
#endif
......
/*****************************************************************************
* cpu.c: CPU capabilities for libavcodec
*****************************************************************************
* Copyright (C) 1999-2012 VLC authors and VideoLAN
*
* 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 Lesser General Public License for more details.
*
* 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_cpu.h>
#define HAVE_MMX 1
#include <libavcodec/avcodec.h>
#include "avcommon.h"
/**
* Maps CPU capabilities computed by VLC to libav DSP mask.
*/
unsigned GetVlcDspMask( void )
{
unsigned mask = 0;
#if defined (__i386__) || defined (__x86_64__)
if( !vlc_CPU_MMX() )
mask |= AV_CPU_FLAG_MMX;
if( !vlc_CPU_MMXEXT() )
mask |= AV_CPU_FLAG_MMXEXT;
if( !vlc_CPU_3dNOW() )
mask |= AV_CPU_FLAG_3DNOW;
if( !vlc_CPU_SSE() )
mask |= AV_CPU_FLAG_SSE;
if( !vlc_CPU_SSE2() )
mask |= AV_CPU_FLAG_SSE2;
# ifdef AV_CPU_FLAG_SSE3
if( !vlc_CPU_SSE3() )
mask |= AV_CPU_FLAG_SSE3;
# endif
# ifdef AV_CPU_FLAG_SSSE3
if( !vlc_CPU_SSSE3() )
mask |= AV_CPU_FLAG_SSSE3;
# endif
# ifdef AV_CPU_FLAG_SSE4
if( !vlc_CPU_SSE4_1() )
mask |= AV_CPU_FLAG_SSE4;
# endif
# ifdef AV_CPU_FLAG_SSE42
if( !vlc_CPU_SSE4_2() )
mask |= AV_CPU_FLAG_SSE42;
# endif
# ifdef AV_CPU_FLAG_AVX
if( !vlc_CPU_AVX() )
mask |= AV_CPU_FLAG_AVX;
# endif
# ifdef AV_CPU_FLAG_XOP
if( !vlc_CPU_XOP() )
mask |= AV_CPU_FLAG_XOP;
# endif
# ifdef AV_CPU_FLAG_FMA4
if( !vlc_CPU_FMA4() )
mask |= AV_CPU_FLAG_FMA4;
# endif
#endif
#if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
if( !vlc_CPU_ALTIVEC() )
mask |= AV_CPU_FLAG_ALTIVEC;
#endif
#if defined ( __arm__)
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 29, 0)
if( !vlc_CPU_ARM_NEON() )
mask |= AV_CPU_FLAG_NEON;
#endif
#endif
return mask;
}
......@@ -316,11 +316,6 @@ int OpenEncoder( vlc_object_t *p_this )
p_context->debug = var_InheritInteger( p_enc, "avcodec-debug" );
p_context->opaque = (void *)p_this;
/* set CPU capabilities */
#if !LIBAVUTIL_VERSION_CHECK(51, 25, 0, 42, 100)
p_context->dsp_mask = GetVlcDspMask();
#endif
p_sys->i_key_int = var_GetInteger( p_enc, ENC_CFG_PREFIX "keyint" );
p_sys->i_b_frames = var_GetInteger( p_enc, ENC_CFG_PREFIX "bframes" );
p_sys->i_vtolerance = var_GetInteger( p_enc, ENC_CFG_PREFIX "vt" ) * 1000;
......
......@@ -133,7 +133,6 @@ demux_LTLIBRARIES += libcaf_plugin.la
libavformat_plugin_la_SOURCES = demux/avformat/demux.c \
codec/avcodec/fourcc.c \
codec/avcodec/chroma.c \
codec/avcodec/cpu.c \
codec/avcodec/avcommon.h \
codec/avcodec/avcommon_compat.h \
demux/vobsub.h \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment