Showing the changes to codec/encoder/core/src/encoder.cpp (1 of 1 file). Show all
Unified · Split
| @@ -353,29 +353,20 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 352 unmodified lines | ||
| 353 | 353 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) { |
| 354 | 354 | WelsFileHandle* pDumpRecFile = NULL; |
| 355 | 355 | int32_t iWrittenSize = 0; |
| 356 | + const char* openMode = bAppend ? "ab" : "wb"; | |
| 356 | 357 | |
| 357 | 358 | if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) |
| 358 | 359 | return; |
| 359 | 360 | |
| 360 | − if (bAppend) { | |
| 361 | − if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage | |
| 362 | − pDumpRecFile = WelsFopen (kpFileName, "ab"); | |
| 363 | − else { | |
| 364 | − char sDependencyRecFileName[16] = {0}; | |
| 365 | − WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage | |
| 366 | − pDumpRecFile = WelsFopen (sDependencyRecFileName, "ab"); | |
| 367 | − } | |
| 368 | − if (NULL != pDumpRecFile) | |
| 369 | − WelsFseek (pDumpRecFile, 0, SEEK_END); | |
| 370 | − } else { | |
| 371 | − if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | |
| 372 | − pDumpRecFile = WelsFopen (kpFileName, "wb"); | |
| 373 | − } else { | |
| 374 | − char sDependencyRecFileName[16] = {0}; | |
| 375 | − WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage | |
| 376 | − pDumpRecFile = WelsFopen (sDependencyRecFileName, "wb"); | |
| 377 | − } | |
| 361 | + if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage | |
| 362 | + pDumpRecFile = WelsFopen (kpFileName, openMode); | |
| 363 | + else { | |
| 364 | + char sDependencyRecFileName[16] = {0}; | |
| 365 | + WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage | |
| 366 | + pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode); | |
| 378 | 367 | } |
| 368 | + if (NULL != pDumpRecFile && bAppend) | |
| 369 | + WelsFseek (pDumpRecFile, 0, SEEK_END); | |
| 379 | 370 | |
| 380 | 371 | if (NULL != pDumpRecFile) { |
| 381 | 372 | int32_t i = 0; |
| @@ -419,25 +410,18 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 37 unmodified lines | ||
| 419 | 410 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) { |
| 420 | 411 | WelsFileHandle* pDumpRecFile = NULL; |
| 421 | 412 | int32_t iWrittenSize = 0; |
| 413 | + const char* openMode = bAppend ? "ab" : "wb"; | |
| 422 | 414 | |
| 423 | 415 | if (NULL == pCurPicture || NULL == kpFileName) |
| 424 | 416 | return; |
| 425 | 417 | |
| 426 | − if (bAppend) { | |
| 427 | − if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | |
| 428 | − pDumpRecFile = WelsFopen (kpFileName, "ab"); | |
| 429 | − } else { | |
| 430 | − pDumpRecFile = WelsFopen ("rec.yuv", "ab"); | |
| 431 | − } | |
| 432 | − if (NULL != pDumpRecFile) | |
| 433 | − WelsFseek (pDumpRecFile, 0, SEEK_END); | |
| 418 | + if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | |
| 419 | + pDumpRecFile = WelsFopen (kpFileName, openMode); | |
| 434 | 420 | } else { |
| 435 | − if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | |
| 436 | − pDumpRecFile = WelsFopen (kpFileName, "wb"); | |
| 437 | − } else { | |
| 438 | − pDumpRecFile = WelsFopen ("rec.yuv", "wb"); | |
| 439 | − } | |
| 421 | + pDumpRecFile = WelsFopen ("rec.yuv", openMode); | |
| 440 | 422 | } |
| 423 | + if (NULL != pDumpRecFile && bAppend) | |
| 424 | + WelsFseek (pDumpRecFile, 0, SEEK_END); | |
| 441 | 425 | |
| 442 | 426 | if (NULL != pDumpRecFile) { |
| 443 | 427 | int32_t i = 0; |