diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-05-12 23:15:46 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-06-20 18:58:38 +0200 |
commit | d163eefd4756111d188c40b3ee4b6cd91e8b9d64 (patch) | |
tree | f8853253d36018ff6edf0e5aea710aa5a220d7cc /libavcodec/motion_est.c | |
parent | b1a31b32abc19df329cf61fa23febd8252978fd3 (diff) | |
download | ffmpeg-d163eefd4756111d188c40b3ee4b6cd91e8b9d64.tar.gz |
avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcs
Several of the potential choices of comparison functions
need an initialized MpegEncContext (initialized for encoding,
not only ff_mpv_common_init()) or they crash when called.
Modify ff_set_cmp() to check for this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/motion_est.c')
-rw-r--r-- | libavcodec/motion_est.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index b29d0c6d96..13f3d8040e 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -305,7 +305,8 @@ static int zero_cmp(MpegEncContext *s, const uint8_t *a, const uint8_t *b, static void zero_hpel(uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h){ } -av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, const MECmpContext *mecc) +av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, + const MECmpContext *mecc, int mpvenc) { int cache_size = FFMIN(ME_MAP_SIZE>>ME_MAP_SHIFT, 1<<ME_MAP_SHIFT); int dia_size = FFMAX(FFABS(avctx->dia_size) & 255, FFABS(avctx->pre_dia_size) & 255); @@ -324,10 +325,10 @@ av_cold int ff_me_init(MotionEstContext *c, AVCodecContext *avctx, const MECmpCo if (cache_size < 2 * dia_size) av_log(avctx, AV_LOG_INFO, "ME_MAP size may be a little small for the selected diamond size\n"); - ret = ff_set_cmp(mecc, c->me_pre_cmp, avctx->me_pre_cmp); - ret |= ff_set_cmp(mecc, c->me_cmp, avctx->me_cmp); - ret |= ff_set_cmp(mecc, c->me_sub_cmp, avctx->me_sub_cmp); - ret |= ff_set_cmp(mecc, c->mb_cmp, avctx->mb_cmp); + ret = ff_set_cmp(mecc, c->me_pre_cmp, avctx->me_pre_cmp, mpvenc); + ret |= ff_set_cmp(mecc, c->me_cmp, avctx->me_cmp, mpvenc); + ret |= ff_set_cmp(mecc, c->me_sub_cmp, avctx->me_sub_cmp, mpvenc); + ret |= ff_set_cmp(mecc, c->mb_cmp, avctx->mb_cmp, mpvenc); if (ret < 0) return ret; |