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

Function InitSliceSegment

codec/encoder/core/src/svc_enc_slice_segment.cpp:352–434  ·  view source on GitHub ↗

! * \brief Initialize slice segment (Single/multiple slices) * * \param pCurDq current layer which its SSlice segment will be initialized * \param uiSliceMode SSlice mode * \param multi_slice_argv Multiple slices argument * \param iMbWidth MB width * \param iMbHeight MB height * * \return 0 - successful; none 0 - failed; */

Source from the content-addressed store, hash-verified

350 * \return 0 - successful; none 0 - failed;
351 */
352int32_t InitSliceSegment (SDqLayer* pCurDq,
353 CMemoryAlign* pMa,
354 SSliceArgument* pSliceArgument,
355 const int32_t kiMbWidth,
356 const int32_t kiMbHeight) {
357 SSliceCtx* pSliceSeg = &pCurDq->sSliceEncCtx;
358 const int32_t kiCountMbNum = kiMbWidth * kiMbHeight;
359 SliceModeEnum uiSliceMode = SM_SINGLE_SLICE;
360
361 if (NULL == pSliceSeg || NULL == pSliceArgument || kiMbWidth == 0 || kiMbHeight == 0)
362 return 1;
363
364 uiSliceMode = pSliceArgument->uiSliceMode;
365 if (pSliceSeg->iMbNumInFrame == kiCountMbNum && pSliceSeg->iMbWidth == kiMbWidth
366 && pSliceSeg->iMbHeight == kiMbHeight && pSliceSeg->uiSliceMode == uiSliceMode && pSliceSeg->pOverallMbMap != NULL)
367 return 0;
368 else if (pSliceSeg->iMbNumInFrame != kiCountMbNum) {
369 if (NULL != pSliceSeg->pOverallMbMap) {
370 pMa->WelsFree (pSliceSeg->pOverallMbMap, "pSliceSeg->pOverallMbMap");
371
372 pSliceSeg->pOverallMbMap = NULL;
373 }
374
375 // just for safe
376 pSliceSeg->iSliceNumInFrame = 0;
377 pSliceSeg->iMbNumInFrame = 0;
378 pSliceSeg->iMbWidth = 0;
379 pSliceSeg->iMbHeight = 0;
380 pSliceSeg->uiSliceMode = SM_SINGLE_SLICE; // sigle in default
381 }
382
383 if (SM_SINGLE_SLICE == uiSliceMode) {
384 pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMallocz (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
385
386 WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
387 pSliceSeg->iSliceNumInFrame = 1;
388
389 pSliceSeg->uiSliceMode = uiSliceMode;
390 pSliceSeg->iMbWidth = kiMbWidth;
391 pSliceSeg->iMbHeight = kiMbHeight;
392 pSliceSeg->iMbNumInFrame = kiCountMbNum;
393
394 return AssignMbMapSingleSlice (pSliceSeg->pOverallMbMap, kiCountMbNum, sizeof (pSliceSeg->pOverallMbMap[0]));
395 } else { //if ( SM_MULTIPLE_SLICE == uiSliceMode )
396 if (uiSliceMode != SM_FIXEDSLCNUM_SLICE && uiSliceMode != SM_RASTER_SLICE
397 && uiSliceMode != SM_SIZELIMITED_SLICE)
398 return 1;
399
400 pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMallocz (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap");
401 WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
402
403 WelsSetMemMultiplebytes_c (pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof (uint16_t));
404
405 //SM_SIZELIMITED_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1;
406 pSliceSeg->iSliceNumInFrame = GetInitialSliceNum (pSliceArgument);
407 if (-1 == pSliceSeg->iSliceNumInFrame)
408 return 1;
409

Callers 1

InitSlicePEncCtxFunction · 0.85

Calls 6

AssignMbMapSingleSliceFunction · 0.85
GetInitialSliceNumFunction · 0.85
WelsFreeMethod · 0.80
WelsMalloczMethod · 0.80

Tested by

no test coverage detected