int32_t WelsWriteSpsNal (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) { WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta); BsRbspTrailingBits (pBitStringAux); BsFlush (pBitStringAux); return 0; }
/*! * \brief write prefix nal */ int32_t WelsWriteSVCPrefixNal (SBitStringAux* pBitStringAux, const int32_t kiNalRefIdc, const bool_t kbIdrFlag) { if (0 < kiNalRefIdc) { BsWriteOneBit (pBitStringAux, false/*bStoreRefBasePicFlag*/); BsWriteOneBit (pBitStringAux, false); BsRbspTrailingBits (pBitStringAux); BsFlush (pBitStringAux); } return 0; }
int32_t WelsWriteSubsetSpsSyntax (SSubsetSps* pSubsetSps, SBitStringAux* pBitStringAux , int32_t* pSpsIdDelta) { SWelsSPS* pSps = &pSubsetSps->pSps; WelsWriteSpsSyntax (pSps, pBitStringAux, pSpsIdDelta); if (pSps->uiProfileIdc == PRO_SCALABLE_BASELINE || pSps->uiProfileIdc == PRO_SCALABLE_HIGH) { SSpsSvcExt* pSubsetSpsExt = &pSubsetSps->sSpsSvcExt; BsWriteOneBit (pBitStringAux, true/*pSubsetSpsExt->bInterLayerDeblockingFilterCtrlPresentFlag*/); BsWriteBits (pBitStringAux, 2, pSubsetSpsExt->iExtendedSpatialScalability); BsWriteOneBit (pBitStringAux, 0/*pSubsetSpsExt->uiChromaPhaseXPlus1Flag*/); BsWriteBits (pBitStringAux, 2, 1/*pSubsetSpsExt->uiChromaPhaseYPlus1*/); if (pSubsetSpsExt->iExtendedSpatialScalability == 1) { BsWriteOneBit (pBitStringAux, 0/*pSubsetSpsExt->uiSeqRefLayerChromaPhaseXPlus1Flag*/); BsWriteBits (pBitStringAux, 2, 1/*pSubsetSpsExt->uiSeqRefLayerChromaPhaseYPlus1*/); BsWriteSE (pBitStringAux, 0/*pSubsetSpsExt->sSeqScaledRefLayer.left_offset*/); BsWriteSE (pBitStringAux, 0/*pSubsetSpsExt->sSeqScaledRefLayer.top_offset*/); BsWriteSE (pBitStringAux, 0/*pSubsetSpsExt->sSeqScaledRefLayer.right_offset*/); BsWriteSE (pBitStringAux, 0/*pSubsetSpsExt->sSeqScaledRefLayer.bottom_offset*/); } BsWriteOneBit (pBitStringAux, pSubsetSpsExt->bSeqTcoeffLevelPredFlag); if (pSubsetSpsExt->bSeqTcoeffLevelPredFlag) { BsWriteOneBit (pBitStringAux, pSubsetSpsExt->bAdaptiveTcoeffLevelPredFlag); } BsWriteOneBit (pBitStringAux, pSubsetSpsExt->bSliceHeaderRestrictionFlag); BsWriteOneBit (pBitStringAux, false/*pSubsetSps->bSvcVuiParamPresentFlag*/); } BsWriteOneBit (pBitStringAux, false/*pSubsetSps->bAdditionalExtension2Flag*/); BsRbspTrailingBits (pBitStringAux); BsFlush (pBitStringAux); return 0; }
/*! ************************************************************************************* * \brief to write Picture Parameter Set (PPS) * * \param pPps pPps * \param pBitStringAux bitstream writer auxiliary * * \return 0 - successed * 1 - failed * * \note Call it in case EWelsNalUnitType is PPS. ************************************************************************************* */ int32_t WelsWritePpsSyntax (SWelsPPS* pPps, SBitStringAux* pBitStringAux, SParaSetOffset* sPSOVector) { SBitStringAux* pLocalBitStringAux = pBitStringAux; bool bUsedSubset = sPSOVector->bPpsIdMappingIntoSubsetsps[pPps->iPpsId]; int32_t iParameterSetType = (bUsedSubset ? PARA_SET_TYPE_SUBSETSPS : PARA_SET_TYPE_AVCSPS); BsWriteUE (pLocalBitStringAux, pPps->iPpsId + sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId]); BsWriteUE (pLocalBitStringAux, pPps->iSpsId + sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId]); #if _DEBUG //SParaSetOffset use, 110421 if (sPSOVector->bEnableSpsPpsIdAddition) { const int32_t kiTmpSpsIdInBs = pPps->iSpsId + sPSOVector->sParaSetOffsetVariable[iParameterSetType].iParaSetIdDelta[pPps->iSpsId]; const int32_t tmp_pps_id_in_bs = pPps->iPpsId + sPSOVector->sParaSetOffsetVariable[PARA_SET_TYPE_PPS].iParaSetIdDelta[pPps->iPpsId]; assert (MAX_SPS_COUNT > kiTmpSpsIdInBs); assert (MAX_PPS_COUNT > tmp_pps_id_in_bs); assert (sPSOVector->sParaSetOffsetVariable[iParameterSetType].bUsedParaSetIdInBs[kiTmpSpsIdInBs]); } #endif BsWriteOneBit (pLocalBitStringAux, false/*pPps->entropy_coding_mode_flag*/); BsWriteOneBit (pLocalBitStringAux, false/*pPps->bPicOrderPresentFlag*/); #ifdef DISABLE_FMO_FEATURE BsWriteUE (pLocalBitStringAux, 0/*pPps->uiNumSliceGroups - 1*/); #else BsWriteUE (pLocalBitStringAux, pPps->uiNumSliceGroups - 1); if (pPps->uiNumSliceGroups > 1) { uint32_t i, uiNumBits; BsWriteUE (pLocalBitStringAux, pPps->uiSliceGroupMapType); switch (pPps->uiSliceGroupMapType) { case 0: for (i = 0; i < pPps->uiNumSliceGroups; i ++) { BsWriteUE (pLocalBitStringAux, pPps->uiRunLength[i] - 1); } break; case 2: for (i = 0; i < pPps->uiNumSliceGroups; i ++) { BsWriteUE (pLocalBitStringAux, pPps->uiTopLeft[i]); BsWriteUE (pLocalBitStringAux, pPps->uiBottomRight[i]); } break; case 3: case 4: case 5: BsWriteOneBit (pLocalBitStringAux, pPps->bSliceGroupChangeDirectionFlag); BsWriteUE (pLocalBitStringAux, pPps->uiSliceGroupChangeRate - 1); break; case 6: BsWriteUE (pLocalBitStringAux, pPps->uiPicSizeInMapUnits - 1); uiNumBits = 0;///////////////////WELS_CEILLOG2(pPps->uiPicSizeInMapUnits); for (i = 0; i < pPps->uiPicSizeInMapUnits; i ++) { BsWriteBits (pLocalBitStringAux, uiNumBits, pPps->uiSliceGroupId[i]); } break; default: break; } } #endif//!DISABLE_FMO_FEATURE BsWriteUE (pLocalBitStringAux, 0/*pPps->uiNumRefIdxL0Active - 1*/); BsWriteUE (pLocalBitStringAux, 0/*pPps->uiNumRefIdxL1Active - 1*/); BsWriteOneBit (pLocalBitStringAux, false/*pPps->bWeightedPredFlag*/); BsWriteBits (pLocalBitStringAux, 2, 0/*pPps->uiWeightedBiPredIdc*/); BsWriteSE (pLocalBitStringAux, pPps->iPicInitQp - 26); BsWriteSE (pLocalBitStringAux, pPps->iPicInitQs - 26); BsWriteSE (pLocalBitStringAux, pPps->uiChromaQpIndexOffset); BsWriteOneBit (pLocalBitStringAux, pPps->bDeblockingFilterControlPresentFlag); BsWriteOneBit (pLocalBitStringAux, false/*pPps->bConstainedIntraPredFlag*/); BsWriteOneBit (pLocalBitStringAux, false/*pPps->bRedundantPicCntPresentFlag*/); BsRbspTrailingBits (pLocalBitStringAux); BsFlush (pLocalBitStringAux); return 0; }