diff mbox

[FFmpeg-devel,1/2] intreadwrite: add AV_RL64A, AV_WL64A

Message ID 235e43fdd4219e61a5ac3f2ca7b5b3c92e2602ac.1546860888.git.pross@xvid.org
State Accepted
Commit b4e6d1f597a3d299176cebb42f1cf60e891a259a
Headers show

Commit Message

Peter Ross Jan. 7, 2019, 11:40 a.m. UTC
macros for reading and writing 64-bit aligned little-endian values.

these macros are used by the DST decoder and give a performance boost
on big-endian platforms that where the compiler must normally guard
against unaligned memory access.
---
 libavutil/intreadwrite.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Carl Eugen Hoyos Jan. 7, 2019, 11:42 a.m. UTC | #1
2019-01-07 12:40 GMT+01:00, Peter Ross <pross@xvid.org>:
> macros for reading and writing 64-bit aligned little-endian values.
>
> these macros are used by the DST decoder and give a performance boost
> on big-endian platforms that where the compiler must normally guard
> against unaligned memory access.

I thought there is a performance gain on little-endian...

Carl Eugen
Peter Ross Jan. 7, 2019, 11:56 a.m. UTC | #2
On Mon, Jan 07, 2019 at 12:42:24PM +0100, Carl Eugen Hoyos wrote:
> 2019-01-07 12:40 GMT+01:00, Peter Ross <pross@xvid.org>:
> > macros for reading and writing 64-bit aligned little-endian values.
> >
> > these macros are used by the DST decoder and give a performance boost
> > on big-endian platforms that where the compiler must normally guard
> > against unaligned memory access.
> 
> I thought there is a performance gain on little-endian...

true... i will omit 'big-endian' from the comment to make it clearer.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
diff mbox

Patch

diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
index 67c763b135..4c8413a536 100644
--- a/libavutil/intreadwrite.h
+++ b/libavutil/intreadwrite.h
@@ -542,6 +542,21 @@  union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
 #   define AV_WN64A(p, v) AV_WNA(64, p, v)
 #endif
 
+#if AV_HAVE_BIGENDIAN
+#   define AV_RLA(s, p)    av_bswap##s(AV_RN##s##A(p))
+#   define AV_WLA(s, p, v) AV_WN##s##A(p, av_bswap##s(v))
+#else
+#   define AV_RLA(s, p)    AV_RN##s##A(p)
+#   define AV_WLA(s, p, v) AV_WN##s##A(p, v)
+#endif
+
+#ifndef AV_RL64A
+#   define AV_RL64A(p) AV_RLA(64, p)
+#endif
+#ifndef AV_WL64A
+#   define AV_WL64A(p, v) AV_WLA(64, p, v)
+#endif
+
 /*
  * The AV_COPYxxU macros are suitable for copying data to/from unaligned
  * memory locations.