[FFmpeg-cvslog] avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext

Andreas Rheinhardt git at videolan.org
Thu Jul 3 21:55:48 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Jun 19 15:35:20 2025 +0200| [273de7f60c04cab886a18a136b47f35297f6b472] | committer: Andreas Rheinhardt

avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=273de7f60c04cab886a18a136b47f35297f6b472
---

 libavcodec/motion_est.c    |  4 ++--
 libavcodec/motion_est.h    |  1 +
 libavcodec/mpegvideo.h     |  1 -
 libavcodec/mpegvideo_enc.c | 18 +++++++++---------
 libavcodec/rv20enc.c       |  2 +-
 libavcodec/snowenc.c       |  2 +-
 libavcodec/svq1enc.c       |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 333048d1c8..93be712cc0 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -551,7 +551,7 @@ static inline void get_limits(MPVEncContext *const s, int x, int y, int bframe)
     if(c->avctx->me_range) c->range= c->avctx->me_range >> 1;
     else                   c->range= 16;
 */
-    if (s->c.unrestricted_mv) {
+    if (c->unrestricted_mv) {
         c->xmin = - x - 16;
         c->ymin = - y - 16;
         c->xmax = - x + s->c.width;
@@ -600,7 +600,7 @@ static inline int h263_mv4_search(MPVEncContext *const s, int mx, int my, int sh
     int same=1;
     const int stride= c->stride;
     const uint8_t *mv_penalty = c->current_mv_penalty;
-    int safety_clipping = s->c.unrestricted_mv && (s->c.width&15) && (s->c.height&15);
+    int safety_clipping = c->unrestricted_mv && (s->c.width&15) && (s->c.height&15);
 
     init_mv4_ref(c);
 
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index 89a2f41b75..7e57a3a79b 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -69,6 +69,7 @@ typedef struct MotionEstContext {
     int mb_flags;
     int pre_pass;                   ///< = 1 for the pre pass
     int dia_size;
+    int unrestricted_mv;            ///< mv can point outside of the coded picture
     int xmin;
     int xmax;
     int ymin;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index a439c1878b..d95cebedd8 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -164,7 +164,6 @@ typedef struct MpegEncContext {
     int droppable;
 
     /* motion compensation */
-    int unrestricted_mv;        ///< mv can point outside of the coded picture
     int h263_long_vectors;      ///< use horrible H.263v1 long vector mode
 
     BlockDSPContext bdsp;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 8a38e54982..afdc2fb787 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -926,7 +926,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         s->c.h263_aic        = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0;
         s->c.modified_quant  = s->c.h263_aic;
         s->c.loop_filter     = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
-        s->c.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
+        s->me.unrestricted_mv = s->c.obmc || s->c.loop_filter || s->c.umvplus;
         s->flipflop_rounding = 1;
 
         /* /Fx */
@@ -937,7 +937,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_FLV1:
         s->c.out_format      = FMT_H263;
         s->c.h263_flv        = 2; /* format = 1; 11-bit codes */
-        s->c.unrestricted_mv = 1;
+        s->me.unrestricted_mv = 1;
         s->rtp_mode  = 0; /* don't allow GOB */
         avctx->delay = 0;
         s->c.low_delay = 1;
@@ -961,13 +961,13 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
         // will be set later on a per-frame basis.
         s->c.h263_aic        = 1;
         s->c.loop_filter     = 1;
-        s->c.unrestricted_mv = 0;
+        s->me.unrestricted_mv = 0;
         break;
 #endif
     case AV_CODEC_ID_MPEG4:
         s->c.out_format      = FMT_H263;
         s->c.h263_pred       = 1;
-        s->c.unrestricted_mv = 1;
+        s->me.unrestricted_mv = 1;
         s->flipflop_rounding = 1;
         s->c.low_delay       = m->max_b_frames ? 0 : 1;
         avctx->delay       = s->c.low_delay ? 0 : (m->max_b_frames + 1);
@@ -975,7 +975,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_MSMPEG4V2:
         s->c.out_format      = FMT_H263;
         s->c.h263_pred       = 1;
-        s->c.unrestricted_mv = 1;
+        s->me.unrestricted_mv = 1;
         s->c.msmpeg4_version = MSMP4_V2;
         avctx->delay       = 0;
         s->c.low_delay       = 1;
@@ -983,7 +983,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_MSMPEG4V3:
         s->c.out_format        = FMT_H263;
         s->c.h263_pred         = 1;
-        s->c.unrestricted_mv   = 1;
+        s->me.unrestricted_mv = 1;
         s->c.msmpeg4_version   = MSMP4_V3;
         s->flipflop_rounding = 1;
         avctx->delay         = 0;
@@ -992,7 +992,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_WMV1:
         s->c.out_format        = FMT_H263;
         s->c.h263_pred         = 1;
-        s->c.unrestricted_mv   = 1;
+        s->me.unrestricted_mv = 1;
         s->c.msmpeg4_version   = MSMP4_WMV1;
         s->flipflop_rounding = 1;
         avctx->delay         = 0;
@@ -1001,7 +1001,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
     case AV_CODEC_ID_WMV2:
         s->c.out_format        = FMT_H263;
         s->c.h263_pred         = 1;
-        s->c.unrestricted_mv   = 1;
+        s->me.unrestricted_mv = 1;
         s->c.msmpeg4_version   = MSMP4_WMV2;
         s->flipflop_rounding = 1;
         avctx->delay         = 0;
@@ -1867,7 +1867,7 @@ static void frame_end(MPVMainEncContext *const m)
 {
     MPVEncContext *const s = &m->s;
 
-    if (s->c.unrestricted_mv &&
+    if (s->me.unrestricted_mv &&
         s->c.cur_pic.reference &&
         !m->intra_only) {
         int hshift = s->c.chroma_x_shift;
diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c
index 5c3850c12f..ef2228bb26 100644
--- a/libavcodec/rv20enc.c
+++ b/libavcodec/rv20enc.c
@@ -51,7 +51,7 @@ int ff_rv20_encode_picture_header(MPVMainEncContext *const m)
     put_bits(&s->pb, 1, s->c.no_rounding);
 
     av_assert1(s->f_code == 1);
-    av_assert1(!s->c.unrestricted_mv);
+    av_assert1(!s->me.unrestricted_mv);
     av_assert1(!s->c.alt_inter_vlc);
     av_assert1(!s->c.umvplus);
     av_assert1(s->c.modified_quant == 1);
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 661c6b3c07..68da7f55e7 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1869,7 +1869,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         mpv->me.dia_size = avctx->dia_size;
         mpv->c.quarter_sample  = (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0;
         mpv->c.out_format      = FMT_H263;
-        mpv->c.unrestricted_mv = 1;
+        mpv->me.unrestricted_mv = 1;
 
         mpv->lambda   = enc->lambda;
         mpv->c.qscale = (mpv->lambda*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7);
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index 0816252c2f..ed3dca9025 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -333,7 +333,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
         s2->pict_type                     = s->pict_type;
         s->m.me.scene_change_score        = 0;
         // s2->out_format                    = FMT_H263;
-        // s2->unrestricted_mv               = 1;
+        // s->m.me.unrestricted_mv           = 1;
         s->m.lambda                       = s->quality;
         s2->qscale                        = s->m.lambda * 139 +
                                              FF_LAMBDA_SCALE * 64 >>



More information about the ffmpeg-cvslog mailing list