1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avcodec/elbg: Increase some fields to 64bit

Fixes: Ticket8312
Fixes: Ticket8321

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-06-06 22:42:08 +02:00
parent e2c2872393
commit c1a49a1264

View File

@ -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;