diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-16 00:36:30 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-09-20 04:38:45 +0200 |
commit | 896c11687ecc2915f41ac6f04be1d6293bd8f158 (patch) | |
tree | 228e0b79ca4bc1ffcc40a0d221b65d9ccfdfcc9e /libavcodec/elbg.c | |
parent | 9e11debb5d5b1bd18f481e654f7515fc1eefde14 (diff) | |
download | ffmpeg-896c11687ecc2915f41ac6f04be1d6293bd8f158.tar.gz |
avcodec/elbg: Add persistent ELBGContext
It will be used in future commits to avoid having to allocate and free
all the buffers used.
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/elbg.c')
-rw-r--r-- | libavcodec/elbg.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c index ac5c53161d..9eac802688 100644 --- a/libavcodec/elbg.c +++ b/libavcodec/elbg.c @@ -466,12 +466,17 @@ static int init_elbg(int *points, int dim, int numpoints, int *codebook, return ret; } -int avpriv_do_elbg(int *points, int dim, int numpoints, +int avpriv_elbg_do(ELBGContext **elbgp, int *points, int dim, int numpoints, int *codebook, int num_cb, int max_steps, int *closest_cb, AVLFG *rand_state) { + ELBGContext *const elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg)); int ret; + if (!elbg) + return AVERROR(ENOMEM); + *elbgp = elbg; + ret = init_elbg(points, dim, numpoints, codebook, num_cb, max_steps, closest_cb, rand_state); if (ret < 0) @@ -479,3 +484,8 @@ int avpriv_do_elbg(int *points, int dim, int numpoints, return do_elbg (points, dim, numpoints, codebook, num_cb, max_steps, closest_cb, rand_state); } + +av_cold void avpriv_elbg_free(ELBGContext **elbgp) +{ + av_freep(elbgp); +} |