diff --git a/libavcodec/me_cmp.h b/libavcodec/me_cmp.h index 67e3816829..4f964ca188 100644 --- a/libavcodec/me_cmp.h +++ b/libavcodec/me_cmp.h @@ -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]; diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 60dcf65288..df46433a82 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -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; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c4fc28e4d9..68f6ea0633 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -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; diff --git a/tests/checkasm/motion.c b/tests/checkasm/motion.c index 2bf49afc77..8f9915c63a 100644 --- a/tests/checkasm/motion.c +++ b/tests/checkasm/motion.c @@ -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