Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
4b57ea8f
Commit
4b57ea8f
authored
Jun 11, 2024
by
James Almer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avutil/common: assert that bit position in av_zero_extend is valid
Signed-off-by:
James Almer
<
jamrial@gmail.com
>
parent
39c90d64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
common.h
libavutil/common.h
+4
-1
intmath.h
libavutil/x86/intmath.h
+13
-1
No files found.
libavutil/common.h
View file @
4b57ea8f
...
@@ -286,11 +286,14 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
...
@@ -286,11 +286,14 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
/**
/**
* Clear high bits from an unsigned integer starting with specific bit position
* Clear high bits from an unsigned integer starting with specific bit position
* @param a value to clip
* @param a value to clip
* @param p bit position to clip at
* @param p bit position to clip at
. Must be between 0 and 31.
* @return clipped value
* @return clipped value
*/
*/
static
av_always_inline
av_const
unsigned
av_zero_extend_c
(
unsigned
a
,
unsigned
p
)
static
av_always_inline
av_const
unsigned
av_zero_extend_c
(
unsigned
a
,
unsigned
p
)
{
{
#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
if
(
p
>
31
)
abort
();
#endif
return
a
&
((
1U
<<
p
)
-
1
);
return
a
&
((
1U
<<
p
)
-
1
);
}
}
...
...
libavutil/x86/intmath.h
View file @
4b57ea8f
...
@@ -82,7 +82,16 @@ static av_always_inline av_const int ff_ctzll_x86(long long v)
...
@@ -82,7 +82,16 @@ static av_always_inline av_const int ff_ctzll_x86(long long v)
#if defined(__BMI2__)
#if defined(__BMI2__)
#if AV_GCC_VERSION_AT_LEAST(5,1)
#if AV_GCC_VERSION_AT_LEAST(5,1)
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
#define av_zero_extend av_zero_extend_bmi2
static
av_always_inline
av_const
unsigned
av_zero_extend_bmi2
(
unsigned
a
,
unsigned
p
)
{
if
(
p
>
31
)
abort
();
return
__builtin_ia32_bzhi_si
(
a
,
p
);
}
#else
#define av_zero_extend __builtin_ia32_bzhi_si
#define av_zero_extend __builtin_ia32_bzhi_si
#endif
#elif HAVE_INLINE_ASM
#elif HAVE_INLINE_ASM
/* GCC releases before 5.1.0 have a broken bzhi builtin, so for those we
/* GCC releases before 5.1.0 have a broken bzhi builtin, so for those we
* implement it using inline assembly
* implement it using inline assembly
...
@@ -90,8 +99,11 @@ static av_always_inline av_const int ff_ctzll_x86(long long v)
...
@@ -90,8 +99,11 @@ static av_always_inline av_const int ff_ctzll_x86(long long v)
#define av_zero_extend av_zero_extend_bmi2
#define av_zero_extend av_zero_extend_bmi2
static
av_always_inline
av_const
unsigned
av_zero_extend_bmi2
(
unsigned
a
,
unsigned
p
)
static
av_always_inline
av_const
unsigned
av_zero_extend_bmi2
(
unsigned
a
,
unsigned
p
)
{
{
#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
if
(
p
>
31
)
abort
();
#endif
if
(
av_builtin_constant_p
(
p
))
if
(
av_builtin_constant_p
(
p
))
return
a
&
((
1
<<
p
)
-
1
);
return
a
&
((
1
U
<<
p
)
-
1
);
else
{
else
{
unsigned
x
;
unsigned
x
;
__asm__
(
"bzhi %2, %1, %0
\n\t
"
:
"=r"
(
x
)
:
"rm"
(
a
),
"r"
(
p
));
__asm__
(
"bzhi %2, %1, %0
\n\t
"
:
"=r"
(
x
)
:
"rm"
(
a
),
"r"
(
p
));
...
...
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