Commit beb7168452 for ffmpeg

commit beb716845250257b9ae42c5cd60ad8cf1847ea5a
Author: Martin Mirchev <mmirchev@comp.nus.edu.sg>
Date:   Sun Oct 18 16:30:57 2026 +0800

    swscale/output: write the last partial byte in the mono error-diffusion paths

    The SWS_DITHER_ED branches of yuv2mono_1_c_template() and
    yuv2mono_2_c_template() only store a byte when (i & 7) == 6, so for widths
    whose last pixel pair does not end a byte the final partial byte of each
    row is never written and keeps whatever the destination held. Converting a
    white 100x8 frame with -sws_flags +error_diffusion -pix_fmt monob leaves the
    last 4 pixels of rows 1-7 black (0x00 instead of 0xf0).

    Write the pending bits after the loop, shifted into the high bits as monob
    expects, like the non-ED paths.

    Signed-off-by: Martin Mirchev <mmirchev@comp.nus.edu.sg>

diff --git a/libswscale/output.c b/libswscale/output.c
index 760dca642e..5cc5cf026d 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -749,6 +749,8 @@ yuv2mono_2_c_template(SwsInternal *c, const int16_t *buf[2],
                 output_pixel(*dest++, acc);
         }
         c->dither_error[0][i] = err;
+        if (i & 6)
+            output_pixel(*dest, acc << (8 - (i & 7)));
     } else {
         for (i = 0; i < dstW; i += 8) {
             int Y;
@@ -807,6 +809,8 @@ yuv2mono_1_c_template(SwsInternal *c, const int16_t *buf0,
                 output_pixel(*dest++, acc);
         }
         c->dither_error[0][i] = err;
+        if (i & 6)
+            output_pixel(*dest, acc << (8 - (i & 7)));
     } else {
         for (i = 0; i < dstW; i += 8) {
             unsigned acc = 0;