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
117 gettimeofday (&tTimev, NULL);117 gettimeofday (&tTimev, NULL);
118#endif//WIN32118#endif//WIN32
119 119
120#ifdef _WIN32120 iCurUsed = WelsSnprintf (strStreamFileName, iBufferLeft, "enc_bs_0x%p_", (void*)this);
121#if defined(_MSC_VER)121 iCurUsedSize = WelsSnprintf (strLenFileName, iBufferLeftSize, "enc_size_0x%p_", (void*)this);
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
134 122
135 123
136 if (iCurUsed > 0) {124 if (iCurUsed > 0) {
@@ -179,15 +167,9 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 42 unmodified lines
179 167
180 if (iBufferLeft > 0) {168 if (iBufferLeft > 0) {
181#ifdef _WIN32169#ifdef _WIN32
182#if defined(_MSC_VER)170 iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm);
183#if _MSC_VER>=1500
184 iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, iBufferLeft, ".%03.3u.264", tTimeb.millitm);
185#else171#else
186 iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimeb.millitm);172 iCurUsed = WelsSnprintf (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000);
187#endif//_MSC_VER>=1500
188#endif//_MSC_VER
189#else
190 iCurUsed = SNPRINTF (&strStreamFileName[iBufferUsed], iBufferLeft, ".%03.3u.264", tTimev.tv_usec / 1000);
191#endif//WIN32173#endif//WIN32
192 if (iCurUsed > 0) {174 if (iCurUsed > 0) {
193 iBufferUsed += iCurUsed;175 iBufferUsed += iCurUsed;
@@ -197,16 +179,9 @@ CWelsH264SVCEncoder::CWelsH264SVCEncoder() · 3 unmodified lines
197 179
198 if (iBufferLeftSize > 0) {180 if (iBufferLeftSize > 0) {
199#ifdef _WIN32181#ifdef _WIN32
200#if defined(_MSC_VER)182 iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm);
201#if _MSC_VER>=1500
202 iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, iBufferLeftSize, ".%03.3u.len",
203 tTimeb.millitm);
204#else183#else
205 iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimeb.millitm);184 iCurUsedSize = WelsSnprintf (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000);
206#endif//_MSC_VER>=1500
207#endif//_MSC_VER
208#else
209 iCurUsedSize = SNPRINTF (&strLenFileName[iBufferUsedSize], iBufferLeftSize, ".%03.3u.len", tTimev.tv_usec / 1000);
210#endif//WIN32185#endif//WIN32
211 if (iCurUsedSize > 0) {186 if (iCurUsedSize > 0) {
212 iBufferUsedSize += iCurUsedSize;187 iBufferUsedSize += iCurUsedSize;
@@ -492,17 +467,11 @@ int CWelsH264SVCEncoder::Initialize2 (void* argv, const INIT_TYPE iInitType) { · 279 unmodified lines
492#if defined(OUTPUT_BIT_STREAM) || defined(ENABLE_TRACE_FILE)467#if defined(OUTPUT_BIT_STREAM) || defined(ENABLE_TRACE_FILE)
493 str_t fpath[MAX_FNAME_LEN] = {0};468 str_t fpath[MAX_FNAME_LEN] = {0};
494#if defined(__GNUC__)469#if defined(__GNUC__)
495 SNPRINTF (fpath, MAX_FNAME_LEN, "/tmp/"); // confirmed_safe_unsafe_usage470 WelsSnprintf (fpath, MAX_FNAME_LEN, "/tmp/"); // confirmed_safe_unsafe_usage
496 471
497#else//__GNUC__472#else//__GNUC__
498 473
499#if defined (_MSC_VER)474 WelsSnprintf (fpath, MAX_FNAME_LEN, ".\\"); // confirmed_safe_unsafe_usage
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
506#endif //__GNUC__475#endif //__GNUC__
507 476
508 strcpy (pCfg->sTracePath, fpath); // confirmed_safe_unsafe_usage477 strcpy (pCfg->sTracePath, fpath); // confirmed_safe_unsafe_usage
@@ -681,37 +650,14 @@ int CWelsH264SVCEncoder::EncodeFrame2 (const SSourcePicture** pSrcPicList, int · 172 unmodified lines
681 m_pFileBsSize = NULL;650 m_pFileBsSize = NULL;
682 }651 }
683 str_t strStreamFileName[128] = {0};652 str_t strStreamFileName[128] = {0};
684#if defined(__GNUC__)653 int32_t iLen = WelsSnprintf (strStreamFileName, 128, "adj%d_w%d.264", m_iSwitchTimes,
685 654 m_pEncContext->pSvcParam->iActualPicWidth);
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);
706 m_pFileBs = WelsFopen (strStreamFileName, "wb");655 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);
708 m_pFileBsSize = WelsFopen (strStreamFileName, "wb");658 m_pFileBsSize = WelsFopen (strStreamFileName, "wb");
709#endif//_MSC_VER>=1500
710#endif//_MSC_VER
711 659
712 660
713#endif//__GNUC__
714
715 m_bSwitch = FALSE;661 m_bSwitch = FALSE;
716 }662 }
717 663

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