summaryrefslogtreecommitdiff
path: root/goo
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2019-08-20 21:00:40 +0300
committerAdrian Bunk <bunk@stusta.de>2019-08-20 21:00:40 +0300
commit5b81ab6ce06f60daa63029a3eb12cd31d6852799 (patch)
treebeccba619d6fddb93119bbd175678e5ed599f9a0 /goo
parentd70f77ee6a1bdee8b17f08f3066c0cd685853d21 (diff)
Remove USE_FIXEDPOINT support
This was already non-compiling for some time. Closes #821
Diffstat (limited to 'goo')
-rw-r--r--goo/FixedPoint.cc145
-rw-r--r--goo/FixedPoint.h176
2 files changed, 0 insertions, 321 deletions
diff --git a/goo/FixedPoint.cc b/goo/FixedPoint.cc
deleted file mode 100644
index 31e04b68..00000000
--- a/goo/FixedPoint.cc
+++ /dev/null
@@ -1,145 +0,0 @@
-//========================================================================
-//
-// FixedPoint.cc
-//
-// Fixed point type, with C++ operators.
-//
-// Copyright 2004 Glyph & Cog, LLC
-//
-//========================================================================
-
-//========================================================================
-//
-// Modified under the Poppler project - http://poppler.freedesktop.org
-//
-// All changes made under the Poppler project to this file are licensed
-// under GPL version 2 or later
-//
-// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
-//
-// To see a description of the changes please see the Changelog file that
-// came with your tarball or type make ChangeLog if you are building from git
-//
-//========================================================================
-
-#include <config.h>
-
-#ifdef USE_FIXEDPOINT
-
-#include "FixedPoint.h"
-
-#define ln2 ((FixedPoint)0.69314718)
-
-#define ln2 ((FixedPoint)0.69314718)
-
-FixedPoint FixedPoint::sqrt(FixedPoint x) {
- FixedPoint y0, y1, z;
-
- if (x.val <= 0) {
- y1.val = 0;
- } else {
- y1.val = x.val == 1 ? 2 : x.val >> 1;
- do {
- y0.val = y1.val;
- z = x / y0;
- y1.val = (y0.val + z.val) >> 1;
- } while (::abs(y0.val - y1.val) > 1);
- }
- return y1;
-}
-
-FixedPoint FixedPoint::pow(FixedPoint x, FixedPoint y) {
- FixedPoint t, t2, lnx0, lnx, z0, z;
- int d, n, i;
-
- if (y.val <= 0) {
- z.val = 0;
- } else {
- // y * ln(x)
- t = (x - 1) / (x + 1);
- t2 = t * t;
- d = 1;
- lnx = 0;
- do {
- lnx0 = lnx;
- lnx += t / d;
- t *= t2;
- d += 2;
- } while (::abs(lnx.val - lnx0.val) > 2);
- lnx.val <<= 1;
- t = y * lnx;
- // exp(y * ln(x))
- n = floor(t / ln2);
- t -= ln2 * n;
- t2 = t;
- d = 1;
- i = 1;
- z = 1;
- do {
- z0 = z;
- z += t2 / d;
- t2 *= t;
- ++i;
- d *= i;
- } while (::abs(z.val - z0.val) > 2 && d < (1 << fixptShift));
- if (n >= 0) {
- z.val <<= n;
- } else if (n < 0) {
- z.val >>= -n;
- }
- }
- return z;
-}
-
-int FixedPoint::mul(int x, int y) {
- FixPtInt64 z;
-
- z = ((FixPtInt64)x * y) >> fixptShift;
- if (z > 0x7fffffffLL) {
- return 0x7fffffff;
- } else if (z < -0x80000000LL) {
- return 0x80000000;
- } else {
- return (int)z;
- }
-}
-
-int FixedPoint::div(int x, int y) {
- FixPtInt64 z;
-
- z = ((FixPtInt64)x << fixptShift) / y;
- if (z > 0x7fffffffLL) {
- return 0x7fffffff;
- } else if (z < -0x80000000LL) {
- return 0x80000000;
- } else {
- return (int)z;
- }
-}
-
-bool FixedPoint::divCheck(FixedPoint x, FixedPoint y, FixedPoint *result) {
- FixPtInt64 z;
-
- z = ((FixPtInt64)x.val << fixptShift) / y.val;
- if ((z == 0 && x != 0) ||
- z >= ((FixPtInt64)1 << 31) || z < -((FixPtInt64)1 << 31)) {
- return false;
- }
- result->val = z;
- return true;
-}
-
-bool FixedPoint::checkDet(FixedPoint m11, FixedPoint m12,
- FixedPoint m21, FixedPoint m22,
- FixedPoint epsilon) {
- FixPtInt64 det, e;
-
- det = (FixPtInt64)m11.val * (FixPtInt64)m22.val
- - (FixPtInt64)m12.val * (FixPtInt64)m21.val;
- e = (FixPtInt64)epsilon.val << fixptShift;
- // NB: this comparison has to be >= not > because epsilon can be
- // truncated to zero as a fixed point value.
- return det >= e || det <= -e;
-}
-
-#endif // USE_FIXEDPOINT
diff --git a/goo/FixedPoint.h b/goo/FixedPoint.h
deleted file mode 100644
index 960c5bd0..00000000
--- a/goo/FixedPoint.h
+++ /dev/null
@@ -1,176 +0,0 @@
-//========================================================================
-//
-// FixedPoint.h
-//
-// Fixed point type, with C++ operators.
-//
-// Copyright 2004 Glyph & Cog, LLC
-//
-//========================================================================
-
-
-//========================================================================
-//
-// Modified under the Poppler project - http://poppler.freedesktop.org
-//
-// All changes made under the Poppler project to this file are licensed
-// under GPL version 2 or later
-//
-// Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
-//
-// To see a description of the changes please see the Changelog file that
-// came with your tarball or type make ChangeLog if you are building from git
-//
-//========================================================================
-
-#ifndef FIXEDPOINT_H
-#define FIXEDPOINT_H
-
-#include "poppler-config.h"
-
-#ifdef USE_FIXEDPOINT
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#define fixptShift 16
-#define fixptMaskL ((1 << fixptShift) - 1)
-#define fixptMaskH (~fixptMaskL)
-
-typedef long long FixPtInt64;
-
-class FixedPoint {
-public:
-
- FixedPoint() { val = 0; }
- FixedPoint(const FixedPoint &x) { val = x.val; }
- FixedPoint(double x) { val = (int)(x * (1 << fixptShift) + 0.5); }
- FixedPoint(int x) { val = x << fixptShift; }
- FixedPoint(long x) { val = x << fixptShift; }
-
- operator float()
- { return (float) val * ((float)1 / (float)(1 << fixptShift)); }
- operator double()
- { return (double) val * (1.0 / (double)(1 << fixptShift)); }
- operator int()
- { return val >> fixptShift; }
-
- int get16Dot16() { return val; }
-
- FixedPoint operator =(FixedPoint x) { val = x.val; return *this; }
-
- int operator ==(FixedPoint x) { return val == x.val; }
- int operator ==(double x) { return *this == (FixedPoint)x; }
- int operator ==(int x) { return *this == (FixedPoint)x; }
- int operator ==(long x) { return *this == (FixedPoint)x; }
-
- int operator !=(FixedPoint x) { return val != x.val; }
- int operator !=(double x) { return *this != (FixedPoint)x; }
- int operator !=(int x) { return *this != (FixedPoint)x; }
- int operator !=(long x) { return *this != (FixedPoint)x; }
-
- int operator <(FixedPoint x) { return val < x.val; }
- int operator <(double x) { return *this < (FixedPoint)x; }
- int operator <(int x) { return *this < (FixedPoint)x; }
- int operator <(long x) { return *this < (FixedPoint)x; }
-
- int operator <=(FixedPoint x) { return val <= x.val; }
- int operator <=(double x) { return *this <= (FixedPoint)x; }
- int operator <=(int x) { return *this <= (FixedPoint)x; }
- int operator <=(long x) { return *this <= (FixedPoint)x; }
-
- int operator >(FixedPoint x) { return val > x.val; }
- int operator >(double x) { return *this > (FixedPoint)x; }
- int operator >(int x) { return *this > (FixedPoint)x; }
- int operator >(long x) { return *this > (FixedPoint)x; }
-
- int operator >=(FixedPoint x) { return val >= x.val; }
- int operator >=(double x) { return *this >= (FixedPoint)x; }
- int operator >=(int x) { return *this >= (FixedPoint)x; }
- int operator >=(long x) { return *this >= (FixedPoint)x; }
-
- FixedPoint operator -() { return make(-val); }
-
- FixedPoint operator +(FixedPoint x) { return make(val + x.val); }
- FixedPoint operator +(double x) { return *this + (FixedPoint)x; }
- FixedPoint operator +(int x) { return *this + (FixedPoint)x; }
- FixedPoint operator +(long x) { return *this + (FixedPoint)x; }
-
- FixedPoint operator +=(FixedPoint x) { val = val + x.val; return *this; }
- FixedPoint operator +=(double x) { return *this += (FixedPoint)x; }
- FixedPoint operator +=(int x) { return *this += (FixedPoint)x; }
- FixedPoint operator +=(long x) { return *this += (FixedPoint)x; }
-
- FixedPoint operator -(FixedPoint x) { return make(val - x.val); }
- FixedPoint operator -(double x) { return *this - (FixedPoint)x; }
- FixedPoint operator -(int x) { return *this - (FixedPoint)x; }
- FixedPoint operator -(long x) { return *this - (FixedPoint)x; }
-
- FixedPoint operator -=(FixedPoint x) { val = val - x.val; return *this; }
- FixedPoint operator -=(double x) { return *this -= (FixedPoint)x; }
- FixedPoint operator -=(int x) { return *this -= (FixedPoint)x; }
- FixedPoint operator -=(long x) { return *this -= (FixedPoint)x; }
-
- FixedPoint operator *(FixedPoint x) { return make(mul(val, x.val)); }
- FixedPoint operator *(double x) { return *this * (FixedPoint)x; }
- FixedPoint operator *(int x) { return *this * (FixedPoint)x; }
- FixedPoint operator *(long x) { return *this * (FixedPoint)x; }
-
- FixedPoint operator *=(FixedPoint x) { val = mul(val, x.val); return *this; }
- FixedPoint operator *=(double x) { return *this *= (FixedPoint)x; }
- FixedPoint operator *=(int x) { return *this *= (FixedPoint)x; }
- FixedPoint operator *=(long x) { return *this *= (FixedPoint)x; }
-
- FixedPoint operator /(FixedPoint x) { return make(div(val, x.val)); }
- FixedPoint operator /(double x) { return *this / (FixedPoint)x; }
- FixedPoint operator /(int x) { return *this / (FixedPoint)x; }
- FixedPoint operator /(long x) { return *this / (FixedPoint)x; }
-
- FixedPoint operator /=(FixedPoint x) { val = div(val, x.val); return *this; }
- FixedPoint operator /=(double x) { return *this /= (FixedPoint)x; }
- FixedPoint operator /=(int x) { return *this /= (FixedPoint)x; }
- FixedPoint operator /=(long x) { return *this /= (FixedPoint)x; }
-
- static FixedPoint abs(FixedPoint x) { return make(::abs(x.val)); }
-
- static int floor(FixedPoint x) { return x.val >> fixptShift; }
-
- static int ceil(FixedPoint x)
- { return (x.val & fixptMaskL) ? ((x.val >> fixptShift) + 1)
- : (x.val >> fixptShift); }
-
- static int round(FixedPoint x)
- { return (x.val + (1 << (fixptShift - 1))) >> fixptShift; }
-
- // Computes (x+y)/2 avoiding overflow and LSbit accuracy issues.
- static FixedPoint avg(FixedPoint x, FixedPoint y)
- { return make((x.val >> 1) + (y.val >> 1) + ((x.val | y.val) & 1)); }
-
-
- static FixedPoint sqrt(FixedPoint x);
-
- static FixedPoint pow(FixedPoint x, FixedPoint y);
-
- // Compute *result = x/y; return false if there is an underflow or
- // overflow.
- static bool divCheck(FixedPoint x, FixedPoint y, FixedPoint *result);
-
- // Compute abs(m11*m22 - m12*m21) >= epsilon, handling the case
- // where the multiplications overflow.
- static bool checkDet(FixedPoint m11, FixedPoint m12,
- FixedPoint m21, FixedPoint m22,
- FixedPoint epsilon);
-
-private:
-
- static FixedPoint make(int valA) { FixedPoint x; x.val = valA; return x; }
-
- static int mul(int x, int y);
- static int div(int x, int y);
-
- int val; // fixed point: (n-fixptShift).(fixptShift)
-};
-
-#endif // USE_FIXEDPOINT
-
-#endif