aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/elbg.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-07-23 03:55:37 +0000
committerVitor Sessak <vitor1001@gmail.com>2008-07-23 03:55:37 +0000
commit6bf8b047640e9e8af726f21f146876c2c1f26f8d (patch)
tree6e382a8a9ae7cf2812aa89e29753efd894cf6299 /libavcodec/elbg.c
parent5916af1954f0c25f06e87d2076aaf536c684ed98 (diff)
downloadffmpeg-6bf8b047640e9e8af726f21f146876c2c1f26f8d.tar.gz
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. Originally committed as revision 14341 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/elbg.c')
-rw-r--r--libavcodec/elbg.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 9f8ed221a4..d56a0c3573 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -105,9 +105,12 @@ static int get_high_utility_cell(elbg_data *elbg)
{
int i=0;
/* Using linear search, do binary if it ever turns to be speed critical */
- int r = av_random(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1];
+ int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
while (elbg->utility_inc[i] < r)
i++;
+
+ assert(!elbg->cells[i]);
+
return i;
}