Mercurial > libavcodec.hg
changeset 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 |
files | elbg.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/elbg.c Wed Jul 23 03:54:31 2008 +0000 +++ b/elbg.c Wed Jul 23 03:55:37 2008 +0000 @@ -105,9 +105,12 @@ { 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; }