Hi,
While compiling 2.4 I'm seeind lots of warnings like this:
.../source/common/ipfilter.cpp: In instantiation of ‘void
{anonymous}::interp_horiz_ps_c(const pixel*, intptr_t, int16_t*,
intptr_t, int, int) [with int N = 8; int width = 4; int height = 4;
pixel = unsigned char; intptr_t = long int; int16_t = short int]’:
.../source/common/ipfilter.cpp:417:5: required from here
.../source/common/ipfilter.cpp:126:36: warning: left shift of negative
value [-Wshift-negative-value]
int offset = -IF_INTERNAL_OFFS << shift;
~~~~~~~~~~~~~~~~~~^~~~~~~~
Left-shifting negative signed intehers is undefined behavior in C++.
I've attached a patch that resolves the warnings. The patch assumes 2's
complement signed integers and that the shift does not introduce an
arithmetic overflow.
Index: x265-2.4+0-e7a4dd48293b/source/common/ipfilter.cpp
===================================================================
--- x265-2.4+0-e7a4dd48293b.orig/source/common/ipfilter.cpp 2017-04-26 17:22:40.548759520 +0300
+++ x265-2.4+0-e7a4dd48293b/source/common/ipfilter.cpp 2017-04-26 17:44:38.960479060 +0300
@@ -123,7 +123,7 @@ void interp_horiz_ps_c(const pixel* src,
const int16_t* coeff = (N == 4) ? g_chromaFilter[coeffIdx] : g_lumaFilter[coeffIdx];
int headRoom = IF_INTERNAL_PREC - X265_DEPTH;
int shift = IF_FILTER_PREC - headRoom;
- int offset = -IF_INTERNAL_OFFS << shift;
+ int offset = -(IF_INTERNAL_OFFS << shift);
int blkheight = height;
src -= N / 2 - 1;
@@ -209,7 +209,7 @@ void interp_vert_ps_c(const pixel* src,
const int16_t* c = (N == 4) ? g_chromaFilter[coeffIdx] : g_lumaFilter[coeffIdx];
int headRoom = IF_INTERNAL_PREC - X265_DEPTH;
int shift = IF_FILTER_PREC - headRoom;
- int offset = -IF_INTERNAL_OFFS << shift;
+ int offset = -(IF_INTERNAL_OFFS << shift);
src -= (N / 2 - 1) * srcStride;
_______________________________________________
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel