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 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) { | 353 | extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) { |
| 354 | WelsFileHandle* pDumpRecFile = NULL; | 354 | WelsFileHandle* pDumpRecFile = NULL; |
| 355 | int32_t iWrittenSize = 0; | 355 | int32_t iWrittenSize = 0; |
| 356 | const char* openMode = bAppend ? "ab" : "wb"; | ||
| 356 | 357 | ||
| 357 | if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) | 358 | if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER) |
| 358 | return; | 359 | return; |
| 359 | 360 | ||
| 360 | if (bAppend) { | 361 | if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage |
| 361 | if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage | 362 | pDumpRecFile = WelsFopen (kpFileName, openMode); |
| 362 | pDumpRecFile = WelsFopen (kpFileName, "ab"); | 363 | else { |
| 363 | else { | 364 | char sDependencyRecFileName[16] = {0}; |
| 364 | char sDependencyRecFileName[16] = {0}; | 365 | WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage |
| 365 | WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage | 366 | pDumpRecFile = WelsFopen (sDependencyRecFileName, openMode); |
| 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 | } | ||
| 378 | } | 367 | } |
| 368 | if (NULL != pDumpRecFile && bAppend) | ||
| 369 | WelsFseek (pDumpRecFile, 0, SEEK_END); | ||
| 379 | 370 | ||
| 380 | if (NULL != pDumpRecFile) { | 371 | if (NULL != pDumpRecFile) { |
| 381 | int32_t i = 0; | 372 | int32_t i = 0; |
| @@ -419,25 +410,18 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 37 unmodified lines | |||
| 419 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) { | 410 | void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) { |
| 420 | WelsFileHandle* pDumpRecFile = NULL; | 411 | WelsFileHandle* pDumpRecFile = NULL; |
| 421 | int32_t iWrittenSize = 0; | 412 | int32_t iWrittenSize = 0; |
| 413 | const char* openMode = bAppend ? "ab" : "wb"; | ||
| 422 | 414 | ||
| 423 | if (NULL == pCurPicture || NULL == kpFileName) | 415 | if (NULL == pCurPicture || NULL == kpFileName) |
| 424 | return; | 416 | return; |
| 425 | 417 | ||
| 426 | if (bAppend) { | 418 | if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage |
| 427 | if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | 419 | pDumpRecFile = WelsFopen (kpFileName, openMode); |
| 428 | pDumpRecFile = WelsFopen (kpFileName, "ab"); | ||
| 429 | } else { | ||
| 430 | pDumpRecFile = WelsFopen ("rec.yuv", "ab"); | ||
| 431 | } | ||
| 432 | if (NULL != pDumpRecFile) | ||
| 433 | WelsFseek (pDumpRecFile, 0, SEEK_END); | ||
| 434 | } else { | 420 | } else { |
| 435 | if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage | 421 | pDumpRecFile = WelsFopen ("rec.yuv", openMode); |
| 436 | pDumpRecFile = WelsFopen (kpFileName, "wb"); | ||
| 437 | } else { | ||
| 438 | pDumpRecFile = WelsFopen ("rec.yuv", "wb"); | ||
| 439 | } | ||
| 440 | } | 422 | } |
| 423 | if (NULL != pDumpRecFile && bAppend) | ||
| 424 | WelsFseek (pDumpRecFile, 0, SEEK_END); | ||
| 441 | 425 | ||
| 442 | if (NULL != pDumpRecFile) { | 426 | if (NULL != pDumpRecFile) { |
| 443 | int32_t i = 0; | 427 | int32_t i = 0; |