History

fix for simulcast case when the frame rate of lower resolution is higher, and add test case

Sijia Chen committed 11 years ago

Commit 53c057a1 parent 5c301de5 files · +183 −25Browse files

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

Unified · Split

codec/encoder/core/src/encoder.cpp+38−12
@@ -226,6 +226,41 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, · 225 unmodified lines
226226 return iReturn;
227227 }
228228
229+void UpdateFrameNum(sWelsEncCtx* pEncCtx) {
230+ bool bNeedFrameNumIncreasing = false;
231+ for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) {
232+ if (NRI_PRI_LOWEST != pEncCtx->eLastNalPriority[i]) {
233+ bNeedFrameNumIncreasing = true;
234+ }
235+ }
236+ if (bNeedFrameNumIncreasing) {
237+ if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1)
238+ ++ pEncCtx->iFrameNum;
239+ else
240+ pEncCtx->iFrameNum = 0; // if iFrameNum overflow
241+ }
242+ for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) {
243+ pEncCtx->eLastNalPriority[i] = NRI_PRI_LOWEST;
244+ }
245+}
246+
247+
248+void LoadBackFrameNum(sWelsEncCtx* pEncCtx) {
249+ bool bNeedFrameNumIncreasing = false;
250+ for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) {
251+ if (NRI_PRI_LOWEST != pEncCtx->eLastNalPriority[i]) {
252+ bNeedFrameNumIncreasing = true;
253+ }
254+ }
255+ if (bNeedFrameNumIncreasing) {
256+ if (pEncCtx->iFrameNum != 0) {
257+ pEncCtx->iFrameNum --;
258+ } else {
259+ pEncCtx->iFrameNum = (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1;
260+ }
261+ }
262+}
263+
229264 /*!
230265 * \brief initialize frame coding
231266 */
@@ -245,12 +280,8 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { · 13 unmodified lines
245280 else
246281 pEncCtx->iPOC = 0;
247282
248− if (pEncCtx->eLastNalPriority != 0) {
249− if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1)
250− ++ pEncCtx->iFrameNum;
251− else
252− pEncCtx->iFrameNum = 0; // if iFrameNum overflow
253− }
283+ UpdateFrameNum(pEncCtx);
284+
254285 pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
255286 pEncCtx->eSliceType = P_SLICE;
256287 pEncCtx->eNalPriority = NRI_PRI_HIGH;
@@ -275,12 +306,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { · 18 unmodified lines
275306 else
276307 pEncCtx->iPOC = 0;
277308
278− if (pEncCtx->eLastNalPriority != 0) {
279− if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1)
280− ++ pEncCtx->iFrameNum;
281− else
282− pEncCtx->iFrameNum = 0; // if iFrameNum overflow
283− }
309+ UpdateFrameNum(pEncCtx);
284310
285311 pEncCtx->eNalType = NAL_UNIT_CODED_SLICE;
286312 pEncCtx->eSliceType = I_SLICE;

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