[FFmpeg-cvslog] avcodec/mpegvideo: Move motion_est to MotionEstContext
Andreas Rheinhardt
git at videolan.org
Wed Mar 26 06:10:38 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Mar 19 00:48:33 2025 +0100| [6a42abe5611358783e790012c74f2986664a5481] | committer: Andreas Rheinhardt
avcodec/mpegvideo: Move motion_est to MotionEstContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a42abe5611358783e790012c74f2986664a5481
---
libavcodec/motion_est.c | 7 ++++---
libavcodec/motion_est.h | 1 +
libavcodec/mpegvideo.h | 1 -
libavcodec/mpegvideoenc.h | 2 +-
libavcodec/snowenc.c | 2 +-
libavcodec/svq1enc.c | 5 +----
6 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 7c08fe53eb..88164de6a5 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -919,7 +919,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
s->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
c->mb_var_sum_temp += (varc+128)>>8;
- if (s->motion_est != FF_ME_ZERO) {
+ if (c->motion_est != FF_ME_ZERO) {
const int mot_stride = s->b8_stride;
const int mot_xy = s->block_index[0];
@@ -1127,7 +1127,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
get_limits(s, 16*mb_x, 16*mb_y, 1);
- if (s->motion_est != FF_ME_ZERO) {
+ if (c->motion_est != FF_ME_ZERO) {
P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1];
@@ -1599,8 +1599,9 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
int ff_get_best_fcode(MPVMainEncContext *const m, const int16_t (*mv_table)[2], int type)
{
MpegEncContext *const s = &m->s;
+ MotionEstContext *const c = &s->me;
- if (s->motion_est != FF_ME_ZERO) {
+ if (c->motion_est != FF_ME_ZERO) {
int score[8];
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
const uint8_t * fcode_tab = m->fcode_tab;
diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h
index d8a2cab3a0..5fa96161c6 100644
--- a/libavcodec/motion_est.h
+++ b/libavcodec/motion_est.h
@@ -48,6 +48,7 @@ typedef struct MPVMainEncContext MPVMainEncContext;
*/
typedef struct MotionEstContext {
AVCodecContext *avctx;
+ int motion_est; ///< ME algorithm
int skip; ///< set if ME is skipped for the current MB
int co_located_mv[4][2]; ///< mv from last P-frame for direct mode ME
int direct_basis_mv[4][2];
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 1ff2924052..85227fdb8f 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -222,7 +222,6 @@ typedef struct MpegEncContext {
uint8_t *mb_mean; ///< Table for MB luminance
uint64_t encoding_error[MPV_MAX_PLANES];
- int motion_est; ///< ME algorithm
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h
index 61535db9f0..636a9e6614 100644
--- a/libavcodec/mpegvideoenc.h
+++ b/libavcodec/mpegvideoenc.h
@@ -217,7 +217,7 @@ FF_MPV_OPT_CMP_FUNC, \
#define FF_MPV_COMMON_MOTION_EST_OPTS \
{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "mpv_flags" },\
-{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
+{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(me.motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion_est" }, \
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index e6cf2a290c..fc2a56a808 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1866,7 +1866,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
mpv->b8_stride = 2 * mpv->mb_width + 1;
mpv->f_code = 1;
mpv->pict_type = pic->pict_type;
- mpv->motion_est = enc->motion_est;
+ mpv->me.motion_est = enc->motion_est;
mpv->me.scene_change_score = 0;
mpv->me.dia_size = avctx->dia_size;
mpv->quarter_sample = (s->avctx->flags & AV_CODEC_FLAG_QPEL)!=0;
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index cf0ab64d79..f3a1916b83 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -96,8 +96,6 @@ typedef struct SVQ1EncContext {
uint8_t *scratchbuf;
- int motion_est;
-
SVQ1EncDSPContext svq1encdsp;
} SVQ1EncContext;
@@ -339,7 +337,6 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
s->m.b8_stride = 2 * s->m.mb_width + 1;
s->m.f_code = 1;
s->m.pict_type = s->pict_type;
- s->m.motion_est = s->motion_est;
s->m.me.scene_change_score = 0;
// s->m.out_format = FMT_H263;
// s->m.unrestricted_mv = 1;
@@ -719,7 +716,7 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
#define OFFSET(x) offsetof(struct SVQ1EncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "motion-est", "Motion estimation algorithm", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, VE, .unit = "motion-est"},
+ { "motion-est", "Motion estimation algorithm", OFFSET(m.me.motion_est), AV_OPT_TYPE_INT, { .i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, VE, .unit = "motion-est"},
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion-est" },
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion-est" },
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, .unit = "motion-est" },
More information about the ffmpeg-cvslog
mailing list