avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext

MECmpContext has several arrays of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

One of these other users is mpegvideo_enc; it is the only user
of MECmpContext.frame_skip_cmp and it only uses one of these
function pointers at all.

This commit therefore moves this function pointer to MpegEncContext;
and removes the array from MECmpContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
Andreas Rheinhardt 2024-05-12 19:39:10 +02:00 committed by Paul B Mahol
parent 840eb90aba
commit d2c568bd77
4 changed files with 7 additions and 6 deletions

View File

@ -71,7 +71,6 @@ typedef struct MECmpContext {
me_cmp_func dct264_sad[6];
me_cmp_func ildct_cmp[6]; // only width 16 used
me_cmp_func frame_skip_cmp[6]; // only width 8 used
me_cmp_func pix_abs[2][4];
me_cmp_func median_sad[6];

View File

@ -542,6 +542,7 @@ typedef struct MpegEncContext {
int frame_skip_factor;
int frame_skip_exp;
int frame_skip_cmp;
me_cmp_func frame_skip_cmp_fn;
int scenechange_threshold;
int noise_reduction;

View File

@ -307,12 +307,17 @@ av_cold void ff_dct_encode_init(MpegEncContext *s)
static av_cold int me_cmp_init(MpegEncContext *s, AVCodecContext *avctx)
{
me_cmp_func me_cmp[6];
int ret;
ff_me_cmp_init(&s->mecc, avctx);
ret = ff_me_init(&s->me, avctx, &s->mecc);
if (ret < 0)
return ret;
ret = ff_set_cmp(&s->mecc, me_cmp, s->frame_skip_cmp);
if (ret < 0)
return ret;
s->frame_skip_cmp_fn = me_cmp[1];
return 0;
}
@ -930,9 +935,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
if (!s->mecc.ildct_cmp[0] || !s->mecc.ildct_cmp[4])
return AVERROR(EINVAL);
}
ret = ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->frame_skip_cmp);
if (ret < 0)
return AVERROR(EINVAL);
if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) {
ff_h263_encode_init(s);
@ -1310,7 +1312,7 @@ static int skip_check(MpegEncContext *s, const MPVPicture *p, const MPVPicture *
int off = p->shared ? 0 : 16;
const uint8_t *dptr = p->f->data[plane] + 8 * (x + y * stride) + off;
const uint8_t *rptr = ref->f->data[plane] + 8 * (x + y * stride);
int v = s->mecc.frame_skip_cmp[1](s, dptr, rptr, stride, 8);
int v = s->frame_skip_cmp_fn(s, dptr, rptr, stride, 8);
switch (FFABS(s->frame_skip_exp)) {
case 0: score = FFMAX(score, v); break;

View File

@ -95,7 +95,6 @@ static void test_motion(const char *name, me_cmp_func test_func)
XX(vsse) \
XX(nsse) \
XX(ildct_cmp) \
XX(frame_skip_cmp) \
XX(median_sad)
// tests for functions not yet implemented