{
//need only weight if fit is found
float weight = alpha1 * gmm_weight(mode * frame.rows + y, x) + prune;
-
+ int swap_count = 0;
//fit not found yet
if (!fitsPDF)
{
if (weight < gmm_weight((i - 1) * frame.rows + y, x))
break;
+ swap_count++;
//swap one up
swap(gmm_weight, x, y, i - 1, frame.rows);
swap(gmm_variance, x, y, i - 1, frame.rows);
nmodes--;
}
- gmm_weight(mode * frame.rows + y, x) = weight; //update weight by the calculated value
+ gmm_weight((mode - swap_count) * frame.rows + y, x) = weight; //update weight by the calculated value
totalWeight += weight;
}
for (int mode = 0; mode < nmodes; ++mode)
{
float _weight = alpha1 * weight[(mode * frame_row + y) * weight_step + x] + prune;
-
+ int swap_count = 0;
if (!fitsPDF)
{
float var = variance[(mode * frame_row + y) * var_step + x];
{
if (_weight < weight[((i - 1) * frame_row + y) * weight_step + x])
break;
+ swap_count++;
swap(weight, x, y, i - 1, frame_row, weight_step);
swap(variance, x, y, i - 1, frame_row, var_step);
#if defined (CN1)
nmodes--;
}
- weight[(mode * frame_row + y) * weight_step + x] = _weight; //update weight by the calculated value
+ weight[((mode - swap_count) * frame_row + y) * weight_step + x] = _weight; //update weight by the calculated value
totalWeight += _weight;
}