[FFmpeg-devel] [PATCH] Make HAVE_FAST_UNALIGNED allow unaligned memory accesses

Måns Rullgård mans
Tue Jul 15 21:23:12 CEST 2008


Mans Rullgard <mans at mansr.com> writes:

> If HAVE_FAST_UNALIGNED is defined, potentially unaligned data is
> accessed through normal pointers.  Otherwise, compiler-specific
> code is used to perform unaligned accesses, falling back to
> byte-wise access if no compiler support is available.
> ---
>  libavutil/intreadwrite.h |  130 +++++++++++++++++++++++++++------------------
>  1 files changed, 78 insertions(+), 52 deletions(-)
>
> diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h
> index cbf5163..12dec54 100644
> --- a/libavutil/intreadwrite.h
> +++ b/libavutil/intreadwrite.h
> @@ -23,6 +23,8 @@
>  #include "config.h"
>  #include "bswap.h"
>
> +#if !defined(HAVE_FAST_UNALIGNED)
> +
>  #ifdef __GNUC__
>
>  struct unaligned_64 { uint64_t l; } __attribute__((packed));
> @@ -37,7 +39,19 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
>  #define AV_WN32(a, b) (((struct unaligned_32 *) (a))->l) = (b)
>  #define AV_WN64(a, b) (((struct unaligned_64 *) (a))->l) = (b)
>
> -#else /* __GNUC__ */
> +#elif defined(__DECC)
> +
> +#define AV_RN16(a) (*((const __unaligned uint16_t*)(a)))

Yes, these ifdefs should be replaced with checks for the required
compiler features in configure.  If we agree to this change, I'll
add such checks, and update the patch.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list