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/msvideo1enc.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/msvideo1enc.c')
-rw-r--r-- | libavcodec/msvideo1enc.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c index fa65a2fbc4..d43013ba5f 100644 --- a/libavcodec/msvideo1enc.c +++ b/libavcodec/msvideo1enc.c @@ -36,6 +36,7 @@ */ typedef struct Msvideo1EncContext { AVCodecContext *avctx; + struct ELBGContext *elbg; AVLFG rnd; uint8_t *prev; @@ -117,7 +118,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } // try to find optimal value to fill whole 4x4 block score = 0; - avpriv_do_elbg (c->block, 3, 16, c->avg, 1, 1, c->output, &c->rnd); + avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->avg, + 1, 1, c->output, &c->rnd); if(c->avg[0] == 1) // red component = 1 will be written as skip code c->avg[0] = 0; for(j = 0; j < 4; j++){ @@ -136,7 +138,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } // search for optimal filling of 2-color block score = 0; - avpriv_do_elbg (c->block, 3, 16, c->codebook, 2, 1, c->output, &c->rnd); + avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->codebook, + 2, 1, c->output, &c->rnd); // last output value should be always 1, swap codebooks if needed if(!c->output[15]){ for(i = 0; i < 3; i++) @@ -161,7 +164,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, // search for optimal filling of 2-color 2x2 subblocks score = 0; for(i = 0; i < 4; i++){ - avpriv_do_elbg (c->block2 + i*4*3, 3, 4, c->codebook2 + i*2*3, 2, 1, c->output2 + i*4, &c->rnd); + avpriv_elbg_do(&c->elbg, c->block2 + i * 4 * 3, 3, 4, + c->codebook2 + i * 2 * 3, 2, 1, + c->output2 + i*4, &c->rnd); } // last value should be always 1, swap codebooks if needed if(!c->output2[15]){ @@ -286,6 +291,7 @@ static av_cold int encode_end(AVCodecContext *avctx) Msvideo1EncContext * const c = avctx->priv_data; av_freep(&c->prev); + avpriv_elbg_free(&c->elbg); return 0; } |