@@ -464,7 +464,7 @@ private static bool HistogramCombineStochastic(Vp8LHistogramSet histograms, int
464
464
}
465
465
}
466
466
467
- HistoListUpdateHead ( histoPriorityList , p ) ;
467
+ HistoListUpdateHead ( histoPriorityList , p , j ) ;
468
468
j ++ ;
469
469
}
470
470
@@ -524,7 +524,7 @@ private static void HistogramCombineGreedy(Vp8LHistogramSet histograms)
524
524
}
525
525
else
526
526
{
527
- HistoListUpdateHead ( histoPriorityList , p ) ;
527
+ HistoListUpdateHead ( histoPriorityList , p , i ) ;
528
528
i ++ ;
529
529
}
530
530
}
@@ -646,7 +646,7 @@ private static double HistoPriorityListPush(
646
646
647
647
histoList . Add ( pair ) ;
648
648
649
- HistoListUpdateHead ( histoList , pair ) ;
649
+ HistoListUpdateHead ( histoList , pair , histoList . Count - 1 ) ;
650
650
651
651
return pair . CostDiff ;
652
652
}
@@ -673,13 +673,11 @@ private static void HistoListUpdatePair(
673
673
/// <summary>
674
674
/// Check whether a pair in the list should be updated as head or not.
675
675
/// </summary>
676
- private static void HistoListUpdateHead ( List < HistogramPair > histoList , HistogramPair pair )
676
+ private static void HistoListUpdateHead ( List < HistogramPair > histoList , HistogramPair pair , int idx )
677
677
{
678
678
if ( pair . CostDiff < histoList [ 0 ] . CostDiff )
679
679
{
680
- // Replace the best pair.
681
- int oldIdx = histoList . IndexOf ( pair ) ;
682
- histoList [ oldIdx ] = histoList [ 0 ] ;
680
+ histoList [ idx ] = histoList [ 0 ] ;
683
681
histoList [ 0 ] = pair ;
684
682
}
685
683
}
0 commit comments