Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
a257811b
Commit
a257811b
authored
Aug 01, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpu: do not define capabilities on platforms that do not have them
Also update avcodec encoder and switcher x86 checks.
parent
c9be56de
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
100 additions
and
115 deletions
+100
-115
include/vlc_cpu.h
include/vlc_cpu.h
+12
-36
modules/codec/avcodec/avcodec.c
modules/codec/avcodec/avcodec.c
+10
-18
modules/codec/avcodec/encoder.c
modules/codec/avcodec/encoder.c
+20
-9
modules/codec/libmpeg2.c
modules/codec/libmpeg2.c
+8
-16
modules/codec/x264.c
modules/codec/x264.c
+2
-9
modules/stream_out/switcher.c
modules/stream_out/switcher.c
+38
-22
modules/video_filter/postproc.c
modules/video_filter/postproc.c
+5
-2
modules/video_filter/swscale.c
modules/video_filter/swscale.c
+5
-3
No files found.
include/vlc_cpu.h
View file @
a257811b
...
...
@@ -20,13 +20,16 @@
/**
* \file
* This file provides CPU
-specific optimization flags
.
* This file provides CPU
features detection
.
*/
#ifndef VLC_CPU_H
# define VLC_CPU_H 1
VLC_API
unsigned
vlc_CPU
(
void
);
# if defined (__i386__) || defined (__x86_64__)
# define HAVE_FPU 1
# define CPU_CAPABILITY_MMX (1<<3)
# define CPU_CAPABILITY_3DNOW (1<<4)
# define CPU_CAPABILITY_MMXEXT (1<<5)
...
...
@@ -54,41 +57,9 @@
# define VLC_SSE VLC_SSE_is_not_implemented_on_this_compiler
# endif
# else
# define CPU_CAPABILITY_MMX (0)
# define CPU_CAPABILITY_3DNOW (0)
# define CPU_CAPABILITY_MMXEXT (0)
# define CPU_CAPABILITY_SSE (0)
# define CPU_CAPABILITY_SSE2 (0)
# define CPU_CAPABILITY_SSE3 (0)
# define CPU_CAPABILITY_SSSE3 (0)
# define CPU_CAPABILITY_SSE4_1 (0)
# define CPU_CAPABILITY_SSE4_2 (0)
# define CPU_CAPABILITY_SSE4A (0)
# endif
# if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
# define CPU_CAPABILITY_ALTIVEC (1<<16)
# else
# define CPU_CAPABILITY_ALTIVEC (0)
# endif
# if defined (__arm__)
# define CPU_CAPABILITY_NEON (1<<24)
# else
# define CPU_CAPABILITY_NEON (0)
# endif
VLC_API
unsigned
vlc_CPU
(
void
);
/** Are floating point operations fast?
* If this bit is not set, you should try to use fixed-point instead.
*/
# if defined (__i386__) || defined (__x86_64__)
# define HAVE_FPU 1
# elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__)
# elif defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__)
# define HAVE_FPU 1
# define CPU_CAPABILITY_ALTIVEC (1<<16)
# elif defined (__arm__)
# if defined (__VFP_FP__) && !defined (__SOFTFP__)
...
...
@@ -96,14 +67,19 @@ VLC_API unsigned vlc_CPU( void );
# else
# define HAVE_FPU 0
# endif
# define CPU_CAPABILITY_NEON (1<<24)
# elif defined (__sparc__)
# define HAVE_FPU 1
# else
/**
* Are single precision floating point operations "fast"?
* If this preprocessor constant is zero, floating point should be avoided
* (especially relevant for audio codecs).
*/
# define HAVE_FPU 0
# endif
#endif
/* !VLC_CPU_H */
modules/codec/avcodec/avcodec.c
View file @
a257811b
...
...
@@ -329,43 +329,35 @@ static int OpenDecoder( vlc_object_t *p_this )
p_context
->
opaque
=
(
void
*
)
p_this
;
/* Set CPU capabilities */
unsigned
i_cpu
=
vlc_CPU
();
p_context
->
dsp_mask
=
0
;
#if defined (__i386__) || defined (__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMX
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_MMX
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_MMX2
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_3DNOW
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE2
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE2
;
}
#ifdef AV_CPU_FLAG_SSE3
# ifdef AV_CPU_FLAG_SSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE3
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE3
;
#endif
#ifdef AV_CPU_FLAG_SSSE3
#
endif
#
ifdef AV_CPU_FLAG_SSSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSSE3
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSSE3
;
#endif
#ifdef AV_CPU_FLAG_SSE4
#
endif
#
ifdef AV_CPU_FLAG_SSE4
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_1
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE4
;
#endif
#ifdef AV_CPU_FLAG_SSE42
#
endif
#
ifdef AV_CPU_FLAG_SSE42
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_2
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE42
;
# endif
#endif
p_dec
->
b_need_packetized
=
true
;
...
...
modules/codec/avcodec/encoder.c
View file @
a257811b
...
...
@@ -323,25 +323,36 @@ int OpenEncoder( vlc_object_t *p_this )
p_context
->
opaque
=
(
void
*
)
p_this
;
/* Set CPU capabilities */
unsigned
i_cpu
=
vlc_CPU
();
p_context
->
dsp_mask
=
0
;
#if defined (__i386__) || defined (__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMX
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_MMX
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_MMX2
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_3DNOW
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE
)
)
{
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE
;
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE2
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE2
;
}
# ifdef AV_CPU_FLAG_SSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE3
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE3
;
# endif
# ifdef AV_CPU_FLAG_SSSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSSE3
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSSE3
;
# endif
# ifdef AV_CPU_FLAG_SSE4
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_1
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE4
;
# endif
# ifdef AV_CPU_FLAG_SSE42
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_2
)
)
p_context
->
dsp_mask
|=
AV_CPU_FLAG_SSE42
;
# endif
#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"
);
...
...
modules/codec/libmpeg2.c
View file @
a257811b
...
...
@@ -192,35 +192,27 @@ static int OpenDecoder( vlc_object_t *p_this )
p_sys
->
i_gop_user_data
=
0
;
#if defined( __i386__ ) || defined( __x86_64__ )
if
(
vlc_CPU
()
&
CPU_CAPABILITY_MMX
)
{
unsigned
cpu
=
vlc_CPU
();
if
(
cpu
&
CPU_CAPABILITY_MMX
)
i_accel
|=
MPEG2_ACCEL_X86_MMX
;
}
if
(
vlc_CPU
()
&
CPU_CAPABILITY_3DNOW
)
{
if
(
cpu
&
CPU_CAPABILITY_3DNOW
)
i_accel
|=
MPEG2_ACCEL_X86_3DNOW
;
}
if
(
vlc_CPU
()
&
CPU_CAPABILITY_MMXEXT
)
{
if
(
cpu
&
CPU_CAPABILITY_MMXEXT
)
i_accel
|=
MPEG2_ACCEL_X86_MMXEXT
;
}
#elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
if
(
vlc_CPU
()
&
CPU_CAPABILITY_ALTIVEC
)
{
i_accel
|=
MPEG2_ACCEL_PPC_ALTIVEC
;
}
#elif defined(__arm__) && defined(MPEG2_ACCEL_ARM)
#elif defined(__arm__)
# ifdef MPEG2_ACCEL_ARM
i_accel
|=
MPEG2_ACCEL_ARM
;
# endif
# ifdef MPEG2_ACCEL_ARM_NEON
if
(
vlc_CPU
()
&
CPU_CAPABILITY_NEON
)
i_accel
|=
MPEG2_ACCEL_ARM_NEON
;
# endif
/* TODO: sparc */
#else
/* If we do not know this CPU, trust libmpeg2's feature detection */
i_accel
=
MPEG2_ACCEL_DETECT
;
...
...
modules/codec/x264.c
View file @
a257811b
...
...
@@ -1259,24 +1259,17 @@ static int Open ( vlc_object_t *p_this )
x264_param_apply_profile
(
&
p_sys
->
param
,
psz_val
);
free
(
psz_val
);
#if defined (__i386__) || defined (__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMX
)
)
{
p_sys
->
param
.
cpu
&=
~
X264_CPU_MMX
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
)
{
p_sys
->
param
.
cpu
&=
~
X264_CPU_MMXEXT
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE
)
)
{
p_sys
->
param
.
cpu
&=
~
X264_CPU_SSE
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE2
)
)
{
p_sys
->
param
.
cpu
&=
~
X264_CPU_SSE2
;
}
#endif
/* BUILD 29 adds support for multi-threaded encoding while BUILD 49 (r543)
also adds support for threads = 0 for automatically selecting an optimal
...
...
modules/stream_out/switcher.c
View file @
a257811b
...
...
@@ -378,28 +378,36 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
#endif
/* Set CPU capabilities */
unsigned
i_cpu
=
vlc_CPU
();
id
->
ff_enc_c
->
dsp_mask
=
0
;
#if defined (__i386__) || defined (__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMX
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_MMX
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_MMX2
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_3DNOW
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE2
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE2
;
}
# ifdef AV_CPU_FLAG_SSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE3
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE3
;
# endif
# ifdef AV_CPU_FLAG_SSSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSSE3
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSSE3
;
# endif
# ifdef AV_CPU_FLAG_SSE4
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_1
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE4
;
# endif
# ifdef AV_CPU_FLAG_SSE42
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_2
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE42
;
# endif
#endif
id
->
ff_enc_c
->
sample_rate
=
p_fmt
->
audio
.
i_rate
;
id
->
ff_enc_c
->
time_base
.
num
=
1
;
...
...
@@ -791,28 +799,36 @@ static mtime_t VideoCommand( sout_stream_t *p_stream, sout_stream_id_t *id )
#endif
/* Set CPU capabilities */
unsigned
i_cpu
=
vlc_CPU
();
id
->
ff_enc_c
->
dsp_mask
=
0
;
#if defined (__i386__) || defined (__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMX
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_MMX
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_MMX2
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_3DNOW
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE
;
}
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE2
)
)
{
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE2
;
}
# ifdef AV_CPU_FLAG_SSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE3
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE3
;
# endif
# ifdef AV_CPU_FLAG_SSSE3
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSSE3
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSSE3
;
# endif
# ifdef AV_CPU_FLAG_SSE4
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_1
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE4
;
# endif
# ifdef AV_CPU_FLAG_SSE42
if
(
!
(
i_cpu
&
CPU_CAPABILITY_SSE4_2
)
)
id
->
ff_enc_c
->
dsp_mask
|=
AV_CPU_FLAG_SSE42
;
# endif
#endif
id
->
ff_enc_c
->
width
=
p_sys
->
p_pictures
[
p_sys
->
i_cmd
-
1
].
format
.
i_width
;
id
->
ff_enc_c
->
height
=
p_sys
->
p_pictures
[
p_sys
->
i_cmd
-
1
].
format
.
i_height
;
...
...
modules/video_filter/postproc.c
View file @
a257811b
...
...
@@ -122,7 +122,6 @@ static int OpenPostproc( vlc_object_t *p_this )
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
vlc_value_t
val
,
val_orig
,
text
;
unsigned
i_cpu
=
vlc_CPU
();
int
i_flags
=
0
;
if
(
p_filter
->
fmt_in
.
video
.
i_chroma
!=
p_filter
->
fmt_out
.
video
.
i_chroma
||
...
...
@@ -134,14 +133,18 @@ static int OpenPostproc( vlc_object_t *p_this )
}
/* Set CPU capabilities */
#if defined(__i386__) || defined(__x86_64__)
unsigned
i_cpu
=
vlc_CPU
();
if
(
i_cpu
&
CPU_CAPABILITY_MMX
)
i_flags
|=
PP_CPU_CAPS_MMX
;
if
(
i_cpu
&
CPU_CAPABILITY_MMXEXT
)
i_flags
|=
PP_CPU_CAPS_MMX2
;
if
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
i_flags
|=
PP_CPU_CAPS_3DNOW
;
if
(
i_cpu
&
CPU_CAPABILITY_ALTIVEC
)
#elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
if
(
vlc_CPU
()
&
CPU_CAPABILITY_ALTIVEC
)
i_flags
|=
PP_CPU_CAPS_ALTIVEC
;
#endif
switch
(
p_filter
->
fmt_in
.
video
.
i_chroma
)
{
...
...
modules/video_filter/swscale.c
View file @
a257811b
...
...
@@ -229,9 +229,10 @@ static void CloseScaler( vlc_object_t *p_this )
*****************************************************************************/
static
int
GetSwsCpuMask
(
void
)
{
const
unsigned
int
i_cpu
=
vlc_CPU
();
int
i_sws_cpu
=
0
;
#if defined(__i386__) || defined(__x86_64__)
const
unsigned
int
i_cpu
=
vlc_CPU
();
if
(
i_cpu
&
CPU_CAPABILITY_MMX
)
i_sws_cpu
|=
SWS_CPU_CAPS_MMX
;
#if (LIBSWSCALE_VERSION_INT >= ((0<<16)+(5<<8)+0))
...
...
@@ -240,9 +241,10 @@ static int GetSwsCpuMask(void)
#endif
if
(
i_cpu
&
CPU_CAPABILITY_3DNOW
)
i_sws_cpu
|=
SWS_CPU_CAPS_3DNOW
;
if
(
i_cpu
&
CPU_CAPABILITY_ALTIVEC
)
#elif defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__)
if
(
vlc_CPU
()
&
CPU_CAPABILITY_ALTIVEC
)
i_sws_cpu
|=
SWS_CPU_CAPS_ALTIVEC
;
#endif
return
i_sws_cpu
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment