History

Use WelsSnprintf instead of SNPRINTF

Martin Storsjö committed 12 years ago

Commit f6fe4dd1 parent 6fea0846 files · +29 −117Browse files

Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 6 files). Show all

Unified · Split

codec/encoder/plus/src/welsEncoderExt.cpp+12−66
@@ -117,20 +117,8 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 116 unmodified lines
117117 gettimeofday (&tTimev, NULL);
118118 #endif//WIN32
119119
120−#ifdef _WIN32
121−#if defined(_MSC_VER)
122−#if _MSC_VER>=1500
123− iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, iBufferLeft, "enc_bs_0x%p_", (void*)this);
124− iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, iBufferLeftSize, "enc_size_0x%p_", (void*)this);
125−#else
126− iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this);
127− iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this);
128−#endif//_MSC_VER>=1500
129−#endif//_MSC_VER
130−#else
131− iCurUsed = SNPRINTF (strStreamFileName, iBufferLeft, "/tmp/enc_bs_0x%p_", (void*)this);
132− iCurUsedSize = SNPRINTF (strLenFileName, iBufferLeftSize, "/tmp/enc_size_0x%p", (void*)this);
133−#endif//WIN32
120+ iCurUsed = WelsSnprintf (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this);
121+ iCurUsedSize = WelsSnprintf (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this);
134122
135123
136124 if (iCurUsed > 0) {
@@ -179,15 +167,9 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 42 unmodified lines
179167
180168 if (iBufferLeft > 0) {
181169 #ifdef _WIN32
182−#if defined(_MSC_VER)
183−#if _MSC_VER>=1500
184− iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, iBufferLeft, ".%03.3u.264", tTimeb.millitm);
170+ iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm);
185171 #else
186− iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm);
187−#endif//_MSC_VER>=1500
188−#endif//_MSC_VER
189−#else
190− iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000);
172+ iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000);
191173 #endif//WIN32
192174 if (iCurUsed > 0) {
193175 iBufferUsed += iCurUsed;
@@ -197,16 +179,9 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 3 unmodified lines
197179
198180 if (iBufferLeftSize > 0) {
199181 #ifdef _WIN32
200−#if defined(_MSC_VER)
201−#if _MSC_VER>=1500
202− iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, iBufferLeftSize, ".%03.3u.len",
203− tTimeb.millitm);
182+ iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm);
204183 #else
205− iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm);
206−#endif//_MSC_VER>=1500
207−#endif//_MSC_VER
208−#else
209− iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000);
184+ iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000);
210185 #endif//WIN32
211186 if (iCurUsedSize > 0) {
212187 iBufferUsedSize += iCurUsedSize;
@@ -492,17 +467,11 @@ int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) { · 279 unmodified lines
492467 #if defined(OUTPUT_BIT_STREAM) || defined(ENABLE_TRACE_FILE)
493468 str_t fpath[MAX_FNAME_LEN] = {0};
494469 #if defined(__GNUC__)
495− SNPRINTF (fpath, MAX_FNAME_LEN, "/tmp/"); // confirmed_safe_unsafe_usage
470+ WelsSnprintf (fpath, MAX_FNAME_LEN, "/tmp/"); // confirmed_safe_unsafe_usage
496471
497472 #else//__GNUC__
498473
499−#if defined (_MSC_VER)
500−#if _MSC_VER>=1500
501− SNPRINTF (fpath, MAX_FNAME_LEN, MAX_FNAME_LEN, ".\\"); // confirmed_safe_unsafe_usage
502−#else
503− SNPRINTF (fpath, MAX_FNAME_LEN, ".\\"); // confirmed_safe_unsafe_usage
504−#endif//_MSC_VER>=1500
505−#endif//_MSC_VER
474+ WelsSnprintf (fpath, MAX_FNAME_LEN, ".\\"); // confirmed_safe_unsafe_usage
506475 #endif //__GNUC__
507476
508477 strcpy (pCfg->sTracePath, fpath); // confirmed_safe_unsafe_usage
@@ -681,37 +650,14 @@ int CWelsH264SVCEncoder::EncodeFrame2 (const SSourcePicture** pSrcPicList, int · 172 unmodified lines
681650 m_pFileBsSize = NULL;
682651 }
683652 str_t strStreamFileName[128] = {0};
684−#if defined(__GNUC__)
685−
686− int32_t iLen = SNPRINTF (strStreamFileName, 128, "%sadj%d_w%d.264", m_pEncContext->sTracePath, m_iSwitchTimes,
687− m_pEncContext->pSvcParam->iActualPicWidth);
688− m_pFileBs = WelsFopen (strStreamFileName, "wb");
689− SNPRINTF (strStreamFileName, 128, "%sadj%d_w%d_size.iLen", m_pEncContext->sTracePath, m_iSwitchTimes,
690− m_pEncContext->pSvcParam->iActualPicWidth);
691− m_pFileBsSize = WelsFopen (strStreamFileName, "wb");
692−
693−#else//__GNUC__
694−
695−#if defined (_MSC_VER)
696−#if _MSC_VER>=1500
697− int32_t iLen = SNPRINTF (strStreamFileName, 128, 128, "adj%d_w%d.264", m_iSwitchTimes,
698− m_pEncContext->pSvcParam->iActualPicWidth);
699− m_pFileBs = WelsFopen (strStreamFileName, "wb");
700− SNPRINTF (strStreamFileName, 128, 128, "adj%d_w%d_size.iLen", m_iSwitchTimes,
701− m_pEncContext->pSvcParam->iActualPicWidth);
702− m_pFileBsSize = WelsFopen (strStreamFileName, "wb");
703−#else
704− int32_t iLen = SNPRINTF (strStreamFileName, 128, "adj%d_w%d.264", m_iSwitchTimes,
705− m_pEncContext->pSvcParam->iActualPicWidth);
653+ int32_t iLen = WelsSnprintf (strStreamFileName, 128, "adj%d_w%d.264", m_iSwitchTimes,
654+ m_pEncContext->pSvcParam->iActualPicWidth);
706655 m_pFileBs = WelsFopen (strStreamFileName, "wb");
707− SNPRINTF (strStreamFileName, 128, "adj%d_w%d_size.iLen", m_iSwitchTimes, m_pEncContext->pSvcParam->iActualPicWidth);
656+ WelsSnprintf (strStreamFileName, 128, "adj%d_w%d_size.iLen", m_iSwitchTimes,
657+ m_pEncContext->pSvcParam->iActualPicWidth);
708658 m_pFileBsSize = WelsFopen (strStreamFileName, "wb");
709−#endif//_MSC_VER>=1500
710−#endif//_MSC_VER
711659
712660
713−#endif//__GNUC__
714−
715661 m_bSwitch = FALSE;
716662 }
717663

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t