1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00

avcodec/elbg: Add flags to avpriv_elbg_do()

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.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2021-09-16 20:10:56 +02:00
parent 6afad4c7e9
commit 6b2c1d1018
7 changed files with 11 additions and 9 deletions

View File

@@ -338,7 +338,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
/* calc optimal new charset + charmaps */ /* calc optimal new charset + charmaps */
ret = avpriv_elbg_do(&c->elbg, meta, 32, 1000 * c->mc_lifetime, 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) if (ret < 0)
return ret; return ret;

View File

@@ -764,7 +764,7 @@ static int quantize(CinepakEncContext *s, int h, uint8_t *data[4],
size = i; size = i;
ret = avpriv_elbg_do(&s->elbg, s->codebook_input, entry_size, i, codebook, 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) if (ret < 0)
return ret; return ret;

View File

@@ -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 avpriv_elbg_do(ELBGContext **elbgp, int *points, int dim, int numpoints,
int *codebook, int num_cb, int max_steps, 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)); ELBGContext *const elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg));

View File

@@ -21,6 +21,7 @@
#ifndef AVCODEC_ELBG_H #ifndef AVCODEC_ELBG_H
#define AVCODEC_ELBG_H #define AVCODEC_ELBG_H
#include <stdint.h>
#include "libavutil/lfg.h" #include "libavutil/lfg.h"
struct ELBGContext; 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 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 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 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 * @return < 0 in case of error, 0 otherwise
*/ */
int avpriv_elbg_do(struct ELBGContext **ctx, int *points, int dim, int avpriv_elbg_do(struct ELBGContext **ctx, int *points, int dim,
int numpoints, int *codebook, int num_cb, int num_steps, 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. * Free an ELBGContext and reset the pointer to it.

View File

@@ -119,7 +119,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
// try to find optimal value to fill whole 4x4 block // try to find optimal value to fill whole 4x4 block
score = 0; score = 0;
ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->avg, 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) if (ret < 0)
return ret; return ret;
if(c->avg[0] == 1) // red component = 1 will be written as skip code 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 // search for optimal filling of 2-color block
score = 0; score = 0;
ret = avpriv_elbg_do(&c->elbg, c->block, 3, 16, c->codebook, 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) if (ret < 0)
return ret; return ret;
// last output value should be always 1, swap codebooks if needed // 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++){ for(i = 0; i < 4; i++){
ret = avpriv_elbg_do(&c->elbg, c->block2 + i * 4 * 3, 3, 4, ret = avpriv_elbg_do(&c->elbg, c->block2 + i * 4 * 3, 3, 4,
c->codebook2 + i * 2 * 3, 2, 1, c->codebook2 + i * 2 * 3, 2, 1,
c->output2 + i * 4, &c->rnd); c->output2 + i * 4, &c->rnd, 0);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }

View File

@@ -826,7 +826,7 @@ static int generate_codebook(RoqEncContext *enc,
int *closest_cb = enc->closest_cb; int *closest_cb = enc->closest_cb;
ret = avpriv_elbg_do(&enc->elbg, points, 6 * c_size, inputCount, codebook, 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) if (ret < 0)
return ret; return ret;

View File

@@ -167,7 +167,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
ret = avpriv_elbg_do(&elbg->ctx, elbg->codeword, NB_COMPONENTS, ret = avpriv_elbg_do(&elbg->ctx, elbg->codeword, NB_COMPONENTS,
elbg->codeword_length, elbg->codebook, elbg->codeword_length, elbg->codebook,
elbg->codebook_length, elbg->max_steps_nb, 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) { if (ret < 0) {
av_frame_free(&frame); av_frame_free(&frame);
return ret; return ret;