[FFmpeg-cvslog] intreadwrite: Use the __unaligned keyword on MSVC for ARM and x86_64

Martin Storsjö git at videolan.org
Thu Mar 16 02:32:25 EET 2017


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Aug  1 10:04:42 2016 +0300| [f79d847400d218cfd0b95f10358fe6e65ec3c9c4] | committer: Martin Storsjö

intreadwrite: Use the __unaligned keyword on MSVC for ARM and x86_64

AV_WN64 is meant for unaligned data, but the existing av_alias* unions
(without a definition for the av_alias attribute - we don't have one
for MSVC) indicate to the compiler that they would have sufficient
alignment for normal access, i.e. the compiler is free to assume
8 byte alignment.

On ARM, this makes sure that AV_WN64 (or two consecutive AV_WN32) is
done with two str instructions instead of one strd.

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavutil/intreadwrite.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
index 5f65957..32747b2 100644
--- a/libavutil/intreadwrite.h
+++ b/libavutil/intreadwrite.h
@@ -197,6 +197,11 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
 #   define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
 #   define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
 
+#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64)) && AV_HAVE_FAST_UNALIGNED
+
+#   define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
+#   define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
+
 #elif AV_HAVE_FAST_UNALIGNED
 
 #   define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)



More information about the ffmpeg-cvslog mailing list