predict.h
Go to the documentation of this file.
00001 #ifndef IZ_PREDICT_H
00002 #define IZ_PREDICT_H 1
00003 
00004 #include "intmacros.h"
00005 
00006 namespace IZ {
00007 
00008 #define UNUSED(x) { x = x; }
00009 
00010 template<typename Sample = unsigned char>
00011 class Predictor3med
00012 {
00013 public:
00014     static int predict(int x, int y, int xy) {
00015         int dx, dy, dxy, s;
00016         dy = x - xy;
00017         dx = xy - y;
00018         dxy = x - y;
00019         s = oppositeSign(dy, dx);
00020         dxy &= oppositeSign(dxy, dy);
00021         return selectVal(s, y + dy, x - dxy);
00022     }
00023 };
00024 
00025 template<typename Sample = unsigned char>
00026 class Predictor3alpha
00027 {
00028 public:
00029     static int predict(int x, int y, int xy) {
00030         return clamp0(clampMax(x + y - xy, Sample(~0)));
00031     }
00032 };
00033 
00034 template<typename Sample = unsigned char>
00035 class Predictor3plane
00036 {
00037 public:
00038     static int predict(int x, int y, int xy) {
00039         return x + y - xy;
00040     }
00041 };
00042 
00043 template<typename Sample = unsigned char>
00044 class Predictor3avgplane
00045 {
00046 public:
00047     static int predict(int x, int y, int xy) {
00048         return (3 * x + 3 * y - 2 * xy + 2) >> 2;
00049     }
00050 };
00051 
00052 template<typename Sample = unsigned char>
00053 class Predictor2avg
00054 {
00055 public:
00056     static int predict(int x, int y, int xy) {
00057         UNUSED(xy);
00058         return (x + y + 1) >> 1;
00059     }
00060 };
00061 
00062 template<typename Sample = unsigned char>
00063 class Predictor1x
00064 {
00065 public:
00066     static int predict(int x, int y, int xy) {
00067         UNUSED(y);
00068         UNUSED(xy);
00069         return x;
00070     }
00071 };
00072 
00073 template<typename Sample = unsigned char>
00074 class Predictor1y
00075 {
00076 public:
00077     static int predict(int x, int y, int xy) {
00078         UNUSED(x);
00079         UNUSED(xy);
00080         return y;
00081     }
00082 };
00083 
00084 template<typename Sample = unsigned char>
00085 class Predictor0
00086 {
00087 public:
00088     static int predict(int x, int y, int xy) {
00089         UNUSED(x);
00090         UNUSED(y);
00091         UNUSED(xy);
00092         return 0;
00093     }
00094 };
00095 
00096 } // namespace IZ
00097 
00098 #endif


imagezero
Author(s):
autogenerated on Thu Jun 6 2019 21:34:51