Commit 5ab56a3630 for ffmpeg

commit 5ab56a36302c3802f9f94d9efa31e1d4f67dc141
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date:   Sat Nov 21 12:13:01 2026 -0800

    avcodec/mpegvideo_enc: use the 4:4:4 chroma window for Quality Stats

    The chroma error assumed 8 pixel wide macroblocks.

    Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 476579d1ae..0ada755264 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2979,6 +2979,7 @@ int ff_mpv_reallocate_putbitbuffer(MPVEncContext *const s, size_t threshold, siz

 static int encode_thread(AVCodecContext *c, void *arg){
     MPVEncContext *const s = *(void**)arg;
+    int chr_w = 16 >> s->c.chroma_x_shift;
     int chr_h = 16 >> s->c.chroma_y_shift;
     int i;
     MBBackup best_s = { 0 }, backup_s;
@@ -3590,11 +3591,11 @@ static int encode_thread(AVCodecContext *c, void *arg){
                     s, s->new_pic->data[0] + s->c.mb_x*16 + s->c.mb_y*s->c.linesize*16,
                     s->c.dest[0], w, h, s->c.linesize);
                 s->encoding_error[1] += sse(
-                    s, s->new_pic->data[1] + s->c.mb_x*8  + s->c.mb_y*s->c.uvlinesize*chr_h,
-                    s->c.dest[1], w>>1, h>>s->c.chroma_y_shift, s->c.uvlinesize);
+                    s, s->new_pic->data[1] + s->c.mb_x*chr_w + s->c.mb_y*s->c.uvlinesize*chr_h,
+                    s->c.dest[1], w>>s->c.chroma_x_shift, h>>s->c.chroma_y_shift, s->c.uvlinesize);
                 s->encoding_error[2] += sse(
-                    s, s->new_pic->data[2] + s->c.mb_x*8  + s->c.mb_y*s->c.uvlinesize*chr_h,
-                    s->c.dest[2], w>>1, h>>s->c.chroma_y_shift, s->c.uvlinesize);
+                    s, s->new_pic->data[2] + s->c.mb_x*chr_w + s->c.mb_y*s->c.uvlinesize*chr_h,
+                    s->c.dest[2], w>>s->c.chroma_x_shift, h>>s->c.chroma_y_shift, s->c.uvlinesize);
             }
             if (s->loop_filter) {
                 if (CONFIG_H263_ENCODER && s->c.out_format == FMT_H263)
diff --git a/tests/ref/fate/ffmpeg-speedhq-444-psnr b/tests/ref/fate/ffmpeg-speedhq-444-psnr
index aa6b14733e..9a20abb42d 100644
--- a/tests/ref/fate/ffmpeg-speedhq-444-psnr
+++ b/tests/ref/fate/ffmpeg-speedhq-444-psnr
@@ -3,4 +3,4 @@
 #codec_id 0: speedhq
 #dimensions 0: 128x64
 #sar 0: 1/1
-0,          0,          0,        1,     5728, 0xc7b9b093, S=1, Quality stats,       32, 0x4df20471
+0,          0,          0,        1,     5728, 0xc7b9b093, S=1, Quality stats,       32, 0x50cf0497