Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
13dfce3d
Commit
13dfce3d
authored
13 years ago
by
Vitor Sessak
Committed by
Reinhard Tartler
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Increase alignment of av_malloc() as needed by AVX ASM.
Signed-off-by:
Reinhard Tartler
<
siretart@tauware.de
>
parent
33cbfa6f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavutil/mem.c
+7
-9
7 additions, 9 deletions
libavutil/mem.c
with
7 additions
and
9 deletions
libavutil/mem.c
+
7
−
9
View file @
13dfce3d
...
...
@@ -69,21 +69,21 @@ void *av_malloc(size_t size)
#endif
/* let's disallow possible ambiguous cases */
if
(
size
>
(
INT_MAX
-
16
)
)
if
(
size
>
(
INT_MAX
-
32
)
)
return
NULL
;
#if CONFIG_MEMALIGN_HACK
ptr
=
malloc
(
size
+
16
);
ptr
=
malloc
(
size
+
32
);
if
(
!
ptr
)
return
ptr
;
diff
=
((
-
(
long
)
ptr
-
1
)
&
1
5
)
+
1
;
diff
=
((
-
(
long
)
ptr
-
1
)
&
3
1
)
+
1
;
ptr
=
(
char
*
)
ptr
+
diff
;
((
char
*
)
ptr
)[
-
1
]
=
diff
;
#elif HAVE_POSIX_MEMALIGN
if
(
posix_memalign
(
&
ptr
,
16
,
size
))
if
(
posix_memalign
(
&
ptr
,
32
,
size
))
ptr
=
NULL
;
#elif HAVE_MEMALIGN
ptr
=
memalign
(
16
,
size
);
ptr
=
memalign
(
32
,
size
);
/* Why 64?
Indeed, we should align it:
on 4 for 386
...
...
@@ -93,10 +93,8 @@ void *av_malloc(size_t size)
Because L1 and L2 caches are aligned on those values.
But I don't want to code such logic here!
*/
/* Why 16?
Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs
it will just trigger an exception and the unaligned load will be done in the
exception handler or it will just segfault (SSE2 on P4).
/* Why 32?
For AVX ASM. SSE / NEON needs only 16.
Why not larger? Because I did not see a difference in benchmarks ...
*/
/* benchmarks with P3
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment