predict.h
Go to the documentation of this file.
1 #ifndef IZ_PREDICT_H
2 #define IZ_PREDICT_H 1
3 
4 #include "intmacros.h"
5 
6 namespace IZ {
7 
8 #define UNUSED(x) { x = x; }
9 
10 template<typename Sample = unsigned char>
12 {
13 public:
14  static int predict(int x, int y, int xy) {
15  int dx, dy, dxy, s;
16  dy = x - xy;
17  dx = xy - y;
18  dxy = x - y;
19  s = oppositeSign(dy, dx);
20  dxy &= oppositeSign(dxy, dy);
21  return selectVal(s, y + dy, x - dxy);
22  }
23 };
24 
25 template<typename Sample = unsigned char>
27 {
28 public:
29  static int predict(int x, int y, int xy) {
30  return clamp0(clampMax(x + y - xy, Sample(~0)));
31  }
32 };
33 
34 template<typename Sample = unsigned char>
36 {
37 public:
38  static int predict(int x, int y, int xy) {
39  return x + y - xy;
40  }
41 };
42 
43 template<typename Sample = unsigned char>
45 {
46 public:
47  static int predict(int x, int y, int xy) {
48  return (3 * x + 3 * y - 2 * xy + 2) >> 2;
49  }
50 };
51 
52 template<typename Sample = unsigned char>
54 {
55 public:
56  static int predict(int x, int y, int xy) {
57  UNUSED(xy);
58  return (x + y + 1) >> 1;
59  }
60 };
61 
62 template<typename Sample = unsigned char>
64 {
65 public:
66  static int predict(int x, int y, int xy) {
67  UNUSED(y);
68  UNUSED(xy);
69  return x;
70  }
71 };
72 
73 template<typename Sample = unsigned char>
75 {
76 public:
77  static int predict(int x, int y, int xy) {
78  UNUSED(x);
79  UNUSED(xy);
80  return y;
81  }
82 };
83 
84 template<typename Sample = unsigned char>
86 {
87 public:
88  static int predict(int x, int y, int xy) {
89  UNUSED(x);
90  UNUSED(y);
91  UNUSED(xy);
92  return 0;
93  }
94 };
95 
96 } // namespace IZ
97 
98 #endif
static int predict(int x, int y, int xy)
Definition: predict.h:29
static int selectVal(int s, int v0, int v1)
Definition: intmacros.h:32
#define UNUSED(x)
Definition: predict.h:8
static int predict(int x, int y, int xy)
Definition: predict.h:66
Definition: bitcoder.h:6
static int clamp0(int v)
Definition: intmacros.h:53
static int predict(int x, int y, int xy)
Definition: predict.h:56
static int predict(int x, int y, int xy)
Definition: predict.h:14
static int predict(int x, int y, int xy)
Definition: predict.h:38
static int oppositeSign(int v1, int v2)
Definition: intmacros.h:25
static int clampMax(int v, int max)
Definition: intmacros.h:39
static int predict(int x, int y, int xy)
Definition: predict.h:47
static int predict(int x, int y, int xy)
Definition: predict.h:88
static int predict(int x, int y, int xy)
Definition: predict.h:77


imagezero
Author(s):
autogenerated on Wed Jun 5 2019 22:02:47