9#ifndef BROTLI_ENC_FAST_LOG_H_
10#define BROTLI_ENC_FAST_LOG_H_
16#include "../common/platform.h"
18#if defined(__cplusplus) || defined(c_plusplus)
22static BROTLI_INLINE uint32_t Log2FloorNonZero(
size_t n) {
23#if defined(BROTLI_BSR32)
24 return BROTLI_BSR32((uint32_t)n);
27 while (n >>= 1) result++;
32#define BROTLI_LOG2_TABLE_SIZE 256
36BROTLI_INTERNAL
extern const double kBrotliLog2Table[BROTLI_LOG2_TABLE_SIZE];
40#if !defined(BROTLI_HAVE_LOG2)
41#if ((defined(_MSC_VER) && _MSC_VER <= 1700) || \
42 (defined(__ANDROID_API__) && __ANDROID_API__ < 18))
43#define BROTLI_HAVE_LOG2 0
45#define BROTLI_HAVE_LOG2 1
49#define LOG_2_INV 1.4426950408889634
52static BROTLI_INLINE
double FastLog2(
size_t v) {
53 if (v < BROTLI_LOG2_TABLE_SIZE) {
54 return kBrotliLog2Table[v];
56#if !(BROTLI_HAVE_LOG2)
57 return log((
double)v) * LOG_2_INV;
59 return log2((
double)v);
63#if defined(__cplusplus) || defined(c_plusplus)
Common types used in decoder and encoder API.