aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-05-12 19:39:10 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-06-20 18:58:38 +0200
commitcd2e46a3508d123db9d235b71dd06d495d1eecde (patch)
treecc6cafa142cdc9c87c81560b281a399ec08860db
parent182e647a64bc85f74a03da9f1c96c9111e7b27d4 (diff)
downloadffmpeg-cd2e46a3508d123db9d235b71dd06d495d1eecde.tar.gz
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>
-rw-r--r--libavcodec/me_cmp.h1
-rw-r--r--libavcodec/mpegvideo.h1
-rw-r--r--libavcodec/mpegvideo_enc.c10
-rw-r--r--tests/checkasm/motion.c1
4 files changed, 7 insertions, 6 deletions
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 5b8d877935..6ec8fa2e0b 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -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;
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