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>
release/7.1
Andreas Rheinhardt 8 months ago
parent 182e647a64
commit cd2e46a350
  1. 1
      libavcodec/me_cmp.h
  2. 1
      libavcodec/mpegvideo.h
  3. 10
      libavcodec/mpegvideo_enc.c
  4. 1
      tests/checkasm/motion.c

@ -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];

@ -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;

@ -308,12 +308,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;
}
@ -931,9 +936,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);
@ -1311,7 +1313,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;

@ -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

Loading…
Cancel
Save