w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

primitives.c
Go to the documentation of this file.
1 #include "otfcc/primitives.h"
2 #include "bin-io.h"
3 #include <math.h>
4 
5 // f2dot14 type
6 double otfcc_from_f2dot14(const f2dot14 x) {
7  return x / 16384.0;
8 }
9 int16_t otfcc_to_f2dot14(const double x) {
10  return round(x * 16384.0);
11 }
12 
13 // F16.16 (fixed) type
14 double otfcc_from_fixed(const f16dot16 x) {
15  return x / 65536.0;
16 }
17 f16dot16 otfcc_to_fixed(const double x) {
18  return round(x * 65536.0);
19 }
20 
21 // F16.16 arith
22 // Clamp: remove too-large values
24  int64_t tmp = value;
27  return (f16dot16)tmp;
28 }
29 
31  return a + b;
32 }
34  return a - b;
35 }
36 
38  int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k;
39  f16dot16 product = clamp(tmp >> f16dot16_precision);
40  return product;
41 }
42 
44  if (b == 0) {
45  if (a < 0)
47  else
48  return f16dot16_infinity;
49  }
50 
51  if ((a < 0 != b < 0)) {
52  a -= b / 2;
53  } else {
54  a += b / 2;
55  }
56 
57  return (f16dot16)(clamp(a / b));
58 }
59 
61  int64_t tmp = (int64_t)a * (int64_t)b + f16dot16_k;
62  return divide(tmp, c);
63 }
65  return divide((int64_t)a << f16dot16_precision, b);
66 }
#define b
Definition: jpegint.h:372
#define c(n)
Definition: gpos-common.c:150
#define a(n)
Definition: gpos-common.c:148
signed short int16_t
Definition: stdint.h:76
signed __int64 int64_t
Definition: stdint.h:89
signed int int32_t
Definition: stdint.h:77
#define INLINE
Definition: port.h:26
float x
Definition: cordic.py:15
union value value
Definition: obx.h:44
#define round(a)
Definition: pbmtopk.c:22
static INLINE f16dot16 divide(int64_t a, int32_t b)
Definition: primitives.c:43
f16dot16 otfcc_f1616_muldiv(f16dot16 a, f16dot16 b, f16dot16 c)
Definition: primitives.c:60
f16dot16 otfcc_f1616_add(f16dot16 a, f16dot16 b)
Definition: primitives.c:30
f16dot16 otfcc_f1616_divide(f16dot16 a, f16dot16 b)
Definition: primitives.c:64
double otfcc_from_f2dot14(const f2dot14 x)
Definition: primitives.c:6
double otfcc_from_fixed(const f16dot16 x)
Definition: primitives.c:14
f16dot16 otfcc_f1616_minus(f16dot16 a, f16dot16 b)
Definition: primitives.c:33
static INLINE f16dot16 clamp(int64_t value)
Definition: primitives.c:23
f16dot16 otfcc_f1616_multiply(f16dot16 a, f16dot16 b)
Definition: primitives.c:37
int16_t otfcc_to_f2dot14(const double x)
Definition: primitives.c:9
f16dot16 otfcc_to_fixed(const double x)
Definition: primitives.c:17
#define f16dot16_k
Definition: primitives.h:37
int32_t f16dot16
Definition: primitives.h:9
#define f16dot16_infinity
Definition: primitives.h:38
#define f16dot16_precision
Definition: primitives.h:36
#define f16dot16_negativeIntinity
Definition: primitives.h:39
int16_t f2dot14
Definition: primitives.h:8
#define int64_t
Definition: stdint.in.h:194
Definition: obx.h:51