History

Avoid using static arrays for keeping track of frame dumping state

Martin Storsjö committed 12 years ago

Commit 00f28cc1 parent 1888fba4 files · +18 −13Browse files

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

Unified · Split

codec/encoder/core/src/encoder.cpp+4−8
@@ -350,15 +350,14 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum · 349 unmodified lines
350 * \brief Dump reconstruction for dependency layer350 * \brief Dump reconstruction for dependency layer
351 */351 */
352 352
353extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid) {353extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) {
354 WelsFileHandle* pDumpRecFile = NULL;354 WelsFileHandle* pDumpRecFile = NULL;
355 static bool bDependencyRecFlag[MAX_DEPENDENCY_LAYER] = {0};
356 int32_t iWrittenSize = 0;355 int32_t iWrittenSize = 0;
357 356
358 if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)357 if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)
359 return;358 return;
360 359
361 if (bDependencyRecFlag[kiDid]) {360 if (bAppend) {
362 if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage361 if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage
363 pDumpRecFile = WelsFopen (kpFileName, "ab");362 pDumpRecFile = WelsFopen (kpFileName, "ab");
364 else {363 else {
@@ -376,7 +375,6 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 11 unmodified lines
376 WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage375 WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage
377 pDumpRecFile = WelsFopen (sDependencyRecFileName, "wb");376 pDumpRecFile = WelsFopen (sDependencyRecFileName, "wb");
378 }377 }
379 bDependencyRecFlag[kiDid] = true;
380 }378 }
381 379
382 if (NULL != pDumpRecFile) {380 if (NULL != pDumpRecFile) {
@@ -418,15 +416,14 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName · 35 unmodified lines
418 * \brief Dump the reconstruction pictures416 * \brief Dump the reconstruction pictures
419 */417 */
420 418
421void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName) {419void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) {
422 WelsFileHandle* pDumpRecFile = NULL;420 WelsFileHandle* pDumpRecFile = NULL;
423 static bool bRecFlag = false;
424 int32_t iWrittenSize = 0;421 int32_t iWrittenSize = 0;
425 422
426 if (NULL == pCurPicture || NULL == kpFileName)423 if (NULL == pCurPicture || NULL == kpFileName)
427 return;424 return;
428 425
429 if (bRecFlag) {426 if (bAppend) {
430 if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage427 if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage
431 pDumpRecFile = WelsFopen (kpFileName, "ab");428 pDumpRecFile = WelsFopen (kpFileName, "ab");
432 } else {429 } else {
@@ -440,7 +437,6 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName) { · 7 unmodified lines
440 } else {437 } else {
441 pDumpRecFile = WelsFopen ("rec.yuv", "wb");438 pDumpRecFile = WelsFopen ("rec.yuv", "wb");
442 }439 }
443 bRecFlag = true;
444 }440 }
445 441
446 if (NULL != pDumpRecFile) {442 if (NULL != pDumpRecFile) {

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