[FFmpeg-cvslog] avcodec/texturedspenc: Fix indexing in color distribution determination

Michael Niedermayer git at videolan.org
Mon Oct 10 16:55:51 EEST 2022


ffmpeg | branch: release/4.1 | Michael Niedermayer <michael at niedermayer.cc> | Mon Jan  2 00:28:33 2017 +0100| [dc4d0f630bcd6f0654e633851176aeb1633ef711] | committer: Michael Niedermayer

avcodec/texturedspenc: Fix indexing in color distribution determination

Fixes CID1396405

MSE and PSNR is slightly improved, and some noticable corruptions disappear as
well.

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Marton Balint <cus at passwd.hu>
(cherry picked from commit ade36d61de8ea5a5acb30a05a0cbcda069127143)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc4d0f630bcd6f0654e633851176aeb1633ef711
---

 libavcodec/texturedspenc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/texturedspenc.c b/libavcodec/texturedspenc.c
index 3d68e0cf39..5ce72cbd1e 100644
--- a/libavcodec/texturedspenc.c
+++ b/libavcodec/texturedspenc.c
@@ -255,11 +255,11 @@ static void optimize_colors(const uint8_t *block, ptrdiff_t stride,
 
         muv = minv = maxv = bp[0];
         for (y = 0; y < 4; y++) {
-            for (x = 4; x < 4; x += 4) {
+            for (x = 0; x < 4; x++) {
                 muv += bp[x * 4 + y * stride];
-                if (bp[x] < minv)
+                if (bp[x * 4 + y * stride] < minv)
                     minv = bp[x * 4 + y * stride];
-                else if (bp[x] > maxv)
+                else if (bp[x * 4 + y * stride] > maxv)
                     maxv = bp[x * 4 + y * stride];
             }
         }



More information about the ffmpeg-cvslog mailing list