Here's a patch I'm using.

On 7/13/19 6:21 PM, Mario Rohkrämer wrote:
Forgot to mention: This was v3.1.1+1


Am 13.07.2019, 16:41 Uhr, schrieb Mario *LigH* Rohkrämer <cont...@ligh.de>:

Ubuntu 18.04 LTS + GCC 9.0


/home/ligh/x265/source/encoder/ratecontrol.cpp: In member function ‘int x265::RateControl::writeRateControlFrameStats(x265::Frame*, x265::RateControlEntry*)’: /home/ligh/x265/source/encoder/ratecontrol.cpp:2867:21: warning: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Wrestrict]   2867 |             sprintf(deltaPOC, "%s%d~", deltaPOC, rpsWriter->deltaPOC[i]);
       |                     ^~~~~~~~           ~~~~~~~~
/home/ligh/x265/source/encoder/ratecontrol.cpp:2868:21: warning: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Wrestrict]
  2868 |             sprintf(bUsed, "%s%d~", bUsed, rpsWriter->bUsed[i]);
       |                     ^~~~~           ~~~~~
/home/ligh/x265/source/encoder/ratecontrol.cpp:2867:36: warning: ‘~’ directive writing 1 byte into a region of size between 0 and 127 [-Wformat-overflow=]   2867 |             sprintf(deltaPOC, "%s%d~", deltaPOC, rpsWriter->deltaPOC[i]);
       |                                    ^
/home/ligh/x265/source/encoder/ratecontrol.cpp:2867:20: note: ‘sprintf’ output between 3 and 140 bytes into a destination of size 128   2867 |             sprintf(deltaPOC, "%s%d~", deltaPOC, rpsWriter->deltaPOC[i]);
       | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ligh/x265/source/encoder/ratecontrol.cpp:2868:33: warning: ‘~’ directive writing 1 byte into a region of size between 0 and 39 [-Wformat-overflow=]
  2868 |             sprintf(bUsed, "%s%d~", bUsed, rpsWriter->bUsed[i]);
       |                                 ^
/home/ligh/x265/source/encoder/ratecontrol.cpp:2868:20: note: ‘sprintf’ output between 3 and 42 bytes into a destination of size 40
  2868 |             sprintf(bUsed, "%s%d~", bUsed, rpsWriter->bUsed[i]);
       |             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Index: x265/source/encoder/ratecontrol.cpp
===================================================================
--- x265.orig/source/encoder/ratecontrol.cpp	2019-07-13 15:23:50.000000000 +0300
+++ x265/source/encoder/ratecontrol.cpp	2019-07-13 18:44:08.712025660 +0300
@@ -2857,17 +2857,17 @@ int RateControl::writeRateControlFrameSt
         int i, num = rpsWriter->numberOfPictures;
         char deltaPOC[128];
         char bUsed[40];
         memset(deltaPOC, 0, sizeof(deltaPOC));
         memset(bUsed, 0, sizeof(bUsed));
-        sprintf(deltaPOC, "deltapoc:~");
-        sprintf(bUsed, "bused:~");
+        char* deltaPOCPtr = deltaPOC + snprintf(deltaPOC, sizeof(deltaPOC), "deltapoc:~");
+        char* bUsedPtr = bUsed + snprintf(bUsed, sizeof(bUsed), "bused:~");
 
         for (i = 0; i < num; i++)
         {
-            sprintf(deltaPOC, "%s%d~", deltaPOC, rpsWriter->deltaPOC[i]);
-            sprintf(bUsed, "%s%d~", bUsed, rpsWriter->bUsed[i]);
+            deltaPOCPtr += snprintf(deltaPOCPtr, sizeof(deltaPOC) - (deltaPOCPtr - deltaPOC), "%d~", rpsWriter->deltaPOC[i]);
+            bUsedPtr += snprintf(bUsedPtr, sizeof(bUsed) - (bUsedPtr - bUsed), "%d~", rpsWriter->bUsed[i]);
         }
 
         if (fprintf(m_statFileOut,
             "in:%d out:%d type:%c q:%.2f q-aq:%.2f q-noVbv:%.2f q-Rceq:%.2f tex:%d mv:%d misc:%d icu:%.2f pcu:%.2f scu:%.2f nump:%d numnegp:%d numposp:%d %s %s ;\n",
             rce->poc, rce->encodeOrder,
_______________________________________________
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel

Reply via email to