2 * Copyright (c) 2010 Mans Rullgard <mans@mansr.com>
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVUTIL_INTMATH_H
22 #define AVUTIL_INTMATH_H
27 #include "attributes.h"
30 # include "arm/intmath.h"
34 * @addtogroup lavu_internal
39 # include "arm/intmath.h"
42 #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
45 # define ff_log2(x) (31 - __builtin_clz((x)|1))
46 # ifndef ff_log2_16bit
47 # define ff_log2_16bit av_log2
51 #endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
53 extern const uint8_t ff_log2_tab[256];
56 #define ff_log2 ff_log2_c
57 static av_always_inline av_const int ff_log2_c(unsigned int v)
75 #define ff_log2_16bit ff_log2_16bit_c
76 static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
89 #define av_log2 ff_log2
90 #define av_log2_16bit ff_log2_16bit
97 * @addtogroup lavu_math
101 #if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
103 #define ff_ctz(v) __builtin_ctz(v)
108 #define ff_ctz ff_ctz_c
109 static av_always_inline av_const int ff_ctz_c(int v)
140 * Trailing zero bit count.
142 * @param v input value. If v is 0, the result is undefined.
143 * @return the number of trailing 0-bits
150 #endif /* AVUTIL_INTMATH_H */