static int diff_percent_rgb(int i, int j) { int diff_r = diff_abs(data[3 * i], data[3 * j]); int diff_g = diff_abs(data[3 * i + 1], data[3 * j + 1]); int diff_b = diff_abs(data[3 * i + 2], data[3 * j + 2]); int diff = (diff_r + diff_g + diff_b) / 3; int percent_diff = (100 * diff) / (NUM_INTS_PER_WORD * 256); // printf("cmp(%d,%d) = %d = %d%%\n", i, j, diff, percent_diff); return percent_diff; }
static int diff_percent_gray(int i, int j) { int diff = diff_abs(data[i], data[j]); int percent_diff = (100 * diff) / (NUM_INTS_PER_WORD * 256); // printf("cmp(%d,%d) = %d = %d%%\n", i, j, diff, percent_diff); return percent_diff; }
prediction_info_t CPrediction::predict(float * pSrc, CPoint p, CSize srcSize) { prediction_info_t info; info.dy = 0; info.dx = 0; CSize s = (*m_last)[p.Z].getSize(); int scale = getInterpolationScale(); p.Y *= scale; p.X *= scale; if(m_max) { struct { CPoint p; float d; } min; min.p = p; min.d = std::numeric_limits<float>::max(); CPoint dp; for(int dy = -m_max ; dy <= m_max ; dy++) { for(int dx=-m_max ; dx <= m_max ; dx++) { dp.Y = p.Y + dy*16; dp.X = p.X + dx*16; if(dp.X >= 0 && dp.Y >= 0 && (dp.Y+16) < s.Height && (dp.X+16) < s.Width) { float d; #if DEFAULT_PREDICTION_METHOD == PREDICTION_METHOD_MSE d = diff_mse(pSrc, srcSize, &(*m_last)[p.Z][dp.Y][dp.X], s); #elif DEFAULT_PREDICTION_METHOD == PREDICTION_METHOD_ABS d = diff_abs(pSrc, srcSize, &(*m_last)[p.Z][dp.Y][dp.X], s); #else #error Unknown prediction method #endif if(d < min.d) { min.d = d; min.p = dp; } } } } info.dy = (min.p.Y-p.Y)/16; info.dx = (min.p.X-p.X)/16; } return info; }