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

Function WelsInitBSliceRefList

codec/decoder/core/src/manage_dec_ref.cpp:232–354  ·  view source on GitHub ↗

* fills the pRefPic.pRefList LIST_0 and LIST_0 for B-Slice. */

Source from the content-addressed store, hash-verified

230* fills the pRefPic.pRefList LIST_0 and LIST_0 for B-Slice.
231*/
232int32_t WelsInitBSliceRefList (PWelsDecoderContext pCtx, int32_t iPoc) {
233
234 int32_t err = WelsCheckAndRecoverForFutureDecoding (pCtx);
235 if (err != ERR_NONE) return err;
236
237 WrapShortRefPicNum (pCtx);
238
239 PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0];
240 PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0];
241 memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_DPB_COUNT * sizeof (PPicture));
242 memset (pCtx->sRefPic.pRefList[LIST_1], 0, MAX_DPB_COUNT * sizeof (PPicture));
243 int32_t iLSCurrPocCount = 0;
244 int32_t iLTCurrPocCount = 0;
245 PPicture pLSCurrPocList0[MAX_DPB_COUNT];
246 PPicture pLTCurrPocList0[MAX_DPB_COUNT];
247 for (int32_t i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {
248 if (ppShoreRefList[i]->iFramePoc < iPoc) {
249 pLSCurrPocList0[iLSCurrPocCount++] = ppShoreRefList[i];
250 }
251 }
252 for (int32_t i = pCtx->sRefPic.uiShortRefCount[LIST_0] - 1; i >= 0; --i) {
253 if (ppShoreRefList[i]->iFramePoc > iPoc) {
254 pLTCurrPocList0[iLTCurrPocCount++] = ppShoreRefList[i];
255 }
256 }
257 if (pCtx->sRefPic.uiLongRefCount[LIST_0] > 1) {
258 //long sorts in increasing order
259 PPicture pTemp;
260 for (int32_t i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++i) {
261 for (int32_t j = i + 1; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) {
262 if (ppLongRefList[j]->iFramePoc < ppLongRefList[i]->iFramePoc) {
263 pTemp = ppLongRefList[i];
264 ppLongRefList[i] = ppLongRefList[j];
265 ppLongRefList[j] = pTemp;
266 }
267 }
268 }
269 }
270 int32_t iCurrPocCount = iLSCurrPocCount + iLTCurrPocCount;
271 int32_t iCount = 0;
272 //LIST_0
273 //short
274 //It may need to sort LIST_0 and LIST_1 so that they will have the right default orders.
275 for (int32_t i = 0; i < iLSCurrPocCount; ++i) {
276 pCtx->sRefPic.pRefList[LIST_0][iCount++] = pLSCurrPocList0[i];
277 }
278 if (iLSCurrPocCount > 1) {
279 //LIST_0 short sorts in decreasing order
280 PPicture pTemp;
281 for (int32_t i = 0; i < iLSCurrPocCount; ++i) {
282 for (int32_t j = i + 1; j < iLSCurrPocCount; ++j) {
283 if (pCtx->sRefPic.pRefList[LIST_0][j]->iFramePoc > pCtx->sRefPic.pRefList[LIST_0][i]->iFramePoc) {
284 pTemp = pCtx->sRefPic.pRefList[LIST_0][i];
285 pCtx->sRefPic.pRefList[LIST_0][i] = pCtx->sRefPic.pRefList[LIST_0][j];
286 pCtx->sRefPic.pRefList[LIST_0][j] = pTemp;
287 }
288 }
289 }

Callers 1

InitRefPicListFunction · 0.85

Calls 2

WrapShortRefPicNumFunction · 0.85

Tested by

no test coverage detected