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

Function JudgeNeedOfScaling

codec/encoder/core/src/wels_preprocess.cpp:482–512  ·  view source on GitHub ↗

! * \brief Whether input picture need be scaled? */

Source from the content-addressed store, hash-verified

480 * \brief Whether input picture need be scaled?
481 */
482bool JudgeNeedOfScaling (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture) {
483 const int32_t kiInputPicWidth = pParam->SUsedPicRect.iWidth;
484 const int32_t kiInputPicHeight = pParam->SUsedPicRect.iHeight;
485 const int32_t kiDstPicWidth = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualWidth;
486 const int32_t kiDstPicHeight = pParam->sDependencyLayers[pParam->iSpatialLayerNum - 1].iActualHeight;
487 bool bNeedDownsampling = true;
488
489 int32_t iSpatialIdx = pParam->iSpatialLayerNum - 1;
490
491 if (kiDstPicWidth >= kiInputPicWidth && kiDstPicHeight >= kiInputPicHeight) {
492 bNeedDownsampling = false;
493 }
494
495 for (; iSpatialIdx >= 0; iSpatialIdx --) {
496 SSpatialLayerInternal* pCurLayer = &pParam->sDependencyLayers[iSpatialIdx];
497 int32_t iCurDstWidth = pCurLayer->iActualWidth;
498 int32_t iCurDstHeight = pCurLayer->iActualHeight;
499 int32_t iInputWidthXDstHeight = kiInputPicWidth * iCurDstHeight;
500 int32_t iInputHeightXDstWidth = kiInputPicHeight * iCurDstWidth;
501
502 if (iInputWidthXDstHeight > iInputHeightXDstWidth) {
503 pScaledPicture->iScaledWidth[iSpatialIdx] = WELS_MAX (iCurDstWidth, 4);
504 pScaledPicture->iScaledHeight[iSpatialIdx] = WELS_MAX (iInputHeightXDstWidth / kiInputPicWidth, 4);
505 } else {
506 pScaledPicture->iScaledWidth[iSpatialIdx] = WELS_MAX (iInputWidthXDstHeight / kiInputPicHeight, 4);
507 pScaledPicture->iScaledHeight[iSpatialIdx] = WELS_MAX (iCurDstHeight, 4);
508 }
509 }
510
511 return bNeedDownsampling;
512}
513
514int32_t WelsInitScaledPic (SWelsSvcCodingParam* pParam, Scaled_Picture* pScaledPicture, CMemoryAlign* pMemoryAlign) {
515 bool bInputPicNeedScaling = JudgeNeedOfScaling (pParam, pScaledPicture);

Callers 1

WelsInitScaledPicFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected