comparison elbg.c @ 7352:c2318e551ff5 libavcodec

When picking a "high utility centroid" do not pick one that has no corresponding points. Not only it is the worst possible pick, but also the code was written without this case in mind.
author vitor
date Wed, 23 Jul 2008 03:55:37 +0000
parents 1502ba3beb72
children 3d9cdb5a4f01
comparison
equal deleted inserted replaced
7351:1502ba3beb72 7352:c2318e551ff5
103 103
104 static int get_high_utility_cell(elbg_data *elbg) 104 static int get_high_utility_cell(elbg_data *elbg)
105 { 105 {
106 int i=0; 106 int i=0;
107 /* Using linear search, do binary if it ever turns to be speed critical */ 107 /* Using linear search, do binary if it ever turns to be speed critical */
108 int r = av_random(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1]; 108 int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
109 while (elbg->utility_inc[i] < r) 109 while (elbg->utility_inc[i] < r)
110 i++; 110 i++;
111
112 assert(!elbg->cells[i]);
113
111 return i; 114 return i;
112 } 115 }
113 116
114 /** 117 /**
115 * Implementation of the simple LBG algorithm for just two codebooks 118 * Implementation of the simple LBG algorithm for just two codebooks