Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-16 01:36:30 +0300
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-09-20 05:38:45 +0300
commit896c11687ecc2915f41ac6f04be1d6293bd8f158 (patch)
tree228e0b79ca4bc1ffcc40a0d221b65d9ccfdfcc9e /libavcodec/elbg.c
parent9e11debb5d5b1bd18f481e654f7515fc1eefde14 (diff)
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.c12
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);
+}