[x265] [PATCH STABLE] pixel: fix stride alignment checks to be byte based

Steve Borho steve at borho.org
Sun Mar 15 01:08:08 CET 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1426378068 18000
#      Sat Mar 14 19:07:48 2015 -0500
# Node ID b2d60e982388aff20ac65c89b5d835fe54f3bf41
# Parent  2e4cc42dd63f9bf518e51c954ff5aa1508369f25
pixel: fix stride alignment checks to be byte based

In order to check byte alignment of the stride, you must account for the size of
the data type.  This was causing check failures when the C references were used

diff -r 2e4cc42dd63f -r b2d60e982388 source/common/pixel.cpp
--- a/source/common/pixel.cpp	Sat Mar 14 14:06:20 2015 -0500
+++ b/source/common/pixel.cpp	Sat Mar 14 19:07:48 2015 -0500
@@ -428,7 +428,7 @@
 void cpy2Dto1D_shl(int16_t* dst, const int16_t* src, intptr_t srcStride, int shift)
 {
     X265_CHECK(((intptr_t)dst & 15) == 0, "dst alignment error\n");
-    X265_CHECK((((intptr_t)src | srcStride) & 15) == 0 || size == 4, "src alignment error\n");
+    X265_CHECK((((intptr_t)src | (srcStride * sizeof(*src))) & 15) == 0 || size == 4, "src alignment error\n");
     X265_CHECK(shift >= 0, "invalid shift\n");
 
     for (int i = 0; i < size; i++)
@@ -445,7 +445,7 @@
 void cpy2Dto1D_shr(int16_t* dst, const int16_t* src, intptr_t srcStride, int shift)
 {
     X265_CHECK(((intptr_t)dst & 15) == 0, "dst alignment error\n");
-    X265_CHECK((((intptr_t)src | srcStride) & 15) == 0 || size == 4, "src alignment error\n");
+    X265_CHECK((((intptr_t)src | (srcStride * sizeof(*src))) & 15) == 0 || size == 4, "src alignment error\n");
     X265_CHECK(shift > 0, "invalid shift\n");
 
     int16_t round = 1 << (shift - 1);
@@ -462,7 +462,7 @@
 template<int size>
 void cpy1Dto2D_shl(int16_t* dst, const int16_t* src, intptr_t dstStride, int shift)
 {
-    X265_CHECK((((intptr_t)dst | dstStride) & 15) == 0 || size == 4, "dst alignment error\n");
+    X265_CHECK((((intptr_t)dst | (dstStride * sizeof(*dst))) & 15) == 0 || size == 4, "dst alignment error\n");
     X265_CHECK(((intptr_t)src & 15) == 0, "src alignment error\n");
     X265_CHECK(shift >= 0, "invalid shift\n");
 
@@ -479,7 +479,7 @@
 template<int size>
 void cpy1Dto2D_shr(int16_t* dst, const int16_t* src, intptr_t dstStride, int shift)
 {
-    X265_CHECK((((intptr_t)dst | dstStride) & 15) == 0 || size == 4, "dst alignment error\n");
+    X265_CHECK((((intptr_t)dst | (dstStride * sizeof(*dst))) & 15) == 0 || size == 4, "dst alignment error\n");
     X265_CHECK(((intptr_t)src & 15) == 0, "src alignment error\n");
     X265_CHECK(shift > 0, "invalid shift\n");
 


More information about the x265-devel mailing list