MCPcopy Create free account
hub / github.com/cisco/openh264 / WelsCheckNumRefSetting

Function WelsCheckNumRefSetting

codec/encoder/core/src/au_set.cpp:88–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88static int32_t WelsCheckNumRefSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam, bool bStrictCheck) {
89 // validate LTR num
90 int32_t iCurrentSupportedLtrNum = (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? LONG_TERM_REF_NUM :
91 LONG_TERM_REF_NUM_SCREEN;
92 if ((pParam->bEnableLongTermReference) && (iCurrentSupportedLtrNum != pParam->iLTRRefNum)) {
93 WelsLog (pLogCtx, WELS_LOG_WARNING, "iLTRRefNum(%d) does not equal to currently supported %d, will be reset",
94 pParam->iLTRRefNum, iCurrentSupportedLtrNum);
95 pParam->iLTRRefNum = iCurrentSupportedLtrNum;
96 } else if (!pParam->bEnableLongTermReference) {
97 pParam->iLTRRefNum = 0;
98 }
99
100 //TODO: here is a fix needed here, the most reasonable value should be:
101 // iCurrentStrNum = WELS_MAX (1, WELS_LOG2 (pParam->uiGopSize));
102 // but reference list updating need to be changed
103 int32_t iCurrentStrNum = ((pParam->iUsageType == SCREEN_CONTENT_REAL_TIME && pParam->bEnableLongTermReference)
104 ? (WELS_MAX (1, WELS_LOG2 (pParam->uiGopSize)))
105 : (WELS_MAX (1, (pParam->uiGopSize >> 1))));
106 int32_t iNeededRefNum = (pParam->uiIntraPeriod != 1) ? (iCurrentStrNum + pParam->iLTRRefNum) : 0;
107
108 iNeededRefNum = WELS_CLIP3 (iNeededRefNum,
109 MIN_REF_PIC_COUNT,
110 (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME) ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA :
111 MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN);
112 // to adjust default or invalid input, in case pParam->iNumRefFrame do not have a valid value for the next step
113 if (pParam->iNumRefFrame == AUTO_REF_PIC_COUNT) {
114 pParam->iNumRefFrame = iNeededRefNum;
115 } else if (pParam->iNumRefFrame < iNeededRefNum) {
116 WelsLog (pLogCtx, WELS_LOG_WARNING,
117 "iNumRefFrame(%d) setting does not support the temporal and LTR setting, will be reset to %d",
118 pParam->iNumRefFrame, iNeededRefNum);
119 if (bStrictCheck) {
120 return ENC_RETURN_UNSUPPORTED_PARA;
121 }
122 pParam->iNumRefFrame = iNeededRefNum;
123 }
124
125 // after adjustment, do the following:
126 // if the setting is larger than needed, we will use the needed, and write the max into sps and for memory to wait for further expanding
127 if (pParam->iMaxNumRefFrame < pParam->iNumRefFrame) {
128 pParam->iMaxNumRefFrame = pParam->iNumRefFrame;
129 }
130 pParam->iNumRefFrame = iNeededRefNum;
131
132 return ENC_RETURN_SUCCESS;
133}
134
135int32_t WelsCheckRefFrameLimitationNumRefFirst (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam) {
136

Calls 2

WelsLogFunction · 0.85
WELS_LOG2Function · 0.85

Tested by

no test coverage detected