diff mbox series

[FFmpeg-devel,13/13] avcodec/elbg: Add flags to avpriv_elbg_do()

Message ID AM7PR03MB6660B819C270F2122B15BA218FDD9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 6b2c1d10185592442988ec5332ac57eb48dea4b6
Headers show
Series [FFmpeg-devel,01/13] avcodec/elbg: Remove avoidable buffer
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 17, 2021, 2:08 a.m. UTC
This is currently unused and it is only added to enable changes
while maintaining ABI compatibility. The type is uintptr_t in order
to potentially accept a pointer argument.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/a64multienc.c | 2 +-
 libavcodec/cinepakenc.c  | 2 +-
 libavcodec/elbg.c        | 2 +-
 libavcodec/elbg.h        | 4 +++-
 libavcodec/msvideo1enc.c | 6 +++---
 libavcodec/roqvideoenc.c | 2 +-
 libavfilter/vf_elbg.c    | 2 +-
 7 files changed, 11 insertions(+), 9 deletions(-)

Comments

Paul B Mahol Sept. 17, 2021, 6:53 a.m. UTC | #1
lgtm
diff mbox series

Patch

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 71a620b4ff..c368ac218a 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -338,7 +338,7 @@  static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
             /* calc optimal new charset + charmaps */
             ret = avpriv_elbg_do(&c->elbg, meta, 32, 1000 * c->mc_lifetime,
-                                 best_cb, CHARSET_CHARS, 50, charmap, &c->randctx);
+                                 best_cb, CHARSET_CHARS, 50, charmap, &c->randctx, 0);
             if (ret < 0)
                 return ret;
 
diff --git a/libavcodec/cinepakenc.c b/libavcodec/cinepakenc.c
index d1bcf2b2d5..edb553f0db 100644
--- a/libavcodec/cinepakenc.c
+++ b/libavcodec/cinepakenc.c
@@ -764,7 +764,7 @@  static int quantize(CinepakEncContext *s, int h, uint8_t *data[4],
         size = i;
 
     ret = avpriv_elbg_do(&s->elbg, s->codebook_input, entry_size, i, codebook,
-                         size, 1, s->codebook_closest, &s->randctx);
+                         size, 1, s->codebook_closest, &s->randctx, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index 2bacf5b773..712c125a58 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -445,7 +445,7 @@  static void init_elbg(ELBGContext *elbg, int *points, int *temp_points,
 
 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)
+                   int *closest_cb, AVLFG *rand_state, uintptr_t flags)
 {
     ELBGContext *const elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg));
 
diff --git a/libavcodec/elbg.h b/libavcodec/elbg.h
index abeeb4ff44..34d96846b1 100644
--- a/libavcodec/elbg.h
+++ b/libavcodec/elbg.h
@@ -21,6 +21,7 @@ 
 #ifndef AVCODEC_ELBG_H
 #define AVCODEC_ELBG_H
 
+#include <stdint.h>
 #include "libavutil/lfg.h"
 
 struct ELBGContext;
@@ -41,11 +42,12 @@  struct ELBGContext;
  * @param num_steps The maximum number of steps. One step is already a good compromise between time and quality.
  * @param closest_cb Return the closest codebook to each point. Must be allocated.
  * @param rand_state A random number generator state. Should be already initialized by av_lfg_init().
+ * @param flags Currently unused; must be set to 0.
  * @return < 0 in case of error, 0 otherwise
  */
 int avpriv_elbg_do(struct ELBGContext **ctx, int *points, int dim,
                    int numpoints, int *codebook, int num_cb, int num_steps,
-                   int *closest_cb, AVLFG *rand_state);
+                   int *closest_cb, AVLFG *rand_state, uintptr_t flags);
 
 /**
  * Free an ELBGContext and reset the pointer to it.
diff --git a/libavcodec/msvideo1enc.c b/libavcodec/msvideo1enc.c
index 79810ec8c3..a8761bdd2e 100644
--- a/libavcodec/msvideo1enc.c
+++ b/libavcodec/msvideo1enc.c
@@ -119,7 +119,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             // try to find optimal value to fill whole 4x4 block
             score = 0;
             ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->avg,
-                                 1, 1, c->output, &c->rnd);
+                                 1, 1, c->output, &c->rnd, 0);
             if (ret < 0)
                 return ret;
             if(c->avg[0] == 1) // red component = 1 will be written as skip code
@@ -141,7 +141,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             // search for optimal filling of 2-color block
             score = 0;
             ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->codebook,
-                                 2, 1, c->output, &c->rnd);
+                                 2, 1, c->output, &c->rnd, 0);
             if (ret < 0)
                 return ret;
             // last output value should be always 1, swap codebooks if needed
@@ -170,7 +170,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             for(i = 0; i < 4; i++){
                 ret = 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);
+                                     c->output2 + i * 4, &c->rnd, 0);
                 if (ret < 0)
                     return ret;
             }
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 316adac45e..78c84c6f65 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -826,7 +826,7 @@  static int generate_codebook(RoqEncContext *enc,
     int *closest_cb = enc->closest_cb;
 
     ret = avpriv_elbg_do(&enc->elbg, points, 6 * c_size, inputCount, codebook,
-                         cbsize, 1, closest_cb, &enc->randctx);
+                         cbsize, 1, closest_cb, &enc->randctx, 0);
     if (ret < 0)
         return ret;
 
diff --git a/libavfilter/vf_elbg.c b/libavfilter/vf_elbg.c
index fac3b6f7fe..0bebcdbda5 100644
--- a/libavfilter/vf_elbg.c
+++ b/libavfilter/vf_elbg.c
@@ -167,7 +167,7 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
     ret = avpriv_elbg_do(&elbg->ctx, elbg->codeword, NB_COMPONENTS,
                          elbg->codeword_length, elbg->codebook,
                          elbg->codebook_length, elbg->max_steps_nb,
-                         elbg->codeword_closest_codebook_idxs, &elbg->lfg);
+                         elbg->codeword_closest_codebook_idxs, &elbg->lfg, 0);
     if (ret < 0) {
         av_frame_free(&frame);
         return ret;