Beispiel #1
0
int32_t CWelsPreProcess::BuildSpatialPicList (sWelsEncCtx* pCtx, const SSourcePicture* kpSrcPic) {
  SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam;
  int32_t	iNumDependencyLayer = (int32_t)pSvcParam->iSpatialLayerNum;
  int32_t iSpatialNum = 0;

  if (!m_bInitDone) {
    if (WelsPreprocessCreate() != 0)
      return -1;
    if (WelsPreprocessReset (pCtx) != 0)
      return -1;

    m_bInitDone = true;
  }

  if (m_pInterfaceVp == NULL)
    return -1;

  pCtx->pVaa->bSceneChangeFlag = pCtx->pVaa->bIdrPeriodFlag = false;
  if (pSvcParam->uiIntraPeriod)
    pCtx->pVaa->bIdrPeriodFlag = (1 + pCtx->iFrameIndex >= (int32_t)pSvcParam->uiIntraPeriod) ? true : false;

  iSpatialNum = SingleLayerPreprocess (pCtx, kpSrcPic, &m_sScaledPicture);

  return iSpatialNum;
}
int32_t CWelsPreProcess::WelsPreprocessStep1 (void* pCtx, const SSourcePicture** kppSrcPicList,
    const int32_t kiConfiguredLayerNum) {
  sWelsEncCtx* pEncCtx = (sWelsEncCtx*)pCtx;
  SWelsSvcCodingParam* pSvcParam = pEncCtx->pSvcParam;
  int32_t	iNumDependencyLayer = (int32_t)pSvcParam->iNumDependencyLayer;
  int32_t iSpatialNum = 0;

  if (!m_bInitDone) {
    if (WelsPreprocessCreate() != 0)
      return -1;
    if (WelsPreprocessReset (pEncCtx) != 0)
      return -1;

    m_bOfficialBranch  = (iNumDependencyLayer != kiConfiguredLayerNum);
    if (!m_bOfficialBranch && (iNumDependencyLayer == 1)) {
      // check the input source uiSize to decide if need switch to official branch
      // NOTICE: the layernum=1 case is confused in official/non-official cases!
      SSourcePicture** pic_queue = (SSourcePicture**)kppSrcPicList;
      for (int32_t i = 0; i < iNumDependencyLayer; i++) {
        if (pSvcParam->sDependencyLayers[i].iFrameWidth != pic_queue[i]->iPicWidth ||
            pSvcParam->sDependencyLayers[i].iFrameHeight != pic_queue[i]->iPicHeight) {
          m_bOfficialBranch = TRUE;
          break;
        }
      }
    }
    m_bInitDone = TRUE;
  }

  if (m_pInterfaceVp == NULL)
    return -1;

  if (kiConfiguredLayerNum <= 0)
    return -1;

  pEncCtx->pVaa->bSceneChangeFlag = pEncCtx->pVaa->bIdrPeriodFlag = false;
  if (pSvcParam->uiIntraPeriod)
    pEncCtx->pVaa->bIdrPeriodFlag = (1 + pEncCtx->iFrameIndex >= (int32_t)pSvcParam->uiIntraPeriod) ? true : false;

  if (m_bOfficialBranch) {	// Perform Down Sampling potentially due to application
    assert (kiConfiguredLayerNum == 1);
    iSpatialNum	= SingleLayerPreprocess (pEncCtx, kppSrcPicList[0], &m_sScaledPicture);
  } else { // for console each spatial pictures are available there
    iSpatialNum	= kiConfiguredLayerNum;
    MultiLayerPreprocess (pEncCtx, kppSrcPicList, iSpatialNum);
  }

  return iSpatialNum;
}