Commit 0d6e0e6f authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander.Trofimov

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68845 954022d7-b5bf-4e40-9824-e11837661b57
parent aa538911
...@@ -919,7 +919,7 @@ function FT_PAD_FLOOR(x, n) ...@@ -919,7 +919,7 @@ function FT_PAD_FLOOR(x, n)
} }
function FT_PAD_ROUND(x, n) function FT_PAD_ROUND(x, n)
{ {
return (x + (n >> 1)) & (~(n-1)); return (x + (n >>> 1)) & (~(n-1));
} }
function FT_PAD_CEIL(x, n) function FT_PAD_CEIL(x, n)
{ {
......
...@@ -668,6 +668,16 @@ function _FT_Common() ...@@ -668,6 +668,16 @@ function _FT_Common()
this.TABLE_EXTEND = 5; this.TABLE_EXTEND = 5;
/* the Cordic shrink factor 0.858785336480436 * 2^32 */
this.FT_TRIG_SCALE = 0xDBD95B16;
/* the highest bit in overflow-safe vector components, */
/* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */
this.FT_TRIG_SAFE_MSB = 29;
/* this table was generated for FT_PI = 180L << 16, i.e. degrees */
this.FT_TRIG_MAX_ITERS = 23;
// константы строковые // константы строковые
this.SYMBOL_CONST_SR = "\r".charCodeAt(0); this.SYMBOL_CONST_SR = "\r".charCodeAt(0);
this.SYMBOL_CONST_SN = "\n".charCodeAt(0); this.SYMBOL_CONST_SN = "\n".charCodeAt(0);
...@@ -958,11 +968,6 @@ function _FT_Common() ...@@ -958,11 +968,6 @@ function _FT_Common()
this.FT_ANGLE_PI = (180 << 16); this.FT_ANGLE_PI = (180 << 16);
this.FT_ANGLE_PI2 = (this.FT_ANGLE_PI / 2); this.FT_ANGLE_PI2 = (this.FT_ANGLE_PI / 2);
this.FT_TRIG_MAX_ITERS = 23;
this.FT_TRIG_SCALE = 0x9B74EDA8;
if (this.FT_TRIG_SCALE < 0)
this.FT_TRIG_SCALE = this.IntToUInt(this.FT_TRIG_SCALE);
this.tt_coderange_none = 0; this.tt_coderange_none = 0;
this.tt_coderange_font = 1; this.tt_coderange_font = 1;
......
...@@ -1791,6 +1791,9 @@ function TT_MulFix14(a, b) ...@@ -1791,6 +1791,9 @@ function TT_MulFix14(a, b)
hi += 1; hi += 1;
mid = FT_Common.IntToUInt(((lo >> 14) | (hi << 18)) & 0xFFFFFFFF); mid = FT_Common.IntToUInt(((lo >> 14) | (hi << 18)) & 0xFFFFFFFF);
//console.log("(" + a + ", " + b + "): " + (sign >= 0 ? mid : -mid));
return sign >= 0 ? mid : -mid; return sign >= 0 ? mid : -mid;
} }
...@@ -1840,6 +1843,8 @@ function TT_DotFix14(ax, ay, bx, by) ...@@ -1840,6 +1843,8 @@ function TT_DotFix14(ax, ay, bx, by)
hi += ((l < lo) ? 1 : 0); hi += ((l < lo) ? 1 : 0);
//console.log("(" + ax + ", " + ay + ", " + bx + ", " + by + "): " + (((hi << 18) | (l >> 14)) & 0xFFFFFFFF));
return ((hi << 18) | (l >> 14)) & 0xFFFFFFFF; return ((hi << 18) | (l >> 14)) & 0xFFFFFFFF;
} }
......
...@@ -384,15 +384,15 @@ function ft_trig_prenorm(vec) ...@@ -384,15 +384,15 @@ function ft_trig_prenorm(vec)
shift += 1; shift += 1;
} }
if (shift <= 27) if (shift <= FT_Common.FT_TRIG_SAFE_MSB)
{ {
shift = 27 - shift; shift = FT_Common.FT_TRIG_SAFE_MSB - shift;
vec.x = x << shift; vec.x = x << shift;
vec.y = y << shift; vec.y = y << shift;
} }
else else
{ {
shift -= 27; shift -= FT_Common.FT_TRIG_SAFE_MSB;
vec.x = x >> shift; vec.x = x >> shift;
vec.y = y >> shift; vec.y = y >> shift;
shift = -shift; shift = -shift;
...@@ -401,53 +401,75 @@ function ft_trig_prenorm(vec) ...@@ -401,53 +401,75 @@ function ft_trig_prenorm(vec)
return shift; return shift;
} }
var ft_trig_arctan_table = [2949120, 1740967, 919879, 466945, 234379, 117304, 58666, 29335, 14668, 7334, var ft_trig_arctan_table = [1740967, 919879, 466945, 234379, 117304, 58666, 29335, 14668, 7334,
3667, 1833, 917, 458, 229, 115, 57, 29, 14, 7, 4, 2, 1]; 3667, 1833, 917, 458, 229, 115, 57, 29, 14, 7, 4, 2, 1, 0];
function ft_trig_pseudo_polarize(vec) function ft_trig_pseudo_polarize(vec)
{ {
var x = vec.x; var x = vec.x;
var y = vec.y; var y = vec.y;
/* Get the vector into the right half plane */
var theta = 0; var theta = 0;
if (x < 0) var xtemp = 0;
/* Get the vector into [-PI/4,PI/4] sector */
if ( y > x )
{
if ( y > -x )
{
theta = FT_Common.FT_ANGLE_PI2;
xtemp = y;
y = -x;
x = xtemp;
}
else
{
theta = y > 0 ? FT_Common.FT_ANGLE_PI : -FT_Common.FT_ANGLE_PI;
x = -x;
y = -y;
}
}
else
{ {
x = -x; if ( y < -x )
y = -y; {
theta = 2 * FT_Common.FT_ANGLE_PI2; theta = -FT_Common.FT_ANGLE_PI2;
xtemp = -y;
y = x;
x = xtemp;
}
else
{
theta = 0;
}
} }
if (y > 0) arctanptr = 0;
theta = - theta;
var arctanptr = 0;
var xtemp = 0;
/* Pseudorotations, with right shifts */ /* Pseudorotations, with right shifts */
i = 0; for ( i = 1, b = 1; i < FT_Common.FT_TRIG_MAX_ITERS; b <<= 1, i++ )
do
{ {
if ( y > 0 ) if ( y > 0 )
{ {
xtemp = x + (y >> i); xtemp = x + ( ( y + b ) >> i );
y = y - (x >> i); y = y - ( ( x + b ) >> i );
x = xtemp; x = xtemp;
theta += ft_trig_arctan_table[arctanptr++]; theta += ft_trig_arctan_table[arctanptr++];
} }
else else
{ {
xtemp = x - (y >> i); xtemp = x - ( ( y + b ) >> i );
y = y + (x >> i); y = y + ( ( x + b ) >> i );
x = xtemp; x = xtemp;
theta -= ft_trig_arctan_table[arctanptr++]; theta -= ft_trig_arctan_table[arctanptr++];
} }
} while (++i < FT_Common.FT_TRIG_MAX_ITERS); }
/* round theta */ /* round theta */
if (theta >= 0) if ( theta >= 0 )
theta = ((theta + 16) & ~31); theta = FT_PAD_ROUND( theta, 32 );
else else
theta = -((-theta + 16) & ~31); theta = -FT_PAD_ROUND( -theta, 32 );
vec.x = x; vec.x = x;
vec.y = theta; vec.y = theta;
...@@ -458,28 +480,25 @@ function ft_trig_downscale(val) ...@@ -458,28 +480,25 @@ function ft_trig_downscale(val)
var s = val; var s = val;
val = (val >= 0) ? val : -val; val = (val >= 0) ? val : -val;
var v1 = FT_Common.IntToUInt(val >> 16); var v1 = val >>> 16;
var v2 = FT_Common.IntToUInt(val & 0xFFFF); var v2 = FT_Common.Short_To_UShort(val & 0xFFFF);
var k1 = 0x9B74; /* constant */ var k1 = 0xDBD9; /* constant */
var k2 = 0xEDA8; /* constant */ var k2 = 0x5B16; /* constant */
var hi = k1 * v1; var hi = k1 * v1;
var lo1 = k1 * v2 + k2 * v1; /* can't overflow */ var lo1 = k1 * v2 + k2 * v1; /* can't overflow */
var lo2 = ( k2 * v2 ) / 65536; var lo2 = ( k2 * v2 ) >>> 16;
lo2 = lo2 >> 0;
var lo3 = ( lo1 >= lo2 ) ? lo1 : lo2; var lo3 = ( lo1 >= lo2 ) ? lo1 : lo2;
lo1 += lo2; lo1 += lo2;
lo1 = FT_Common.IntToUInt(lo1); hi += (lo1 >>> 16);
hi += lo1 >> 16;
if (lo1 < lo3) if (lo1 < lo3)
hi += 0x10000; hi += 0x10000;
val = hi; var val = FT_Common.UintToInt(hi);
val = FT_Common.UintToInt(val);
return (s >= 0) ? val : -val; return (s >= 0) ? val : -val;
} }
......
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