diff options
Diffstat (limited to 'libavcodec/mathops.h')
-rw-r--r-- | libavcodec/mathops.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index 0afc82a0f5..1c35664318 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -3,20 +3,20 @@ * Copyright (c) 2001, 2002 Fabrice Bellard * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef AVCODEC_MATHOPS_H @@ -25,23 +25,21 @@ #include <stdint.h> #include "libavutil/common.h" +#include "libavutil/reverse.h" #include "config.h" #define MAX_NEG_CROP 1024 extern const uint32_t ff_inverse[257]; -extern const uint8_t ff_reverse[256]; extern const uint8_t ff_sqrt_tab[256]; extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP]; extern const uint8_t ff_zigzag_direct[64]; -extern const uint8_t ff_zigzag_scan[16]; +extern const uint8_t ff_zigzag_scan[16+1]; #if ARCH_ARM # include "arm/mathops.h" #elif ARCH_AVR32 # include "avr32/mathops.h" -#elif ARCH_BFIN -# include "bfin/mathops.h" #elif ARCH_MIPS # include "mips/mathops.h" #elif ARCH_PPC @@ -114,6 +112,20 @@ static inline av_const int mid_pred(int a, int b, int c) } #endif +#ifndef median4 +#define median4 median4 +static inline av_const int median4(int a, int b, int c, int d) +{ + if (a < b) { + if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2; + else return (FFMIN(b, c) + FFMAX(a, d)) / 2; + } else { + if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2; + else return (FFMIN(a, c) + FFMAX(b, d)) / 2; + } +} +#endif + #ifndef sign_extend static inline av_const int sign_extend(int val, unsigned bits) { @@ -190,6 +202,8 @@ if ((y) < (x)) {\ # define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32)) #endif /* FASTDIV */ +#ifndef ff_sqrt +#define ff_sqrt ff_sqrt static inline av_const unsigned int ff_sqrt(unsigned int a) { unsigned int b; @@ -209,6 +223,12 @@ static inline av_const unsigned int ff_sqrt(unsigned int a) return b - (a < b * b); } +#endif + +static inline av_const float ff_sqrf(float a) +{ + return a*a; +} static inline int8_t ff_u8_to_s8(uint8_t a) { @@ -220,4 +240,12 @@ static inline int8_t ff_u8_to_s8(uint8_t a) return b.s8; } +static av_always_inline uint32_t bitswap_32(uint32_t x) +{ + return (uint32_t)ff_reverse[ x & 0xFF] << 24 | + (uint32_t)ff_reverse[(x >> 8) & 0xFF] << 16 | + (uint32_t)ff_reverse[(x >> 16) & 0xFF] << 8 | + (uint32_t)ff_reverse[ x >> 24]; +} + #endif /* AVCODEC_MATHOPS_H */ |