[x265] [PATCH] silence MSVC warning C4334 and GCC warnings for '-std=gnu++11'

Mateusz Brzostek mateusz at msystem.waw.pl
Thu Apr 20 22:00:21 CEST 2017


This patch fixes issue #329 for MSVC
and if someone wants to compile with GCC for '-std=gnu++11' instead of default gnu++98, there will be no
f:/x265p/source/common/ipfilter.cpp:212:36: warning: left shift of negative value [-Wshift-negative-value]
     int offset = -IF_INTERNAL_OFFS << shift;
                  ~~~~~~~~~~~~~~~~~~^~~~~~~~
warnings.

# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1492717375 -7200
#      Thu Apr 20 21:42:55 2017 +0200
# Node ID 519968083ab2ea9682d051d88049d003130645c9
# Parent  2c6e6c9c3da72aaddb33565d7031918fb5a37097
silence MSVC warning C4334 and GCC warnings for '-std=gnu++11'

diff -r 2c6e6c9c3da7 -r 519968083ab2 source/common/ipfilter.cpp
--- a/source/common/ipfilter.cpp    Thu Apr 20 11:08:02 2017 +0530
+++ b/source/common/ipfilter.cpp    Thu Apr 20 21:42:55 2017 +0200
@@ -123,7 +123,7 @@
     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 = (unsigned)-IF_INTERNAL_OFFS << shift;
     int blkheight = height;
 
     src -= N / 2 - 1;
@@ -209,7 +209,7 @@
     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 = (unsigned)-IF_INTERNAL_OFFS << shift;
 
     src -= (N / 2 - 1) * srcStride;
 
diff -r 2c6e6c9c3da7 -r 519968083ab2 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp    Thu Apr 20 11:08:02 2017 +0530
+++ b/source/encoder/encoder.cpp    Thu Apr 20 21:42:55 2017 +0200
@@ -2823,7 +2823,7 @@
         analysisFrameData->distortion[count] = distortionBuf[d];
         analysisFrameData->ctuDistortion[ctuCount] += analysisFrameData->distortion[count];
         count += bytes;
-        if ((count % (size_t)NUM_4x4_PARTITIONS) == 0)
+        if ((count % (unsigned)NUM_4x4_PARTITIONS) == 0)
         {
             analysisFrameData->scaledDistortion[ctuCount] = X265_LOG2(X265_MAX(analysisFrameData->ctuDistortion[ctuCount], 1));
             sum += analysisFrameData->scaledDistortion[ctuCount];

-------------- next part --------------
# HG changeset patch
# User Ma0 <mateuszb at poczta.onet.pl>
# Date 1492717375 -7200
#      Thu Apr 20 21:42:55 2017 +0200
# Node ID 519968083ab2ea9682d051d88049d003130645c9
# Parent  2c6e6c9c3da72aaddb33565d7031918fb5a37097
silence MSVC warning C4334 and GCC warnings for '-std=gnu++11'

diff -r 2c6e6c9c3da7 -r 519968083ab2 source/common/ipfilter.cpp
--- a/source/common/ipfilter.cpp	Thu Apr 20 11:08:02 2017 +0530
+++ b/source/common/ipfilter.cpp	Thu Apr 20 21:42:55 2017 +0200
@@ -123,7 +123,7 @@
     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 = (unsigned)-IF_INTERNAL_OFFS << shift;
     int blkheight = height;
 
     src -= N / 2 - 1;
@@ -209,7 +209,7 @@
     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 = (unsigned)-IF_INTERNAL_OFFS << shift;
 
     src -= (N / 2 - 1) * srcStride;
 
diff -r 2c6e6c9c3da7 -r 519968083ab2 source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Apr 20 11:08:02 2017 +0530
+++ b/source/encoder/encoder.cpp	Thu Apr 20 21:42:55 2017 +0200
@@ -2823,7 +2823,7 @@
         analysisFrameData->distortion[count] = distortionBuf[d];
         analysisFrameData->ctuDistortion[ctuCount] += analysisFrameData->distortion[count];
         count += bytes;
-        if ((count % (size_t)NUM_4x4_PARTITIONS) == 0)
+        if ((count % (unsigned)NUM_4x4_PARTITIONS) == 0)
         {
             analysisFrameData->scaledDistortion[ctuCount] = X265_LOG2(X265_MAX(analysisFrameData->ctuDistortion[ctuCount], 1));
             sum += analysisFrameData->scaledDistortion[ctuCount];


More information about the x265-devel mailing list