diff options
-rw-r--r-- | libavcodec/elbg.c | 5 |
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; } |