Avoid using static arrays for keeping track of frame dumping state

This commit is contained in:
Martin Storsjö 2014-06-26 15:04:30 +03:00
parent 1888fba336
commit 00f28cc185
4 changed files with 18 additions and 13 deletions

View File

@ -91,12 +91,12 @@ int32_t GetTemporalLevel (SSpatialLayerInternal* fDlp, const int32_t kiFrameNum,
* \brief Dump reconstruction for dependency layer
*/
extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid);
extern "C" void DumpDependencyRec (SPicture* pSrcPic, const char* kpFileName, const int8_t kiDid, bool bAppend);
/*!
* \brief Dump the reconstruction pictures
*/
void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName);
void DumpRecFrame (SPicture* pSrcPic, const char* kpFileName, bool bAppend);
/*!

View File

@ -217,6 +217,11 @@ SStatSliceInfo sPerInfo;
int32_t iEncoderError;
WELS_MUTEX mutexEncoderError;
int32_t iDropNumber;
#ifdef ENABLE_FRAME_DUMP
bool bDependencyRecFlag[MAX_DEPENDENCY_LAYER];
bool bRecFlag;
#endif
} sWelsEncCtx/*, *PWelsEncCtx*/;
}
#endif//sWelsEncCtx_H__

View File

@ -350,15 +350,14 @@ EVideoFrameType DecideFrameType (sWelsEncCtx* pEncCtx, const int8_t kiSpatialNum
* \brief Dump reconstruction for dependency layer
*/
extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid) {
extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName, const int8_t kiDid, bool bAppend) {
WelsFileHandle* pDumpRecFile = NULL;
static bool bDependencyRecFlag[MAX_DEPENDENCY_LAYER] = {0};
int32_t iWrittenSize = 0;
if (NULL == pCurPicture || NULL == kpFileName || kiDid >= MAX_DEPENDENCY_LAYER)
return;
if (bDependencyRecFlag[kiDid]) {
if (bAppend) {
if (strlen (kpFileName) > 0) // confirmed_safe_unsafe_usage
pDumpRecFile = WelsFopen (kpFileName, "ab");
else {
@ -376,7 +375,6 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName
WelsSnprintf (sDependencyRecFileName, 16, "rec%d.yuv", kiDid); // confirmed_safe_unsafe_usage
pDumpRecFile = WelsFopen (sDependencyRecFileName, "wb");
}
bDependencyRecFlag[kiDid] = true;
}
if (NULL != pDumpRecFile) {
@ -418,15 +416,14 @@ extern "C" void DumpDependencyRec (SPicture* pCurPicture, const char* kpFileName
* \brief Dump the reconstruction pictures
*/
void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName) {
void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName, bool bAppend) {
WelsFileHandle* pDumpRecFile = NULL;
static bool bRecFlag = false;
int32_t iWrittenSize = 0;
if (NULL == pCurPicture || NULL == kpFileName)
return;
if (bRecFlag) {
if (bAppend) {
if (strlen (kpFileName) > 0) { // confirmed_safe_unsafe_usage
pDumpRecFile = WelsFopen (kpFileName, "ab");
} else {
@ -440,7 +437,6 @@ void DumpRecFrame (SPicture* pCurPicture, const char* kpFileName) {
} else {
pDumpRecFile = WelsFopen ("rec.yuv", "wb");
}
bRecFlag = true;
}
if (NULL != pDumpRecFile) {

View File

@ -3384,8 +3384,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
#ifdef ENABLE_FRAME_DUMP
// Dump reconstruction picture for each sQualityStat layer
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum)
DumpDependencyRec (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum].sRecFileName[0], iCurDid);
if (iCurDid + 1 < pSvcParam->iSpatialLayerNum) {
DumpDependencyRec (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum].sRecFileName[0], iCurDid,
pCtx->bDependencyRecFlag[iCurDid]);
pCtx->bDependencyRecFlag[iCurDid] = true;
}
#endif//ENABLE_FRAME_DUMP
#if defined(ENABLE_PSNR_CALC)
@ -3551,7 +3554,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour
#ifdef ENABLE_FRAME_DUMP
DumpRecFrame (fsnr, &pSvcParam->sDependencyLayers[pSvcParam->iSpatialLayerNum -
1].sRecFileName[0]); // pDecPic: final reconstruction output
1].sRecFileName[0], pCtx->bRecFlag); // pDecPic: final reconstruction output
pCtx->bRecFlag = true;
#endif//ENABLE_FRAME_DUMP
++ pCtx->iCodingIndex;