[vlc-devel] [PATCH] avcodec: remove the VLC DSP mask

Rémi Denis-Courmont remi at remlab.net
Sat Feb 22 18:34:55 CET 2014


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.
---
 modules/access/Makefile.am       |  2 +-
 modules/codec/Makefile.am        |  1 -
 modules/codec/avcodec/avcodec.c  |  5 ---
 modules/codec/avcodec/avcommon.h |  5 ---
 modules/codec/avcodec/cpu.c      | 93 ----------------------------------------
 modules/codec/avcodec/encoder.c  |  5 ---
 modules/demux/Makefile.am        |  1 -
 7 files changed, 1 insertion(+), 111 deletions(-)
 delete mode 100644 modules/codec/avcodec/cpu.c

diff --git a/modules/access/Makefile.am b/modules/access/Makefile.am
index 8b0fd08..a8677db 100644
--- a/modules/access/Makefile.am
+++ b/modules/access/Makefile.am
@@ -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)
diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am
index 8535bac..e013263 100644
--- a/modules/codec/Makefile.am
+++ b/modules/codec/Makefile.am
@@ -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 \
diff --git a/modules/codec/avcodec/avcodec.c b/modules/codec/avcodec/avcodec.c
index 956c72b..0695257 100644
--- a/modules/codec/avcodec/avcodec.c
+++ b/modules/codec/avcodec/avcodec.c
@@ -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 )
     {
diff --git a/modules/codec/avcodec/avcommon.h b/modules/codec/avcodec/avcommon.h
index 61fc609..8c47330 100644
--- a/modules/codec/avcodec/avcommon.h
+++ b/modules/codec/avcodec/avcommon.h
@@ -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,6 @@ 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
     msg_Dbg(obj, "CPU flags: 0x%08x", av_get_cpu_flags());
 }
 #endif
diff --git a/modules/codec/avcodec/cpu.c b/modules/codec/avcodec/cpu.c
deleted file mode 100644
index 29726c1..0000000
--- a/modules/codec/avcodec/cpu.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*****************************************************************************
- * 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;
-}
diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index aa2435a3..4c10e11 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -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;
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 0cab9eb..f3fe3c6 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -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 \
-- 
1.9.0




More information about the vlc-devel mailing list