ref: 27662155457b0e48dd84b79261fce6c93471341a
parent: f02d0aa6677216b78d3e1150d82e237b5608a0a1
author: Martin Storsjö <[email protected]>
date: Fri Jan 10 15:46:05 EST 2014
Add an encoder method for encoding the SPS/PPS without encoding a frame This is useful if using a muxer that requires the SPS/PPS to be available before the first frame is encoded.
--- a/codec/api/svc/codec_api.h
+++ b/codec/api/svc/codec_api.h
@@ -55,6 +55,11 @@
/*
* return: 0 - success; otherwise - failed;
*/
+ virtual int EncodeParameterSets (SFrameBSInfo* pBsInfo) = 0;
+
+ /*
+ * return: 0 - success; otherwise - failed;
+ */
virtual int PauseFrame (const unsigned char* kpSrc, SFrameBSInfo* pBsInfo) = 0;
/*
--- a/codec/encoder/core/inc/extern.h
+++ b/codec/encoder/core/inc/extern.h
@@ -98,6 +98,8 @@
int32_t WelsEncoderEncodeExt (sWelsEncCtx*, void* pDst, const SSourcePicture** kppSrcList,
const int32_t kiConfiguredLayerNum);
+int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst);
+
/*
* Force coding IDR as follows
*/
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3093,6 +3093,37 @@
return 0;
}
+int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) {
+ SFrameBSInfo* pFbi = (SFrameBSInfo*)pDst;
+ SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0];
+ int32_t iNalLen[128] = {0};
+ int32_t iCountNal = 0;
+
+ pLayerBsInfo->pBsBuf = pCtx->pFrameBs;
+ InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize);
+
+ WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal);
+
+ pLayerBsInfo->uiPriorityId = 0;
+ pLayerBsInfo->uiSpatialId = 0;
+ pLayerBsInfo->uiTemporalId = 0;
+ pLayerBsInfo->uiQualityId = 0;
+ pLayerBsInfo->uiLayerType = NON_VIDEO_CODING_LAYER;
+ pLayerBsInfo->iNalCount = iCountNal;
+ for (int32_t iNalIndex = 0; iNalIndex < iCountNal; ++ iNalIndex) {
+ pLayerBsInfo->iNalLengthInByte[iNalIndex] = iNalLen[iNalIndex];
+ }
+
+ pCtx->eLastNalPriority = NRI_PRI_HIGHEST;
+ pFbi->iLayerNum = 1;
+
+#if defined(X86_ASM)
+ WelsEmms();
+#endif //X86_ASM
+
+ return 0;
+}
+
/*!
* \brief core svc encoding process
*
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -79,6 +79,11 @@
/*
* return: 0 - success; otherwise - failed;
*/
+ virtual int EncodeParameterSets (SFrameBSInfo* pBsInfo);
+
+ /*
+ * return: 0 - success; otherwise - failed;
+ */
virtual int PauseFrame (const unsigned char* pSrc, SFrameBSInfo* pBsInfo);
/*
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -730,6 +730,10 @@
}
+int CWelsH264SVCEncoder::EncodeParameterSets (SFrameBSInfo* pBsInfo) {
+ return WelsEncoderEncodeParameterSets (m_pEncContext, pBsInfo);
+}
+
/*
* return: 0 - success; otherwise - failed;
*/