4 * Code for predictor calculation. Its function version, predictor.c,
5 * is used in debugging compilation.
8 * $Id: predict.h,v 1.1 2003/10/21 12:08:54 jpr Exp $
16 *--------------------------------------------------------------
20 * Calculate the predictor for pixel[row][col][curComp],
21 * i.e. curRowBuf[col][curComp]. It handles the all special
22 * cases at image edges, such as first row and first column
26 * predictor is passed out.
31 *--------------------------------------------------------------
33 #define Predict(row,col,curComp,curRowBuf,prevRowBuf,Pr,Pt,psv,predictor) \
34 { register int left,upper,diag,leftcol; \
40 * The predictor of first pixel is (1<<(Pr-Pt-1), and the \
41 * predictors for rest of first row are left neighbors. \
44 *predictor = (1<<(Pr-Pt-1)); \
47 *predictor = curRowBuf[leftcol][curComp]; \
53 * The predictors of first column are upper neighbors. \
54 * All other preditors are calculated according to psv. \
56 upper=prevRowBuf[col][curComp]; \
60 left=curRowBuf[leftcol][curComp]; \
61 diag=prevRowBuf[leftcol][curComp]; \
76 *predictor = left+upper-diag; \
79 *predictor = left+((upper-diag)>>1); \
82 *predictor = upper+((left-diag)>>1); \
85 *predictor = (left+upper)>>1; \
88 fprintf(stderr,"Warning: Undefined PSV\n"); \
96 *--------------------------------------------------------------
100 * Calculate the predictor for sample curRowBuf[col][curComp].
101 * It does not handle the special cases at image edges, such
102 * as first row and first column of a scan. We put the special
103 * case checkings outside so that the computations in main
104 * loop can be simpler. This has enhenced the performance
108 * predictor is passed out.
113 *--------------------------------------------------------------
115 #define QuickPredict(col,curComp,curRowBuf,prevRowBuf,psv,predictor){ \
116 register int left,upper,diag,leftcol; \
119 * All predictor are calculated according to psv. \
126 *predictor = curRowBuf [col-1] [curComp]; \
129 *predictor = prevRowBuf[col][curComp]; \
132 *predictor = prevRowBuf [col-1] [curComp]; \
136 upper = prevRowBuf[col][curComp]; \
137 left = curRowBuf[leftcol][curComp]; \
138 diag = prevRowBuf[leftcol][curComp]; \
139 *predictor = left + upper - diag; \
143 upper = prevRowBuf[col][curComp]; \
144 left = curRowBuf[leftcol][curComp]; \
145 diag = prevRowBuf[leftcol][curComp]; \
146 *predictor = left+((upper-diag)>>1); \
150 upper = prevRowBuf[col][curComp]; \
151 left = curRowBuf[leftcol][curComp]; \
152 diag = prevRowBuf[leftcol][curComp]; \
153 *predictor = upper+((left-diag)>>1); \
157 upper = prevRowBuf[col][curComp]; \
158 left = curRowBuf[leftcol][curComp]; \
159 *predictor = (left+upper)>>1; \
162 fprintf(stderr,"Warning: Undefined PSV\n"); \
168 #endif /* _PREDICTOR */