Simplify encoder interface--remove EncoderFrame2 from interface

function
This commit is contained in:
ruil2 2014-02-20 10:33:07 +08:00
parent f2d5f05b50
commit 3ba6a5f4da
10 changed files with 122 additions and 177 deletions

View File

@ -64,9 +64,7 @@ class ISVCEncoder {
/* /*
* return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid] * return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid]
*/ */
virtual int EXTAPI EncodeFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0; virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) = 0;
virtual int EXTAPI EncodeFrame2 (const SSourcePicture** kppSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo) = 0;
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;
*/ */
@ -75,7 +73,7 @@ class ISVCEncoder {
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;
*/ */
virtual int EXTAPI PauseFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0; virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic,SFrameBSInfo* pBsInfo) = 0;
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;
@ -146,12 +144,10 @@ struct ISVCEncoderVtbl {
int (*Uninitialize) (ISVCEncoder*); int (*Uninitialize) (ISVCEncoder*);
int (*EncodeFrame) (ISVCEncoder*, const unsigned char* kpSrc, SFrameBSInfo* pBsInfo); int (*EncodeFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*EncodeFrame2) (ISVCEncoder*, const SSourcePicture** kppSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo);
int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo); int (*EncodeParameterSets) (ISVCEncoder*, SFrameBSInfo* pBsInfo);
int (*PauseFrame) (ISVCEncoder*, const unsigned char* kpSrc, SFrameBSInfo* pBsInfo); int (*PauseFrame) (ISVCEncoder*, const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR); int (*ForceIntraFrame) (ISVCEncoder*, bool bIDR);

View File

@ -50,7 +50,6 @@ typedef struct tagFilesSet {
string strSeqFile; // for cmd lines string strSeqFile; // for cmd lines
struct { struct {
string strLayerCfgFile; string strLayerCfgFile;
string strSeqFile;
} sSpatialLayers[MAX_DEPENDENCY_LAYER]; } sSpatialLayers[MAX_DEPENDENCY_LAYER];
} SFilesSet; } SFilesSet;

View File

@ -120,7 +120,14 @@ int ParseConfig (CReadConfig& cRdCfg, SEncParamExt& pSvcParam, SFilesSet& sFileS
if (iRd > 0) { if (iRd > 0) {
if (strTag[0].empty()) if (strTag[0].empty())
continue; continue;
if (strTag[0].compare ("OutputFile") == 0) { if (strTag[0].compare ("SourceWidth") == 0) {
pSvcParam.iPicWidth = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("SourceHeight") == 0) {
pSvcParam.iPicHeight = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("InputFile") == 0) {
if (strTag[1].length() > 0)
sFileSet.strSeqFile = strTag[1];
} else if (strTag[0].compare ("OutputFile") == 0) {
sFileSet.strBsFile = strTag[1]; sFileSet.strBsFile = strTag[1];
} else if (strTag[0].compare ("MaxFrameRate") == 0) { } else if (strTag[0].compare ("MaxFrameRate") == 0) {
pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str()); pSvcParam.fMaxFrameRate = (float)atof (strTag[1].c_str());
@ -260,16 +267,13 @@ int ParseConfig (CReadConfig& cRdCfg, SEncParamExt& pSvcParam, SFilesSet& sFileS
if (iLayerRd > 0) { if (iLayerRd > 0) {
if (strTag[0].empty()) if (strTag[0].empty())
continue; continue;
if (strTag[0].compare ("SourceWidth") == 0) { if (strTag[0].compare ("FrameWidth") == 0) {
pDLayer->iVideoWidth = atoi (strTag[1].c_str()); pDLayer->iVideoWidth = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("SourceHeight") == 0) { } else if (strTag[0].compare ("FrameHeight") == 0) {
pDLayer->iVideoHeight = atoi (strTag[1].c_str()); pDLayer->iVideoHeight = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("FrameRateOut") == 0) { } else if (strTag[0].compare ("FrameRateOut") == 0) {
pDLayer->fFrameRate = (float)atof (strTag[1].c_str()); pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
} else if (strTag[0].compare ("InputFile") == 0) { }else if (strTag[0].compare ("ReconFile") == 0) {
if (strTag[1].length() > 0)
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
} else if (strTag[0].compare ("ReconFile") == 0) {
const int kiLen = strTag[1].length(); const int kiLen = strTag[1].length();
if (kiLen >= MAX_FNAME_LEN) if (kiLen >= MAX_FNAME_LEN)
return 1; return 1;
@ -427,7 +431,8 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& pSvcParam, SFilesSet&
if (!strcmp (pCommand, "-bf") && (n < argc)) if (!strcmp (pCommand, "-bf") && (n < argc))
sFileSet.strBsFile.assign (argv[n++]); sFileSet.strBsFile.assign (argv[n++]);
else if (!strcmp (pCommand, "-org") && (n < argc))
sFileSet.strSeqFile.assign (argv[n++]);
else if (!strcmp (pCommand, "-frms") && (n < argc)) else if (!strcmp (pCommand, "-frms") && (n < argc))
pSvcParam.uiFrameToBeCoded = atoi (argv[n++]); pSvcParam.uiFrameToBeCoded = atoi (argv[n++]);
@ -500,9 +505,6 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& pSvcParam, SFilesSet&
pDLayer->iVideoHeight = atoi (strTag[1].c_str()); pDLayer->iVideoHeight = atoi (strTag[1].c_str());
} else if (strTag[0].compare ("FrameRateOut") == 0) { } else if (strTag[0].compare ("FrameRateOut") == 0) {
pDLayer->fFrameRate = (float)atof (strTag[1].c_str()); pDLayer->fFrameRate = (float)atof (strTag[1].c_str());
} else if (strTag[0].compare ("InputFile") == 0) {
if (strTag[1].length() > 0)
sFileSet.sSpatialLayers[iLayer].strSeqFile = strTag[1];
} else if (strTag[0].compare ("ReconFile") == 0) { } else if (strTag[0].compare ("ReconFile") == 0) {
#ifdef ENABLE_FRAME_DUMP #ifdef ENABLE_FRAME_DUMP
const int kiLen = strTag[1].length(); const int kiLen = strTag[1].length();
@ -541,12 +543,6 @@ int ParseCommandLine (int argc, char** argv, SEncParamExt& pSvcParam, SFilesSet&
} }
} }
else if (!strcmp (pCommand, "-org") && (n + 1 < argc)) {
unsigned int iLayer = atoi (argv[n++]);
sFileSet.sSpatialLayers[iLayer].strSeqFile.assign (argv[n++]);
}
else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) { else if (!strcmp (pCommand, "-drec") && (n + 1 < argc)) {
#ifdef ENABLE_FRAME_DUMP #ifdef ENABLE_FRAME_DUMP
unsigned int iLayer = atoi (argv[n++]); unsigned int iLayer = atoi (argv[n++]);
@ -745,7 +741,7 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
int32_t iFrameSize = 0; int32_t iFrameSize = 0;
uint8_t* pPlanes[3] = { 0 }; uint8_t* pPlanes[3] = { 0 };
int32_t iFrame = 0; int32_t iFrame = 0;
SSourcePicture* pSrcPic = NULL;
#if defined ( STICK_STREAM_SIZE ) #if defined ( STICK_STREAM_SIZE )
FILE* fTrackStream = fopen ("coding_size.stream", "wb");; FILE* fTrackStream = fopen ("coding_size.stream", "wb");;
#endif #endif
@ -814,6 +810,22 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
goto ERROR_RET; goto ERROR_RET;
} }
pSrcPic = new SSourcePicture;
if (pSrcPic == NULL) {
ret = 1;
goto ERROR_RET;
}
pSrcPic->iColorFormat = sSvcParam.iInputCsp;
pSrcPic->iPicHeight = sSvcParam.iPicHeight;
pSrcPic->iPicWidth = sSvcParam.iPicWidth;
pSrcPic->iStride[0] = sSvcParam.iPicWidth;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = sSvcParam.iPicWidth>>1;
pSrcPic->pData[0] = pPlanes[0];
pSrcPic->pData[1] = pSrcPic->pData[0] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight);
pSrcPic->pData[2] = pSrcPic->pData[1] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight>>2);
while (true) { while (true) {
if (feof (pFpSrc)) if (feof (pFpSrc))
break; break;
@ -825,7 +837,7 @@ int ProcessEncodingSvcWithParam (ISVCEncoder* pPtrEnc, int argc, char** argv) {
break; break;
iStart = WelsTime(); iStart = WelsTime();
long iEncode = pPtrEnc->EncodeFrame (pPlanes[0], &sFbi); long iEncode = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
iTotal += WelsTime() - iStart; iTotal += WelsTime() - iStart;
if (videoFrameTypeInvalid == iEncode) { if (videoFrameTypeInvalid == iEncode) {
fprintf (stderr, "EncodeFrame() failed: %ld.\n", iEncode); fprintf (stderr, "EncodeFrame() failed: %ld.\n", iEncode);
@ -870,7 +882,10 @@ ERROR_RET:
fclose (pFpSrc); fclose (pFpSrc);
pFpSrc = NULL; pFpSrc = NULL;
} }
if(pSrcPic){
delete pSrcPic;
pSrcPic = NULL;
}
return ret; return ret;
} }
@ -886,15 +901,16 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
int64_t iStart = 0, iTotal = 0; int64_t iStart = 0, iTotal = 0;
// Preparing encoding process // Preparing encoding process
FILE* pFileYUV[MAX_DEPENDENCY_LAYER] = {0}; FILE* pFileYUV = NULL;
int32_t iActualFrameEncodedCount = 0; int32_t iActualFrameEncodedCount = 0;
int32_t iFrameIdx = 0; int32_t iFrameIdx = 0;
int32_t iTotalFrameMax = -1; int32_t iTotalFrameMax = -1;
int8_t iDlayerIdx = 0; int8_t iDlayerIdx = 0;
uint8_t* pYUV[MAX_DEPENDENCY_LAYER] = { 0 }; uint8_t* pYUV= NULL;
SSourcePicture** pSrcPicList = NULL; SSourcePicture* pSrcPic = NULL;
// Inactive with sink with output file handler // Inactive with sink with output file handler
FILE* pFpBs = NULL; FILE* pFpBs = NULL;
int kiPicResSize = 0;
#if defined(COMPARE_DATA) #if defined(COMPARE_DATA)
//For getting the golden file handle //For getting the golden file handle
FILE* fpGolden = NULL; FILE* fpGolden = NULL;
@ -937,9 +953,6 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
} }
iTotalFrameMax = (int32_t)sSvcParam.uiFrameToBeCoded; iTotalFrameMax = (int32_t)sSvcParam.uiFrameToBeCoded;
sSvcParam.iPicWidth = sSvcParam.sSpatialLayers[sSvcParam.iSpatialLayerNum - 1].iVideoWidth;
sSvcParam.iPicHeight = sSvcParam.sSpatialLayers[sSvcParam.iSpatialLayerNum - 1].iVideoHeight;
if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization if (cmResultSuccess != pPtrEnc->InitializeExt (&sSvcParam)) { // SVC encoder initialization
fprintf (stderr, "SVC encoder Initialize failed\n"); fprintf (stderr, "SVC encoder Initialize failed\n");
@ -965,48 +978,41 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
} }
#endif #endif
pSrcPicList = new SSourcePicture * [sSvcParam.iSpatialLayerNum]; kiPicResSize = sSvcParam.iPicWidth * sSvcParam.iPicHeight*3>>1;
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) {
SSpatialLayerConfig* pDLayer = &sSvcParam.sSpatialLayers[iDlayerIdx];
const int kiPicResSize = pDLayer->iVideoWidth * pDLayer->iVideoHeight;
SSourcePicture* pSrcPic = new SSourcePicture;
if (pSrcPic == NULL) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
memset (pSrcPic, 0, sizeof (SSourcePicture));
pYUV[iDlayerIdx] = new uint8_t [ (3 * kiPicResSize) >> 1]; pSrcPic = new SSourcePicture;
if (pYUV[iDlayerIdx] == NULL) { if (pSrcPic == NULL) {
iRet = 1; iRet = 1;
goto INSIDE_MEM_FREE; goto INSIDE_MEM_FREE;
} }
pYUV = new uint8_t [kiPicResSize];
if (pYUV == NULL) {
iRet = 1;
goto INSIDE_MEM_FREE;
}
pSrcPic->iColorFormat = sSvcParam.iInputCsp;
pSrcPic->iPicHeight = sSvcParam.iPicHeight;
pSrcPic->iPicWidth = sSvcParam.iPicWidth;
pSrcPic->iStride[0] = sSvcParam.iPicWidth;
pSrcPic->iStride[1] = pSrcPic->iStride[2] = sSvcParam.iPicWidth>>1;
pSrcPic->iColorFormat = videoFormatI420; pSrcPic->pData[0] = pYUV;
pSrcPic->iPicWidth = pDLayer->iVideoWidth; pSrcPic->pData[1] = pSrcPic->pData[0] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight);
pSrcPic->iPicHeight = pDLayer->iVideoHeight; pSrcPic->pData[2] = pSrcPic->pData[1] + (sSvcParam.iPicWidth*sSvcParam.iPicHeight>>2);
pSrcPic->iStride[0] = pDLayer->iVideoWidth; pFileYUV = fopen (fs.strSeqFile.c_str(), "rb");
pSrcPic->iStride[1] = pSrcPic->iStride[2] = pDLayer->iVideoWidth >> 1; if (pFileYUV != NULL) {
if (!fseek (pFileYUV, 0, SEEK_END)) {
pSrcPicList[iDlayerIdx] = pSrcPic; int64_t i_size = ftell (pFileYUV);
fseek (pFileYUV, 0, SEEK_SET);
pFileYUV[iDlayerIdx] = fopen (fs.sSpatialLayers[iDlayerIdx].strSeqFile.c_str(), "rb"); iTotalFrameMax = WELS_MAX ((int32_t) (i_size / kiPicResSize), iTotalFrameMax);
if (pFileYUV[iDlayerIdx] != NULL) {
if (!fseek (pFileYUV[iDlayerIdx], 0, SEEK_END)) {
int64_t i_size = ftell (pFileYUV[iDlayerIdx]);
fseek (pFileYUV[iDlayerIdx], 0, SEEK_SET);
iTotalFrameMax = WELS_MAX ((int32_t) (i_size / ((3 * kiPicResSize) >> 1)), iTotalFrameMax);
} }
} else { } else {
fprintf (stderr, "Unable to open source sequence file (%s), check corresponding path!\n", fprintf (stderr, "Unable to open source sequence file (%s), check corresponding path!\n",
fs.sSpatialLayers[iDlayerIdx].strSeqFile.c_str()); fs.strSeqFile.c_str());
iRet = 1; iRet = 1;
goto INSIDE_MEM_FREE; goto INSIDE_MEM_FREE;
} }
++ iDlayerIdx;
}
iFrameIdx = 0; iFrameIdx = 0;
while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0) while (iFrameIdx < iTotalFrameMax && (((int32_t)sSvcParam.uiFrameToBeCoded <= 0)
|| (iFrameIdx < (int32_t)sSvcParam.uiFrameToBeCoded))) { || (iFrameIdx < (int32_t)sSvcParam.uiFrameToBeCoded))) {
@ -1019,57 +1025,14 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
break; break;
} }
#endif//ONLY_ENC_FRAMES_NUM #endif//ONLY_ENC_FRAMES_NUM
iDlayerIdx = 0;
int nSpatialLayerNum = 0;
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) {
SSpatialLayerConfig* pDLayer = &sSvcParam.sSpatialLayers[iDlayerIdx];
const int kiPicResSize = ((pDLayer->iVideoWidth * pDLayer->iVideoHeight) * 3) >> 1;
uint32_t uiSkipIdx = 1;//(1 << pDLayer->iTemporalResolution);
bool bCanBeRead = false; bool bCanBeRead = false;
bCanBeRead = (fread (pYUV, 1, kiPicResSize, pFileYUV) == kiPicResSize);
if (iFrameIdx % uiSkipIdx == 0) { // such layer is enabled to encode indeed if (!bCanBeRead)
bCanBeRead = (fread (pYUV[iDlayerIdx], 1, kiPicResSize, pFileYUV[iDlayerIdx]) == kiPicResSize); break;
// To encoder this frame
if (bCanBeRead) {
bOnePicAvailableAtLeast = true;
pSrcPicList[nSpatialLayerNum]->pData[0] = pYUV[iDlayerIdx];
pSrcPicList[nSpatialLayerNum]->pData[1] = pSrcPicList[nSpatialLayerNum]->pData[0] +
(pDLayer->iVideoWidth * pDLayer->iVideoHeight);
pSrcPicList[nSpatialLayerNum]->pData[2] = pSrcPicList[nSpatialLayerNum]->pData[1] +
((pDLayer->iVideoWidth * pDLayer->iVideoHeight) >> 2);
pSrcPicList[nSpatialLayerNum]->iPicWidth = pDLayer->iVideoWidth;
pSrcPicList[nSpatialLayerNum]->iPicHeight = pDLayer->iVideoHeight;
pSrcPicList[nSpatialLayerNum]->iStride[0] = pDLayer->iVideoWidth;
pSrcPicList[nSpatialLayerNum]->iStride[1] = pSrcPicList[nSpatialLayerNum]->iStride[2]
= pDLayer->iVideoWidth >> 1;
++ nSpatialLayerNum;
} else { // file end while reading
bSomeSpatialUnavailable = true;
break;
}
} else {
}
++ iDlayerIdx;
}
if (bSomeSpatialUnavailable)
break;
if (!bOnePicAvailableAtLeast) {
++ iFrameIdx;
continue;
}
// To encoder this frame
iStart = WelsTime(); iStart = WelsTime();
int iEncFrames = pPtrEnc->EncodeFrame2 (const_cast<const SSourcePicture**> (pSrcPicList), nSpatialLayerNum, &sFbi); int iEncFrames = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
iTotal += WelsTime() - iStart; iTotal += WelsTime() - iStart;
// fixed issue in case dismatch source picture introduced by frame skipped, 1/12/2010 // fixed issue in case dismatch source picture introduced by frame skipped, 1/12/2010
@ -1132,8 +1095,7 @@ int ProcessEncodingSvcWithConfig (ISVCEncoder* pPtrEnc, int argc, char** argv) {
sSvcParam.iPicWidth, sSvcParam.iPicHeight, sSvcParam.iPicWidth, sSvcParam.iPicHeight,
iActualFrameEncodedCount, dElapsed, (iActualFrameEncodedCount * 1.0) / dElapsed); iActualFrameEncodedCount, dElapsed, (iActualFrameEncodedCount * 1.0) / dElapsed);
} }
INSIDE_MEM_FREE:
INSIDE_MEM_FREE: {
if (pFpBs) { if (pFpBs) {
fclose (pFpBs); fclose (pFpBs);
pFpBs = NULL; pFpBs = NULL;
@ -1151,34 +1113,18 @@ INSIDE_MEM_FREE: {
} }
#endif #endif
// Destruction memory introduced in this routine // Destruction memory introduced in this routine
iDlayerIdx = 0; if (pFileYUV!= NULL) {
while (iDlayerIdx < sSvcParam.iSpatialLayerNum) { fclose (pFileYUV);
if (pFileYUV[iDlayerIdx] != NULL) { pFileYUV = NULL;
fclose (pFileYUV[iDlayerIdx]);
pFileYUV[iDlayerIdx] = NULL;
} }
++ iDlayerIdx; if (pYUV) {
} delete pYUV;
pYUV = NULL;
if (pSrcPicList) {
for (int32_t i = 0; i < sSvcParam.iSpatialLayerNum; i++) {
if (pSrcPicList[i]) {
delete pSrcPicList[i];
pSrcPicList[i] = NULL;
}
} }
delete []pSrcPicList; if(pSrcPic){
pSrcPicList = NULL; delete pSrcPic;
} pSrcPic = NULL;
}
for (int32_t i = 0; i < MAX_DEPENDENCY_LAYER; i++) {
if (pYUV[i]) {
delete [] pYUV[i];
pYUV[i] = NULL;
}
}
}
return iRet; return iRet;
} }

View File

@ -74,7 +74,7 @@ class CWelsH264SVCEncoder : public ISVCEncoder {
/* /*
* return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid] * return: EVideoFrameType [IDR: videoFrameTypeIDR; P: videoFrameTypeP; ERROR: videoFrameTypeInvalid]
*/ */
virtual int EXTAPI EncodeFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo); virtual int EXTAPI EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
virtual int EXTAPI EncodeFrame2 (const SSourcePicture** kppSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo); virtual int EXTAPI EncodeFrame2 (const SSourcePicture** kppSrcPicList, int nSrcPicNum, SFrameBSInfo* pBsInfo);
/* /*
@ -85,7 +85,7 @@ class CWelsH264SVCEncoder : public ISVCEncoder {
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;
*/ */
virtual int EXTAPI PauseFrame (const unsigned char* pSrc, SFrameBSInfo* pBsInfo); virtual int EXTAPI PauseFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo);
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;

View File

@ -498,16 +498,13 @@ int32_t CWelsH264SVCEncoder::RawData2SrcPic (const uint8_t* pSrc) {
/* /*
* SVC core encoding * SVC core encoding
*/ */
int CWelsH264SVCEncoder::EncodeFrame (const unsigned char* pSrc, SFrameBSInfo* pBsInfo) { int CWelsH264SVCEncoder::EncodeFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) {
if (! (pSrc && m_pEncContext && m_bInitialFlag)) { if (! (kpSrcPic && m_pEncContext && m_bInitialFlag)) {
return videoFrameTypeInvalid; return videoFrameTypeInvalid;
} }
int32_t uiFrameType = videoFrameTypeInvalid; int32_t uiFrameType = videoFrameTypeInvalid;
uiFrameType = EncodeFrame2 (&kpSrcPic, 1, pBsInfo);
if (RawData2SrcPic ((uint8_t*)pSrc) == 0) {
uiFrameType = EncodeFrame2 (const_cast<const SSourcePicture**> (m_pSrcPicList), 1, pBsInfo);
}
#ifdef REC_FRAME_COUNT #ifdef REC_FRAME_COUNT
++ m_uiCountFrameNum; ++ m_uiCountFrameNum;
@ -621,14 +618,15 @@ int CWelsH264SVCEncoder::EncodeParameterSets (SFrameBSInfo* pBsInfo) {
/* /*
* return: 0 - success; otherwise - failed; * return: 0 - success; otherwise - failed;
*/ */
int CWelsH264SVCEncoder::PauseFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) { int CWelsH264SVCEncoder::PauseFrame (const SSourcePicture* kpSrcPic, SFrameBSInfo* pBsInfo) {
int32_t iReturn = 1; int32_t iReturn = 1;
ForceIntraFrame (true); ForceIntraFrame (true);
if (EncodeFrame (kpSrc, pBsInfo) != videoFrameTypeInvalid) { if (EncodeFrame2 (&kpSrcPic, 1,pBsInfo) != videoFrameTypeInvalid) {
iReturn = 0; iReturn = 0;
} }
// to avoid pause frame bitstream and // to avoid pause frame bitstream and
// normal bitstream use different video channel. // normal bitstream use different video channel.

View File

@ -48,8 +48,18 @@ void BaseEncoderTest::EncodeStream(InputStream* in, int width, int height,
SFrameBSInfo info; SFrameBSInfo info;
memset(&info, 0, sizeof(SFrameBSInfo)); memset(&info, 0, sizeof(SFrameBSInfo));
SSourcePicture pic;
memset(&pic,0,sizeof(SSourcePicture));
pic.iPicWidth = width;
pic.iPicHeight = height;
pic.iColorFormat = videoFormatI420;
pic.iStride[0] = pic.iPicWidth;
pic.iStride[1] = pic.iStride[2] = pic.iPicWidth>>1;
pic.pData[0] = buf.data();
pic.pData[1] = pic.pData[0] + width *height;
pic.pData[2] = pic.pData[1] + (width*height>>2);
while (in->read(buf.data(), frameSize) == frameSize) { while (in->read(buf.data(), frameSize) == frameSize) {
rv = encoder_->EncodeFrame(buf.data(), &info); rv = encoder_->EncodeFrame(&pic, &info);
ASSERT_TRUE(rv != videoFrameTypeInvalid); ASSERT_TRUE(rv != videoFrameTypeInvalid);
if (rv != videoFrameTypeSkip && cbk != NULL) { if (rv != videoFrameTypeSkip && cbk != NULL) {
cbk->onEncodeFrame(info); cbk->onEncodeFrame(info);

View File

@ -14,12 +14,11 @@ void CheckEncoderInterface(ISVCEncoder* p, CheckFunc check) {
CHECK(2, p, InitializeExt); CHECK(2, p, InitializeExt);
CHECK(3, p, Uninitialize); CHECK(3, p, Uninitialize);
CHECK(4, p, EncodeFrame); CHECK(4, p, EncodeFrame);
CHECK(5, p, EncodeFrame2); CHECK(5, p, EncodeParameterSets);
CHECK(6, p, EncodeParameterSets); CHECK(6, p, PauseFrame);
CHECK(7, p, PauseFrame); CHECK(7, p, ForceIntraFrame);
CHECK(8, p, ForceIntraFrame); CHECK(8, p, SetOption);
CHECK(9, p, SetOption); CHECK(9, p, GetOption);
CHECK(10, p, GetOption);
} }
void CheckDecoderInterface(ISVCDecoder* p, CheckFunc check) { void CheckDecoderInterface(ISVCDecoder* p, CheckFunc check) {

View File

@ -34,36 +34,31 @@ struct SVCEncoderImpl : public ISVCEncoder {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 3; return 3;
} }
virtual int EXTAPI EncodeFrame(const unsigned char* kpSrc, virtual int EXTAPI EncodeFrame(const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) { SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 4; return 4;
} }
virtual int EXTAPI EncodeFrame2(const SSourcePicture** kppSrcPicList, virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) {
int nSrcPicNum, SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 5; return 5;
} }
virtual int EXTAPI EncodeParameterSets(SFrameBSInfo* pBsInfo) { virtual int EXTAPI PauseFrame(const SSourcePicture* kpSrcPic,
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 6; return 6;
} }
virtual int EXTAPI PauseFrame(const unsigned char* kpSrc, virtual int EXTAPI ForceIntraFrame(bool bIDR) {
SFrameBSInfo* pBsInfo) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 7; return 7;
} }
virtual int EXTAPI ForceIntraFrame(bool bIDR) { virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 8; return 8;
} }
virtual int EXTAPI SetOption(ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this);
return 9;
}
virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) { virtual int EXTAPI GetOption(ENCODER_OPTION eOptionId, void* pOption) {
EXPECT_TRUE(gThis == this); EXPECT_TRUE(gThis == this);
return 10; return 9;
} }
}; };

View File

@ -2,11 +2,10 @@
#============================== INPUT / OUTPUT ============================== #============================== INPUT / OUTPUT ==============================
SourceWidth 320 # Input frame width FrameWidth 320 # Input frame width
SourceHeight 192 # Input frame height FrameHeight 192 # Input frame height
FrameRateIn 12 # Input frame rate [Hz] FrameRateIn 12 # Input frame rate [Hz]
FrameRateOut 12 # Output frame rate [Hz] FrameRateOut 12 # Output frame rate [Hz]
InputFile ../res/CiscoVT2people_320x192_12fps.yuv # Input file
ReconFile rec_layer2.yuv # Reconstructed file ReconFile rec_layer2.yuv # Reconstructed file
#============================== CODING ============================== #============================== CODING ==============================

View File

@ -1,6 +1,9 @@
# Cisco Scalable H.264/AVC Extension Encoder Configuration File # Cisco Scalable H.264/AVC Extension Encoder Configuration File
#============================== GENERAL ============================== #============================== GENERAL ==============================
SourceWidth 320 #input video width
SourceHeight 192 #input video height
InputFile ../res/CiscoVT2people_320x192_12fps.yuv # Input file
OutputFile test.264 # Bitstream file OutputFile test.264 # Bitstream file
MaxFrameRate 30 # Maximum frame rate [Hz] MaxFrameRate 30 # Maximum frame rate [Hz]
FramesToBeEncoded -1 # Number of frames (at input frame rate) FramesToBeEncoded -1 # Number of frames (at input frame rate)