int template_window_half_size_;
int search_window_half_size_;
- IT fixed_point_mult_;
+ int fixed_point_mult_;
int almost_template_window_size_sq_bin_shift_;
- std::vector<IT> almost_dist2weight_;
+ std::vector<int> almost_dist2weight_;
void calcDistSumsForFirstElementInRow(
int i, Array2d<int>& dist_sums,
const IT max_estimate_sum_value =
(IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
- fixed_point_mult_ = std::numeric_limits<IT>::max() / max_estimate_sum_value;
+ fixed_point_mult_ = (int)std::min<IT>(std::numeric_limits<IT>::max() / max_estimate_sum_value,
+ std::numeric_limits<int>::max());
// precalc weight for every possible l2 dist between blocks
// additional optimization of precalced weights to replace division(averaging) by binary shift
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
{
double dist = almost_dist * almost_dist2actual_dist_multiplier;
- IT weight = (IT)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
+ int weight = (int)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
weight = 0;
for (int x = 0; x < search_window_size_; x++)
{
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift_;
- IT weight = almost_dist2weight_[almostAvgDist];
- weights_sum += weight;
+ int weight = almost_dist2weight_[almostAvgDist];
+ weights_sum += (IT)weight;
T p = cur_row_ptr[border_size_ + search_window_x + x];
incWithWeight<T, IT>(estimation, weight, p);
template <typename T, typename IT> struct incWithWeight_
{
- static inline void f(IT* estimation, IT weight, T p)
+ static inline void f(IT* estimation, int weight, T p)
{
- estimation[0] += weight * p;
+ estimation[0] += (IT)weight * p;
}
};
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 2>, IT>
{
- static inline void f(IT* estimation, IT weight, Vec<ET, 2> p)
+ static inline void f(IT* estimation, int weight, Vec<ET, 2> p)
{
- estimation[0] += weight * p[0];
- estimation[1] += weight * p[1];
+ estimation[0] += (IT)weight * p[0];
+ estimation[1] += (IT)weight * p[1];
}
};
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 3>, IT>
{
- static inline void f(IT* estimation, IT weight, Vec<ET, 3> p)
+ static inline void f(IT* estimation, int weight, Vec<ET, 3> p)
{
- estimation[0] += weight * p[0];
- estimation[1] += weight * p[1];
- estimation[2] += weight * p[2];
+ estimation[0] += (IT)weight * p[0];
+ estimation[1] += (IT)weight * p[1];
+ estimation[2] += (IT)weight * p[2];
}
};
template <typename ET, typename IT> struct incWithWeight_<Vec<ET, 4>, IT>
{
- static inline void f(IT* estimation, IT weight, Vec<ET, 4> p)
+ static inline void f(IT* estimation, int weight, Vec<ET, 4> p)
{
- estimation[0] += weight * p[0];
- estimation[1] += weight * p[1];
- estimation[2] += weight * p[2];
- estimation[3] += weight * p[3];
+ estimation[0] += (IT)weight * p[0];
+ estimation[1] += (IT)weight * p[1];
+ estimation[2] += (IT)weight * p[2];
+ estimation[3] += (IT)weight * p[3];
}
};
int search_window_half_size_;
int temporal_window_half_size_;
- IT fixed_point_mult_;
+ int fixed_point_mult_;
int almost_template_window_size_sq_bin_shift;
- std::vector<IT> almost_dist2weight;
+ std::vector<int> almost_dist2weight;
void calcDistSumsForFirstElementInRow(int i, Array3d<int>& dist_sums,
Array4d<int>& col_dist_sums,
main_extended_src_ = extended_srcs_[temporal_window_half_size_];
const IT max_estimate_sum_value =
(IT)temporal_window_size_ * (IT)search_window_size_ * (IT)search_window_size_ * (IT)pixelInfo<T>::sampleMax();
- fixed_point_mult_ = std::numeric_limits<IT>::max() / max_estimate_sum_value;
+ fixed_point_mult_ = (int)std::min<IT>(std::numeric_limits<IT>::max() / max_estimate_sum_value,
+ std::numeric_limits<int>::max());
// precalc weight for every possible l2 dist between blocks
// additional optimization of precalced weights to replace division(averaging) by binary shift
for (int almost_dist = 0; almost_dist < almost_max_dist; almost_dist++)
{
double dist = almost_dist * almost_dist2actual_dist_multiplier;
- IT weight = (IT)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
+ int weight = (int)round(fixed_point_mult_ * D::template calcWeight<T>(dist, h));
if (weight < WEIGHT_THRESHOLD * fixed_point_mult_)
weight = 0;
{
int almostAvgDist = dist_sums_row[x] >> almost_template_window_size_sq_bin_shift;
- IT weight = almost_dist2weight[almostAvgDist];
- weights_sum += weight;
+ int weight = almost_dist2weight[almostAvgDist];
+ weights_sum += (IT)weight;
T p = cur_row_ptr[border_size_ + search_window_x + x];
incWithWeight<T, IT>(estimation, weight, p);