1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avutil: remove inline av_log2 from public API

This removes inline av_log2 and av_log2_16bit from the public API,
instead exporting them as regular functions.  In-tree code still
gets the inline and otherwise optimised variants.

Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
Mans Rullgard 2012-10-18 18:15:38 +01:00
parent f0c07be649
commit 8c0a3d5fe0
4 changed files with 89 additions and 40 deletions

View File

@ -69,6 +69,7 @@ OBJS = adler32.o \
lfg.o \
lls.o \
log.o \
log2.o \
log2_tab.o \
lzo.o \
mathematics.o \

View File

@ -62,40 +62,11 @@
#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1))
/* misc math functions */
extern const uint8_t ff_log2_tab[256];
#if FF_API_AV_REVERSE
extern attribute_deprecated const uint8_t av_reverse[256];
#endif
static av_always_inline av_const int av_log2_c(unsigned int v)
{
int n = 0;
if (v & 0xffff0000) {
v >>= 16;
n += 16;
}
if (v & 0xff00) {
v >>= 8;
n += 8;
}
n += ff_log2_tab[v];
return n;
}
static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
{
int n = 0;
if (v & 0xff00) {
v >>= 8;
n += 8;
}
n += ff_log2_tab[v];
return n;
}
#ifdef HAVE_AV_CONFIG_H
# include "config.h"
# include "intmath.h"
@ -104,6 +75,14 @@ static av_always_inline av_const int av_log2_16bit_c(unsigned int v)
/* Pull in unguarded fallback defines at the end of this file. */
#include "common.h"
#ifndef av_log2
av_const int av_log2(unsigned v);
#endif
#ifndef av_log2_16bit
av_const int av_log2_16bit(unsigned v);
#endif
/**
* Clip a signed integer value into the amin-amax range.
* @param a value to clip
@ -385,12 +364,6 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
* to ensure they are immediately available in intmath.h.
*/
#ifndef av_log2
# define av_log2 av_log2_c
#endif
#ifndef av_log2_16bit
# define av_log2_16bit av_log2_16bit_c
#endif
#ifndef av_ceil_log2
# define av_ceil_log2 av_ceil_log2_c
#endif

View File

@ -21,6 +21,8 @@
#ifndef AVUTIL_INTMATH_H
#define AVUTIL_INTMATH_H
#include <stdint.h>
#include "config.h"
#include "attributes.h"
@ -31,15 +33,54 @@
#if HAVE_FAST_CLZ && AV_GCC_VERSION_AT_LEAST(3,4)
#ifndef av_log2
# define av_log2(x) (31 - __builtin_clz((x)|1))
# ifndef av_log2_16bit
# define av_log2_16bit av_log2
#ifndef ff_log2
# define ff_log2(x) (31 - __builtin_clz((x)|1))
# ifndef ff_log2_16bit
# define ff_log2_16bit av_log2
# endif
#endif /* av_log2 */
#endif /* ff_log2 */
#endif /* AV_GCC_VERSION_AT_LEAST(3,4) */
extern const uint8_t ff_log2_tab[256];
#ifndef ff_log2
#define ff_log2 ff_log2_c
static av_always_inline av_const int ff_log2_c(unsigned int v)
{
int n = 0;
if (v & 0xffff0000) {
v >>= 16;
n += 16;
}
if (v & 0xff00) {
v >>= 8;
n += 8;
}
n += ff_log2_tab[v];
return n;
}
#endif
#ifndef ff_log2_16bit
#define ff_log2_16bit ff_log2_16bit_c
static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
{
int n = 0;
if (v & 0xff00) {
v >>= 8;
n += 8;
}
n += ff_log2_tab[v];
return n;
}
#endif
#define av_log2 ff_log2
#define av_log2_16bit ff_log2_16bit
/**
* @}
*/

34
libavutil/log2.c Normal file
View File

@ -0,0 +1,34 @@
/*
* This file is part of Libav.
*
* Libav 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,
* 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
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "intmath.h"
/* undef these to get the function prototypes from common.h */
#undef av_log2
#undef av_log2_16bit
#include "common.h"
int av_log2(unsigned v)
{
return ff_log2(v);
}
int av_log2_16bit(unsigned v)
{
return ff_log2_16bit(v);
}