/* getref: calculate reference image pointer the decision to use interpolation h/v/hv or the normal image is based on dx & dy.  */
static __inline const uint8_t* get_ref(const uint8_t *const refn, const uint8_t *const refh, const uint8_t *const refv, const uint8_t *const refhv, const uint32_t x, const uint32_t y, const uint32_t block, const int32_t dx, const int32_t dy, const int32_t stride)
/* getref: calculate reference image pointer the decision to use interpolation h/v/hv or the normal image is based on dx & dy.  */
static __inline const uint8_t* get_ref(const uint8_t *const refn, const uint8_t *const refh, const uint8_t *const refv, const uint8_t *const refhv, const uint32_t x, const uint32_t y, const uint32_t block, const int32_t dx, const int32_t dy, const int32_t stride)
{
	switch (((dx & 1) << 1) + (dy & 1)) {
	case 0:
		return refn + (int) (((int)x * (int)block + dx / 2) + ((int)y * (int)block + dy / 2) * (int)stride);
	case 1:
		return refv + (int) (((int)x * (int)block + dx / 2) + ((int)y * (int)block + (dy - 1) / 2) * (int)stride);
	case 2:
		return refh + (int) (((int)x * (int)block + (dx - 1) / 2) + ((int)y * (int)block + dy / 2) * (int)stride);
	default:
		return refhv + (int) (((int)x * (int)block + (dx - 1) / 2) + ((int)y * (int)block + (dy - 1) / 2) * (int)stride);
	}
}