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

Git pushed a commit to branch master
in repository ffmpeg.

commit d67a6d27c25ae27d1997e0954cc4aded5d599f4c
Author:     Michael Niedermayer <[email protected]>
AuthorDate: Wed Jun 17 01:18:26 2026 +0200
Commit:     Michael Niedermayer <[email protected]>
CommitDate: Wed Jun 17 02:27:33 2026 +0200

    avcodec/snowenc: fix chroma reference edge extension for odd width
    
    When extending the edges of the reconstructed reference frame, the chroma
    plane width and height were passed to draw_edges() as w >> chroma_h_shift
    (floor) instead of AV_CEIL_RSHIFT(). For an odd width with subsampled chroma
    (e.g. 4:2:0) the chroma plane is one column wider than the floor, and
    draw_edges() replicates the edge columns, so it overwrote the last real
    chroma column with the previous one. The decoder does not draw_edges() its
    reference, so its copy kept the correct value: the encoder and decoder
    references diverged and every following inter frame was reconstructed
    differently by the two, breaking bit-exact (lossless) round-tripping and
    drifting lossy inter coding, for any odd-width 4:2:0 snow stream.
    
    Use AV_CEIL_RSHIFT(), matching the input_picture edge extension just above.
    
    Found-by: Claude
    Signed-off-by: Michael Niedermayer <[email protected]>
---
 libavcodec/snowenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 2142769dbd..8eb409d4bf 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1838,10 +1838,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
                                   EDGE_WIDTH  , EDGE_WIDTH  , EDGE_TOP | 
EDGE_BOTTOM);
         if (s->current_picture->data[2]) {
             enc->mpvencdsp.draw_edges(s->current_picture->data[1],
-                                      s->current_picture->linesize[1], 
w>>s->chroma_h_shift, h>>s->chroma_v_shift,
+                                      s->current_picture->linesize[1], 
AV_CEIL_RSHIFT(w, s->chroma_h_shift), AV_CEIL_RSHIFT(h, s->chroma_v_shift),
                                       EDGE_WIDTH>>s->chroma_h_shift, 
EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
             enc->mpvencdsp.draw_edges(s->current_picture->data[2],
-                                      s->current_picture->linesize[2], 
w>>s->chroma_h_shift, h>>s->chroma_v_shift,
+                                      s->current_picture->linesize[2], 
AV_CEIL_RSHIFT(w, s->chroma_h_shift), AV_CEIL_RSHIFT(h, s->chroma_v_shift),
                                       EDGE_WIDTH>>s->chroma_h_shift, 
EDGE_WIDTH>>s->chroma_v_shift, EDGE_TOP | EDGE_BOTTOM);
         }
     }

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to