History

Consistently use the compat wrappers for file IO

As long as WelsFileHandle* is equal to FILE* this doesn't matter, but for consistency use the WelsF* functions for all handles opened by WelsFopen, and use WelsFileHandle* as type for it instead of FILE*.

Martin Storsjö committed 12 years ago

Commit 3559f421 parent e17e6646 files · +31 −26Browse files

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

Unified · Split

codec/encoder/core/src/encoder.cpp+14−14
@@ -315,7 +315,7 @@ EFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum) { · 314 unmodified lines
315315 */
316316
317317 extern "C" void DumpDependencyRec (SPicture* pCurPicture, const str_t* kpFileName, const int8_t kiDid) {
318− FILE* pDumpRecFile = NULL;
318+ WelsFileHandle* pDumpRecFile = NULL;
319319 static bool_t bDependencyRecFlag[MAX_DEPENDENCY_LAYER] = {0};
320320 int32_t iWrittenSize = 0;
321321
@@ -331,7 +331,7 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const str_t* kpFileNam · 9 unmodified lines
331331 pDumpRecFile = WelsFopen (sDependencyRecFileName, "ab");
332332 }
333333 if (NULL != pDumpRecFile)
334− fseek (pDumpRecFile, 0, SEEK_END);
334+ WelsFseek (pDumpRecFile, 0, SEEK_END);
335335 } else {
336336 if (STRNLEN (kpFileName, MAX_FNAME_LEN) > 0) { // confirmed_safe_unsafe_usage
337337 pDumpRecFile = WelsFopen (kpFileName, "wb");
@@ -353,27 +353,27 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const str_t* kpFileNam · 15 unmodified lines
353353 const int32_t kiChromaHeight = kiLumaHeight >> 1;
354354
355355 for (j = 0; j < kiLumaHeight; ++ j) {
356− iWrittenSize = fwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
356+ iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
357357 assert (iWrittenSize == kiLumaWidth);
358358 if (iWrittenSize < kiLumaWidth) {
359359 assert (0); // make no sense for us if writing failed
360− fclose (pDumpRecFile);
360+ WelsFclose (pDumpRecFile);
361361 return;
362362 }
363363 }
364364 for (i = 1; i < I420_PLANES; ++ i) {
365365 const int32_t kiStrideUV = pCurPicture->iLineSize[i];
366366 for (j = 0; j < kiChromaHeight; ++ j) {
367− iWrittenSize = fwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
367+ iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
368368 assert (iWrittenSize == kiChromaWidth);
369369 if (iWrittenSize < kiChromaWidth) {
370370 assert (0); // make no sense for us if writing failed
371− fclose (pDumpRecFile);
371+ WelsFclose (pDumpRecFile);
372372 return;
373373 }
374374 }
375375 }
376− fclose (pDumpRecFile);
376+ WelsFclose (pDumpRecFile);
377377 pDumpRecFile = NULL;
378378 }
379379 }
@@ -383,7 +383,7 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const str_t* kpFileNam · 3 unmodified lines
383383 */
384384
385385 void DumpRecFrame (SPicture* pCurPicture, const str_t* kpFileName) {
386− FILE* pDumpRecFile = NULL;
386+ WelsFileHandle* pDumpRecFile = NULL;
387387 static bool_t bRecFlag = false;
388388 int32_t iWrittenSize = 0;
389389
@@ -397,7 +397,7 @@ void DumpRecFrame (SPicture* pCurPicture, const str_t* kpFileName) { · 7 unmodified lines
397397 pDumpRecFile = WelsFopen ("rec.yuv", "ab");
398398 }
399399 if (NULL != pDumpRecFile)
400− fseek (pDumpRecFile, 0, SEEK_END);
400+ WelsFseek (pDumpRecFile, 0, SEEK_END);
401401 } else {
402402 if (STRNLEN (kpFileName, MAX_FNAME_LEN) > 0) { // confirmed_safe_unsafe_usage
403403 pDumpRecFile = WelsFopen (kpFileName, "wb");
@@ -417,27 +417,27 @@ void DumpRecFrame (SPicture* pCurPicture, const str_t* kpFileName) { · 13 unmodified lines
417417 const int32_t kiChromaHeight = kiLumaHeight >> 1;
418418
419419 for (j = 0; j < kiLumaHeight; ++ j) {
420− iWrittenSize = fwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
420+ iWrittenSize = WelsFwrite (&pCurPicture->pData[0][j * kiStrideY], 1, kiLumaWidth, pDumpRecFile);
421421 assert (iWrittenSize == kiLumaWidth);
422422 if (iWrittenSize < kiLumaWidth) {
423423 assert (0); // make no sense for us if writing failed
424− fclose (pDumpRecFile);
424+ WelsFclose (pDumpRecFile);
425425 return;
426426 }
427427 }
428428 for (i = 1; i < I420_PLANES; ++ i) {
429429 const int32_t kiStrideUV = pCurPicture->iLineSize[i];
430430 for (j = 0; j < kiChromaHeight; ++ j) {
431− iWrittenSize = fwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
431+ iWrittenSize = WelsFwrite (&pCurPicture->pData[i][j * kiStrideUV], 1, kiChromaWidth, pDumpRecFile);
432432 assert (iWrittenSize == kiChromaWidth);
433433 if (iWrittenSize < kiChromaWidth) {
434434 assert (0); // make no sense for us if writing failed
435− fclose (pDumpRecFile);
435+ WelsFclose (pDumpRecFile);
436436 return;
437437 }
438438 }
439439 }
440− fclose (pDumpRecFile);
440+ WelsFclose (pDumpRecFile);
441441 pDumpRecFile = NULL;
442442 }
443443 }

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