private short PredictPixel(Vector mv, int x, int y, int k)
{
if(mv.namespace_global) {
for(int i = 0; i < par.num_refs; i++) {
par.global[i].GetVector(mv, x, y, i);
}
if(k != 0)
mv = mv.Scale(chroma_h_shift, chroma_v_shift);
}
short weight = (short)(par.picture_weight_1 + par.picture_weight_2);
short val = 0;
int px, py;
switch(mv.pred_mode) {
case 1:
px = (x << par.mv_precision) + mv.dx[0];
py = (y << par.mv_precision) + mv.dy[0];
val = (short)(weight*PredictSubPixel(0, px, py));
break;
case 2:
px = (x << par.mv_precision) + mv.dx[1];
py = (y << par.mv_precision) + mv.dy[1];
val = (short)(weight*PredictSubPixel(1, px, py));
break;
case 3:
px = (x << par.mv_precision) + mv.dx[0];
py = (y << par.mv_precision) + mv.dy[0];
val = (short)(par.picture_weight_1*PredictSubPixel(0, px, py));
px = (x << par.mv_precision) + mv.dx[1];
py = (x << par.mv_precision) + mv.dy[1];
val += (short)(par.picture_weight_2*PredictSubPixel(1, px, py));
break;
default:
break;
}
return (short)Util.RoundShift(val, par.picture_weight_bits);
}