<div dir="ltr">Pushed to the release_4.1 branch<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 17, 2024 at 9:36 PM Ponsanthini Arunachalam <<a href="mailto:ponsanthini.arunachalam@multicorewareinc.com">ponsanthini.arunachalam@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">From dd1dc1f882b6f45422741e8b64da92c272e70e75 Mon Sep 17 00:00:00 2001<br>From: Ponsanthini <<a href="mailto:ponsanthini.arunachalam@multicorewareinc.com" target="_blank">ponsanthini.arunachalam@multicorewareinc.com</a>><br>Date: Wed, 16 Oct 2024 19:37:39 +0530<br>Subject: [PATCH] Fix the buffer size issue<br><br>---<br> source/encoder/encoder.cpp | 17 +++++++++--------<br> source/encoder/encoder.h | 2 +-<br> 2 files changed, 10 insertions(+), 9 deletions(-)<br><br>diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>index 21a4d5518..607c80d86 100644<br>--- a/source/encoder/encoder.cpp<br>+++ b/source/encoder/encoder.cpp<br>@@ -2789,15 +2789,16 @@ void EncStats::addQP(double aveQp)<br> m_totalQp += aveQp;<br> }<br> <br>-char* Encoder::statsString(EncStats& stat, char* buffer)<br>+char* Encoder::statsString(EncStats& stat, char* buffer, size_t bufferSize)<br> {<br> double fps = (double)m_param->fpsNum / m_param->fpsDenom;<br> double scale = fps / 1000 / (double)stat.m_numPics;<br> <br>- int len = snprintf(buffer, sizeof(buffer), "%6u, ", stat.m_numPics);<br>-<br>- len += snprintf(buffer + len, sizeof(buffer) - len, "Avg QP:%2.2lf", stat.m_totalQp / (double)stat.m_numPics);<br>- len += snprintf(buffer + len, sizeof(buffer) - len, " kb/s: %-8.2lf", stat.m_accBits * scale);<br>+ int len = snprintf(buffer, bufferSize, "%6u, ", stat.m_numPics);<br>+<br>+ len += snprintf(buffer + len, bufferSize - len, "Avg QP:%2.2lf", stat.m_totalQp / (double)stat.m_numPics);<br>+ len += snprintf(buffer + len, bufferSize - len, " kb/s: %-8.2lf", stat.m_accBits * scale);<br>+<br> if (m_param->bEnablePsnr)<br> {<br> len += snprintf(buffer + len, sizeof(buffer) - len," PSNR Mean: Y:%.3lf U:%.3lf V:%.3lf",<br>@@ -2823,11 +2824,11 @@ void Encoder::printSummary()<br> {<br> char buffer[200];<br> if (m_analyzeI[layer].m_numPics)<br>- x265_log(m_param, X265_LOG_INFO, "frame I: %s\n", statsString(m_analyzeI[layer], buffer));<br>+ x265_log(m_param, X265_LOG_INFO, "frame I: %s\n", statsString(m_analyzeI[layer], buffer, sizeof(buffer)));<br> if (m_analyzeP[layer].m_numPics)<br>- x265_log(m_param, X265_LOG_INFO, "frame P: %s\n", statsString(m_analyzeP[layer], buffer));<br>+ x265_log(m_param, X265_LOG_INFO, "frame P: %s\n", statsString(m_analyzeP[layer], buffer, sizeof(buffer)));<br> if (m_analyzeB[layer].m_numPics)<br>- x265_log(m_param, X265_LOG_INFO, "frame B: %s\n", statsString(m_analyzeB[layer], buffer));<br>+ x265_log(m_param, X265_LOG_INFO, "frame B: %s\n", statsString(m_analyzeB[layer], buffer, sizeof(buffer)));<br> if (m_param->bEnableWeightedPred && m_analyzeP[layer].m_numPics)<br> {<br> x265_log(m_param, X265_LOG_INFO, "Weighted P-Frames: Y:%.1f%% UV:%.1f%%\n",<br>diff --git a/source/encoder/encoder.h b/source/encoder/encoder.h<br>index 4b72f8bf9..f50f783d0 100644<br>--- a/source/encoder/encoder.h<br>+++ b/source/encoder/encoder.h<br>@@ -328,7 +328,7 @@ public:<br> <br> void printReconfigureParams();<br> <br>- char* statsString(EncStats&, char*);<br>+ char* statsString(EncStats&, char* , size_t bufferSize);<br> <br> void configure(x265_param *param);<br> <br>-- <br>2.41.0.windows.3<br><br></div>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div>