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/a64multienc.c | |
parent | 9e11debb5d5b1bd18f481e654f7515fc1eefde14 (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/a64multienc.c')
-rw-r--r-- | libavcodec/a64multienc.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 3d4bcf387d..00700ddcb7 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -43,6 +43,7 @@ typedef struct A64Context { /* variables for multicolor modes */ + struct ELBGContext *elbg; AVLFG randctx; int mc_lifetime; int mc_use_5col; @@ -195,6 +196,9 @@ static void render_charset(AVCodecContext *avctx, uint8_t *charset, static av_cold int a64multi_close_encoder(AVCodecContext *avctx) { A64Context *c = avctx->priv_data; + + avpriv_elbg_free(&c->elbg); + av_freep(&c->mc_meta_charset); av_freep(&c->mc_best_cb); av_freep(&c->mc_charmap); @@ -333,8 +337,8 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, buf = pkt->data; /* calc optimal new charset + charmaps */ - ret = avpriv_do_elbg(meta, 32, 1000 * c->mc_lifetime, best_cb, - CHARSET_CHARS, 50, charmap, &c->randctx); + ret = avpriv_elbg_do(&c->elbg, meta, 32, 1000 * c->mc_lifetime, + best_cb, CHARSET_CHARS, 50, charmap, &c->randctx); if (ret < 0) return ret; |