diff libavutil/x86/bswap.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavutil/x86/bswap.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,61 @@
     1.4 +/*
     1.5 + * This file is part of FFmpeg.
     1.6 + *
     1.7 + * FFmpeg is free software; you can redistribute it and/or
     1.8 + * modify it under the terms of the GNU Lesser General Public
     1.9 + * License as published by the Free Software Foundation; either
    1.10 + * version 2.1 of the License, or (at your option) any later version.
    1.11 + *
    1.12 + * FFmpeg is distributed in the hope that it will be useful,
    1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.15 + * Lesser General Public License for more details.
    1.16 + *
    1.17 + * You should have received a copy of the GNU Lesser General Public
    1.18 + * License along with FFmpeg; if not, write to the Free Software
    1.19 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.20 + */
    1.21 +
    1.22 +/**
    1.23 + * @file
    1.24 + * byte swapping routines
    1.25 + */
    1.26 +
    1.27 +#ifndef AVUTIL_X86_BSWAP_H
    1.28 +#define AVUTIL_X86_BSWAP_H
    1.29 +
    1.30 +#include <stdint.h>
    1.31 +#include "config.h"
    1.32 +#include "libavutil/attributes.h"
    1.33 +
    1.34 +#define bswap_16 bswap_16
    1.35 +static av_always_inline av_const uint16_t bswap_16(uint16_t x)
    1.36 +{
    1.37 +    __asm__("rorw $8, %0" : "+r"(x));
    1.38 +    return x;
    1.39 +}
    1.40 +
    1.41 +#define bswap_32 bswap_32
    1.42 +static av_always_inline av_const uint32_t bswap_32(uint32_t x)
    1.43 +{
    1.44 +// #if HAVE_BSWAP
    1.45 +    __asm__("bswap   %0" : "+r" (x));
    1.46 +// #else
    1.47 +//     __asm__("rorw    $8,  %w0 \n\t"
    1.48 +//             "rorl    $16, %0  \n\t"
    1.49 +//             "rorw    $8,  %w0"
    1.50 +//             : "+r"(x));
    1.51 +// #endif
    1.52 +    return x;
    1.53 +}
    1.54 +
    1.55 +#if ARCH_X86_64
    1.56 +#define bswap_64 bswap_64
    1.57 +static inline uint64_t av_const bswap_64(uint64_t x)
    1.58 +{
    1.59 +    __asm__("bswap  %0": "=r" (x) : "0" (x));
    1.60 +    return x;
    1.61 +}
    1.62 +#endif
    1.63 +
    1.64 +#endif /* AVUTIL_X86_BSWAP_H */