mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Add kvz_math.h for common inline math functions
Calling it just math.h would have prevented including system math.h.
This commit is contained in:
parent
f8edf28161
commit
e27ec2cc53
|
@ -211,6 +211,7 @@
|
||||||
<ClCompile Include="..\..\src\transform.c" />
|
<ClCompile Include="..\..\src\transform.c" />
|
||||||
<ClInclude Include="..\..\src\input_frame_buffer.h" />
|
<ClInclude Include="..\..\src\input_frame_buffer.h" />
|
||||||
<ClInclude Include="..\..\src\kvazaar_internal.h" />
|
<ClInclude Include="..\..\src\kvazaar_internal.h" />
|
||||||
|
<ClInclude Include="..\..\src\kvz_math.h" />
|
||||||
<ClInclude Include="..\..\src\search_inter.h" />
|
<ClInclude Include="..\..\src\search_inter.h" />
|
||||||
<ClInclude Include="..\..\src\search_intra.h" />
|
<ClInclude Include="..\..\src\search_intra.h" />
|
||||||
<ClInclude Include="..\..\src\strategies\avx2\intra-avx2.h" />
|
<ClInclude Include="..\..\src\strategies\avx2\intra-avx2.h" />
|
||||||
|
|
|
@ -382,6 +382,7 @@
|
||||||
<ClInclude Include="..\..\src\encoder_state-bitstream.h">
|
<ClInclude Include="..\..\src\encoder_state-bitstream.h">
|
||||||
<Filter>Bitstream</Filter>
|
<Filter>Bitstream</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\kvz_math.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<YASM Include="..\..\src\extras\x86inc.asm">
|
<YASM Include="..\..\src\extras\x86inc.asm">
|
||||||
|
|
|
@ -70,6 +70,7 @@ libkvazaar_la_SOURCES = \
|
||||||
intra.h \
|
intra.h \
|
||||||
kvazaar.c \
|
kvazaar.c \
|
||||||
kvazaar_internal.h \
|
kvazaar_internal.h \
|
||||||
|
kvz_math.h \
|
||||||
nal.c \
|
nal.c \
|
||||||
nal.h \
|
nal.h \
|
||||||
rate_control.c \
|
rate_control.c \
|
||||||
|
|
54
src/kvz_math.h
Normal file
54
src/kvz_math.h
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
#ifndef MATH_H_
|
||||||
|
#define MATH_H_
|
||||||
|
/*****************************************************************************
|
||||||
|
* This file is part of Kvazaar HEVC encoder.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
|
||||||
|
* COPYING file).
|
||||||
|
*
|
||||||
|
* Kvazaar 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.
|
||||||
|
*
|
||||||
|
* Kvazaar 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 General Public License along
|
||||||
|
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Generic math functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
static INLINE unsigned kvz_math_floor_log2(unsigned value)
|
||||||
|
{
|
||||||
|
assert(value > 0);
|
||||||
|
|
||||||
|
unsigned result = 0;
|
||||||
|
|
||||||
|
for (int i = 4; i >= 0; --i) {
|
||||||
|
unsigned bits = 1ull << i;
|
||||||
|
unsigned shift = value >= (1 << bits) ? bits : 0;
|
||||||
|
result += shift;
|
||||||
|
value >>= shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE unsigned kvz_math_ceil_log2(unsigned value)
|
||||||
|
{
|
||||||
|
assert(value > 0);
|
||||||
|
|
||||||
|
// The ceil_log2 is just floor_log2 + 1, except for exact powers of 2.
|
||||||
|
return kvz_math_floor_log2(value) + ((value & (value - 1)) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //CHECKPOINT_H_
|
Loading…
Reference in a new issue