This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit bf0a2e4680df92d8de6514090d350152eb7845b8
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Thu Sep 17 18:41:48 2026 +0200
Commit:     michaelni <[email protected]>
CommitDate: Sat Sep 19 18:47:12 2026 +0000

    avcodec/motion_est: scale the B frame vector predictors with the exact 
frame distances
    
    Fixes: division by zero
    Fixes: 1XvjZP0UGl6O
    Found-by: Gabe Sherman (Trail of Bits)
---
 libavcodec/motion_est.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 894fa85576..492336ca54 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1149,11 +1149,12 @@ static int estimate_motion_b(MPVEncContext *const s, 
int mb_x, int mb_y,
         c->pred_x = P_LEFT[0];
         c->pred_y = P_LEFT[1];
 
-        if(mv_table == s->b_forw_mv_table){
-            mv_scale= (s->c.pb_time<<16) / (s->c.pp_time<<shift);
-        }else{
-            mv_scale = ((s->c.pb_time - s->c.pp_time) * (1 << 16)) / 
(s->c.pp_time<<shift);
-        }
+        int64_t pp = s->c.next_pic.ptr->f->pts - s->c.last_pic.ptr->f->pts;
+        int64_t pb = s->c. cur_pic.ptr->f->pts - s->c.last_pic.ptr->f->pts;
+        if (mv_table == s->b_forw_mv_table)
+            mv_scale = (pb << (16 - shift)) / pp;
+        else
+            mv_scale = (pb - pp) * (1 << (16 - shift)) / pp;
 
         dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, 
s->p_mv_table, mv_scale, 0, 16);
     }

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to