Commit 1a1b9c6f authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Optimize exp2fix8

Slightly faster and more accurate rounding.
parent c695f524
......@@ -165,9 +165,9 @@ extern const float x264_log2_lz_lut[32];
* qp to qscale. */
static ALWAYS_INLINE int x264_exp2fix8( float x )
{
if( x >= 512.f/6.f ) return 0;
if( x <= -512.f/6.f ) return 0xffff;
int i = x*(-64.f/6.f) + 512;
int i = x*(-64.f/6.f) + 512.5f;
if( i < 0 ) return 0;
if( i > 1023 ) return 0xffff;
return (x264_exp2_lut[i&63]+256) << (i>>6) >> 8;
}
......
......@@ -154,10 +154,10 @@ const int x264_lambda2_tab[52] = {
};
const uint8_t x264_exp2_lut[64] = {
1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 44, 47,
50, 53, 57, 60, 64, 67, 71, 74, 78, 81, 85, 89, 93, 96, 100, 104,
108, 112, 116, 120, 124, 128, 132, 137, 141, 145, 150, 154, 159, 163, 168, 172,
177, 182, 186, 191, 196, 201, 206, 211, 216, 221, 226, 232, 237, 242, 248, 253,
0, 3, 6, 8, 11, 14, 17, 20, 23, 26, 29, 32, 36, 39, 42, 45,
48, 52, 55, 58, 62, 65, 69, 72, 76, 80, 83, 87, 91, 94, 98, 102,
106, 110, 114, 118, 122, 126, 130, 135, 139, 143, 147, 152, 156, 161, 165, 170,
175, 179, 184, 189, 194, 198, 203, 208, 214, 219, 224, 229, 234, 240, 245, 250
};
const float x264_log2_lut[128] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment