[FFmpeg-devel] [PATCH 26/57] avcodec/motion_est: Store remaining required me_cmp_funcs

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jun 12 16:48:22 EEST 2024


This avoids using MpegEncContext.mecc; it already allows
to avoid touching the latter for snowenc and svq1enc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/motion_est.c | 7 +++++--
 libavcodec/motion_est.h | 3 +++
 libavcodec/snowenc.c    | 1 -
 libavcodec/svq1enc.c    | 1 -
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 13f3d8040e..e783e79a94 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -332,6 +332,9 @@ av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx,
     if (ret < 0)
         return ret;
 
+    c->sse = mecc->sse[0];
+    memcpy(c->pix_abs, mecc->pix_abs, sizeof(c->pix_abs));
+
     c->flags     = get_flags(c, 0, avctx->me_cmp     & FF_CMP_CHROMA);
     c->sub_flags = get_flags(c, 0, avctx->me_sub_cmp & FF_CMP_CHROMA);
     c->mb_flags  = get_flags(c, 0, avctx->mb_cmp     & FF_CMP_CHROMA);
@@ -397,7 +400,7 @@ void ff_me_init_pic(MpegEncContext *s)
 
 #define CHECK_SAD_HALF_MV(suffix, x, y) \
 {\
-    d  = s->mecc.pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \
+    d  = c->pix_abs[size][(x ? 1 : 0) + (y ? 2 : 0)](NULL, pix, ptr + ((x) >> 1), stride, h); \
     d += (mv_penalty[pen_x + x] + mv_penalty[pen_y + y])*penalty_factor;\
     COPY3_IF_LT(dminh, d, dx, x, dy, y)\
 }
@@ -973,7 +976,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
     /* At this point (mx,my) are full-pell and the relative displacement */
     ppix = c->ref[0][0] + (my * s->linesize) + mx;
 
-    vard = s->mecc.sse[0](NULL, pix, ppix, s->linesize, 16);
+    vard = c->sse(NULL, pix, ppix, s->linesize, 16);
 
     s->mc_mb_var[s->mb_stride * mb_y + mb_x] = (vard+128)>>8;
     c->mc_mb_var_sum_temp += (vard+128)>>8;
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 243b73ff4e..12f7cd43ab 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -89,6 +89,9 @@ typedef struct MotionEstContext {
     me_cmp_func me_sub_cmp[6];
     me_cmp_func mb_cmp[6];
 
+    me_cmp_func pix_abs[2][4];
+    me_cmp_func sse;
+
     op_pixels_func(*hpel_put)[4];
     op_pixels_func(*hpel_avg)[4];
     qpel_mc_func(*qpel_put)[16];
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 819a7933fe..9db4314efb 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1869,7 +1869,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         mpv->qscale = (mpv->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
         enc->lambda2  = mpv->lambda2 = (mpv->lambda*mpv->lambda + FF_LAMBDA_SCALE/2) >> FF_LAMBDA_SHIFT;
 
-        mpv->mecc = enc->mecc; //move
         mpv->qdsp = enc->qdsp; //move
         mpv->hdsp = s->hdsp;
         ff_me_init_pic(&enc->m);
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 5413508217..6e687166b8 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -373,7 +373,6 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
         s->m.cur_pic.motion_val[0]   = s->motion_val8[plane] + 2;
         s->m.p_mv_table                      = s->motion_val16[plane] +
                                                s->m.mb_stride + 1;
-        s->m.mecc                            = s->mecc; // move
         ff_me_init_pic(&s->m);
 
         s->m.me.dia_size      = s->avctx->dia_size;
-- 
2.40.1



More information about the ffmpeg-devel mailing list