ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Fri Jun 13 02:50:11 2025 +0200| [dcd7408c9200464bc33293b96f439121af2dd692] | 
committer: Andreas Rheinhardt

avcodec/mpegvideo: Provide alignment hint to compiler

The underlying element type has always a size of 32B,
so that the pointer is always at least 16B aligned.
Clang uses this to upgrade the (inlined) memset to
aligned stores. GCC doesn't (it does it only when
the alignment hint is provided via __builtin_assume_aligned).

Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dcd7408c9200464bc33293b96f439121af2dd692
---

 libavcodec/mpegvideo.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 109afbe858..a27efa8b89 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -504,11 +504,13 @@ void ff_clean_intra_table_entries(MpegEncContext *s)
     dc_val[uxy] =
     dc_val[vxy] = 1024;
     /* ac pred */
-    memset(s->ac_val[0][xy       ], 0, 32 * sizeof(int16_t));
-    memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(int16_t));
+    int16_t (*ac_val)[16] = s->ac_val[0];
+    av_assume(!((uintptr_t)ac_val & 0xF));
+    memset(ac_val[xy       ], 0, 2 * sizeof(*ac_val));
+    memset(ac_val[xy + wrap], 0, 2 * sizeof(*ac_val));
     /* ac pred */
-    memset(s->ac_val[0][uxy], 0, 16 * sizeof(int16_t));
-    memset(s->ac_val[0][vxy], 0, 16 * sizeof(int16_t));
+    memset(ac_val[uxy], 0, sizeof(*ac_val));
+    memset(ac_val[vxy], 0, sizeof(*ac_val));
 }
 
 void ff_init_block_index(MpegEncContext *s){ //FIXME maybe rename

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to