dump file refactor

This commit is contained in:
ruil2 2014-03-07 10:23:25 +08:00
parent b3fa8dd334
commit 594fc4fe7b
4 changed files with 39 additions and 20 deletions

View File

@ -89,7 +89,8 @@ typedef enum {
ENCODER_OPTION_ENABLE_PREFIX_NAL_ADDING, //enable prefix: true--enable prefix; false--disable prefix
ENCODER_OPTION_ENABLE_SPS_PPS_ID_ADDITION, //disable pSps/pPps id addition: true--disable pSps/pPps id; false--enable pSps/pPps id addistion
ENCODER_OPTION_CURRENT_PATH
ENCODER_OPTION_CURRENT_PATH,
ENCODER_OPTION_DUMP_FILE
} ENCODER_OPTION;
/* Option types introduced in decoder application */
@ -295,5 +296,8 @@ typedef struct Source_Picture_s {
long long uiTimeStamp;
} SSourcePicture;
typedef struct Dump_Layer_s{
int iLayer;
char *pFileName;
}SDumpLayer;
#endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__

View File

@ -48,9 +48,8 @@ using namespace std;
typedef struct tagFilesSet {
string strBsFile;
string strSeqFile; // for cmd lines
struct {
string strLayerCfgFile;
} sSpatialLayers[MAX_DEPENDENCY_LAYER];
string strLayerCfgFile[MAX_DEPENDENCY_LAYER];
char sRecFileName[MAX_DEPENDENCY_LAYER][MAX_FNAME_LEN];
} SFilesSet;

View File

@ -281,7 +281,7 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
}
} else if (strTag[0].compare ("LayerCfg") == 0) {
if (strTag[1].length() > 0)
sFileSet.sSpatialLayers[iLayerCount].strLayerCfgFile = strTag[1];
sFileSet.strLayerCfgFile[iLayerCount] = strTag[1];
// pSvcParam.sDependencyLayers[iLayerCount].uiDependencyId = iLayerCount;
++ iLayerCount;
} else if (strTag[0].compare ("PrefixNALAddingCtrl") == 0) {
@ -305,7 +305,7 @@ int ParseConfig (CReadConfig& cRdCfg, SSourcePicture* pSrcPic, SEncParamExt& pSv
for (int8_t iLayer = 0; iLayer < kiActualLayerNum; ++ iLayer) {
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
CReadConfig cRdLayerCfg (sFileSet.sSpatialLayers[iLayer].strLayerCfgFile);
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
if (-1==ParseLayerConfig( cRdLayerCfg, iLayer, pSvcParam ))
{
iRet = 1;
@ -477,11 +477,11 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
pSvcParam.iSpatialLayerNum = atoi (argv[n++]);
for (int ln = 0 ; (ln < pSvcParam.iSpatialLayerNum) && (n < argc) ; ln++) {
// pSvcParam.sDependencyLayers[ln].uiDependencyId = ln;
sFileSet.sSpatialLayers[ln].strLayerCfgFile.assign (argv[n++]);
sFileSet.strLayerCfgFile[ln].assign (argv[n++]);
}
for (int8_t iLayer = 0; iLayer < pSvcParam.iSpatialLayerNum; ++ iLayer) {
CReadConfig cRdLayerCfg (sFileSet.sSpatialLayers[iLayer].strLayerCfgFile);
CReadConfig cRdLayerCfg (sFileSet.strLayerCfgFile[iLayer]);
if (-1==ParseLayerConfig( cRdLayerCfg, iLayer, pSvcParam ))
{
return 1;
@ -489,19 +489,13 @@ int ParseCommandLine (int argc, char** argv, SSourcePicture* pSrcPic, SEncParamE
}
}
else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) {
#ifdef ENABLE_FRAME_DUMP
unsigned int iLayer = atoi (argv[n++]);
const int iLen = strlen (argv[n]);
SDLayerParam* pDLayer = &pSvcParam.sDependencyLayers[iLayer];
if (iLen >= sizeof(pDLayer->sRecFileName))
if (iLen >= sizeof(sFileSet.sRecFileName[iLayer]))
return 1;
pDLayer->sRecFileName[iLen] = '\0';
strncpy (pDLayer->sRecFileName, argv[n++], iLen); // confirmed_safe_unsafe_usage
#else
n += 2;
#endif//ENABLE_FRAME_DUMP
sFileSet.sRecFileName[iLayer][iLen] = '\0';
strncpy (sFileSet.sRecFileName[iLayer], argv[n++], iLen); // confirmed_safe_unsafe_usage
}
else if (!strcmp (pCommand, "-dw") && (n + 1 < argc)) {
unsigned int iLayer = atoi (argv[n++]);
SSpatialLayerConfig* pDLayer = &pSvcParam.sSpatialLayers[iLayer];
@ -700,7 +694,6 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
ret = 1;
goto ERROR_RET;
}
iPicLumaSize = sSvcParam.iPicWidth * sSvcParam.iPicHeight;
switch (sSvcParam.iInputCsp) {
int iStride;
@ -852,7 +845,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
memset (&sFbi, 0, sizeof (SFrameBSInfo));
memset (&sSvcParam, 0, sizeof (SEncParamExt));
memset (&fs,0,sizeof(SFilesSet));
sSvcParam.iInputCsp = videoFormatI420; // I420 in default
sSvcParam.sSpatialLayers[0].uiProfileIdc = PRO_BASELINE;
// svc_cfg->sDependencyLayers[0].frext_mode = 0;
@ -918,6 +911,20 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
for(int iLayer = 0;iLayer<MAX_DEPENDENCY_LAYER;iLayer++)
{
if(fs.sRecFileName[iLayer][0]!=0)
{
SDumpLayer sDumpLayer;
sDumpLayer.iLayer = iLayer;
sDumpLayer.pFileName = fs.sRecFileName[iLayer];
if(cmResultSuccess!=pPtrEnc->SetOption(ENCODER_OPTION_DUMP_FILE,&sDumpLayer)){
fprintf (stderr, "SetOption ENCODER_OPTION_DUMP_FILE failed!\n");
iRet = 1;
goto INSIDE_MEM_FREE;
}
}
}
// Inactive with sink with output file handler
if (fs.strBsFile.length() > 0) {
pFpBs = fopen (fs.strBsFile.c_str(), "wb");

View File

@ -938,6 +938,15 @@ int CWelsH264SVCEncoder::SetOption (ENCODER_OPTION eOptionId, void* pOption) {
}
}
break;
case ENCODER_OPTION_DUMP_FILE:{
#ifdef ENABLE_FRAME_DUMP
if(m_pEncContext->pSvcParam!=NULL){
SDumpLayer*pDump = (static_cast<SDumpLayer *>(pOption));
WelsStrncpy(m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName, pDump->pFileName, sizeof(m_pEncContext->pSvcParam->sDependencyLayers[pDump->iLayer].sRecFileName))
}
#endif
}
break;
default:
return cmInitParaError;
}