[x265] [PATCH] Eliminating decreament in pointer index in weightp primitives

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Tue Oct 22 14:07:53 CEST 2013


# HG changeset patch
# User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
# Date 1382443578 -19800
#      Tue Oct 22 17:36:18 2013 +0530
# Node ID ea1a532ef43ffaffe0f52119a9810c3d145572be
# Parent  f1bdacac64972a69ba4a6bb92c57e562ac50ff2c
Eliminating decreament in pointer index in weightp primitives


could have been a source of possible crash

diff -r f1bdacac6497 -r ea1a532ef43f source/common/pixel.cpp
--- a/source/common/pixel.cpp	Tue Oct 22 15:32:06 2013 +0530
+++ b/source/common/pixel.cpp	Tue Oct 22 17:36:18 2013 +0530
@@ -520,13 +520,13 @@
 {
     int x, y;
 
-    for (y = height - 1; y >= 0; y--)
+    for (y = 0; y <= height - 1; y++)
     {
-        for (x = width - 1; x >= 0; )
+        for (x = 0; x <= width - 1; )
         {
             // note: width can be odd
             dst[x] = (pixel)Clip3(0, ((1 << X265_DEPTH) - 1), ((w0 * (src[x] + IF_INTERNAL_OFFS) + round) >> shift) + offset);
-            x--;
+            x++;
         }
 
         src += srcStride;
@@ -537,14 +537,14 @@
 void weightUnidirPix(pixel *src, pixel *dst, intptr_t srcStride, intptr_t dstStride, int width, int height, int w0, int round, int shift, int offset)
 {
     int x, y;
-    for (y = height - 1; y >= 0; y--)
+    for (y = 0; y <= height - 1; y++)
     {
-        for (x = width - 1; x >= 0; )
+        for (x = 0; x <= width - 1; )
         {
             // simulating pixel to short conversion
             short val = src[x] << (IF_INTERNAL_PREC - X265_DEPTH);
             dst[x] = (pixel) Clip3(0, ((1 << X265_DEPTH) - 1), ((w0 * (val) + round) >> shift) + offset);
-            x--;
+            x++;
         }
 
         src += srcStride;


More information about the x265-devel mailing list