[FFmpeg-cvslog] avcodec/elbg: Increase some fields to 64bit

Michael Niedermayer git at videolan.org
Wed Sep 15 20:58:25 EEST 2021


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Jun  6 22:42:08 2021 +0200| [c1a49a1264926039fabdeb1c51909fc2c34e2414] | committer: Michael Niedermayer

avcodec/elbg: Increase some fields to 64bit

Fixes: Ticket8312
Fixes: Ticket8321

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c1a49a1264926039fabdeb1c51909fc2c34e2414
---

 libavcodec/elbg.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 377d5209cf..d012d9a384 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -44,12 +44,12 @@ typedef struct cell_s {
  * ELBG internal data
  */
 typedef struct elbg_data {
-    int error;
+    int64_t error;
     int dim;
     int numCB;
     int *codebook;
     cell **cells;
-    int *utility;
+    int64_t *utility;
     int64_t *utility_inc;
     int *nearest_cb;
     int *points;
@@ -264,7 +264,8 @@ static void update_utility_and_n_cb(elbg_data *elbg, int idx, int newutility)
  */
 static void try_shift_candidate(elbg_data *elbg, int idx[3])
 {
-    int j, k, olderror=0, newerror, cont=0;
+    int j, k, cont=0;
+    int64_t olderror=0, newerror;
     int newutility[3];
     int *newcentroid[3] = {
         elbg->scratchbuf,
@@ -374,19 +375,20 @@ int avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
     int dist;
     elbg_data elbg_d;
     elbg_data *elbg = &elbg_d;
-    int i, j, k, last_error, steps = 0, ret = 0;
+    int i, j, k, steps = 0, ret = 0;
     int *dist_cb = av_malloc_array(numpoints, sizeof(int));
     int *size_part = av_malloc_array(numCB, sizeof(int));
     cell *list_buffer = av_malloc_array(numpoints, sizeof(cell));
     cell *free_cells;
     int best_dist, best_idx = 0;
+    int64_t last_error;
 
-    elbg->error = INT_MAX;
+    elbg->error = INT64_MAX;
     elbg->dim = dim;
     elbg->numCB = numCB;
     elbg->codebook = codebook;
     elbg->cells = av_malloc_array(numCB, sizeof(cell *));
-    elbg->utility = av_malloc_array(numCB, sizeof(int));
+    elbg->utility = av_malloc_array(numCB, sizeof(*elbg->utility));
     elbg->nearest_cb = closest_cb;
     elbg->points = points;
     elbg->utility_inc = av_malloc_array(numCB, sizeof(*elbg->utility_inc));
@@ -404,7 +406,7 @@ int avpriv_do_elbg(int *points, int dim, int numpoints, int *codebook,
         free_cells = list_buffer;
         last_error = elbg->error;
         steps++;
-        memset(elbg->utility, 0, numCB*sizeof(int));
+        memset(elbg->utility, 0, numCB*sizeof(*elbg->utility));
         memset(elbg->cells, 0, numCB*sizeof(cell *));
 
         elbg->error = 0;



More information about the ffmpeg-cvslog mailing list