/*! * \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; }
/*! ************************************************************************************* * \brief to set Sequence Parameter Set (SPS) * * \param pSps SWelsSPS to be wrote, update iSpsId dependency * \param pBitStringAux bitstream writer auxiliary * * \return 0 - successed * 1 - failed * * \note Call it in case EWelsNalUnitType is SPS. ************************************************************************************* */ int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta) { SBitStringAux* pLocalBitStringAux = pBitStringAux; assert (pSps != NULL && pBitStringAux != NULL); BsWriteBits (pLocalBitStringAux, 8, pSps->uiProfileIdc); BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet0Flag); // bConstraintSet0Flag BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet1Flag); // bConstraintSet1Flag BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet2Flag); // bConstraintSet2Flag BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bConstraintSet3Flag*/); // bConstraintSet3Flag BsWriteBits (pLocalBitStringAux, 4, 0); // reserved_zero_4bits, equal to 0 BsWriteBits (pLocalBitStringAux, 8, pSps->iLevelIdc); // iLevelIdc BsWriteUE (pLocalBitStringAux, pSps->uiSpsId + pSpsIdDelta[pSps->uiSpsId]); // seq_parameter_set_id if (PRO_SCALABLE_BASELINE == pSps->uiProfileIdc || PRO_SCALABLE_HIGH == pSps->uiProfileIdc || PRO_HIGH == pSps->uiProfileIdc || PRO_HIGH10 == pSps->uiProfileIdc || PRO_HIGH422 == pSps->uiProfileIdc || PRO_HIGH444 == pSps->uiProfileIdc || PRO_CAVLC444 == pSps->uiProfileIdc || 44 == pSps->uiProfileIdc) { BsWriteUE (pLocalBitStringAux, 1); //uiChromaFormatIdc, now should be 1 BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthLuma BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthChroma BsWriteOneBit (pLocalBitStringAux, 0); //qpprime_y_zero_transform_bypass_flag BsWriteOneBit (pLocalBitStringAux, 0); //seq_scaling_matrix_present_flag } BsWriteUE (pLocalBitStringAux, pSps->uiLog2MaxFrameNum - 4); // log2_max_frame_num_minus4 BsWriteUE (pLocalBitStringAux, 0/*pSps->uiPocType*/); // pic_order_cnt_type BsWriteUE (pLocalBitStringAux, pSps->iLog2MaxPocLsb - 4); // log2_max_pic_order_cnt_lsb_minus4 BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); // max_num_ref_frames BsWriteOneBit (pLocalBitStringAux, true/*pSps->bGapsInFrameNumValueAllowedFlag*/); // bGapsInFrameNumValueAllowedFlag BsWriteUE (pLocalBitStringAux, pSps->iMbWidth - 1); // pic_width_in_mbs_minus1 BsWriteUE (pLocalBitStringAux, pSps->iMbHeight - 1); // pic_height_in_map_units_minus1 BsWriteOneBit (pLocalBitStringAux, true/*pSps->bFrameMbsOnlyFlag*/); // bFrameMbsOnlyFlag BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bDirect8x8InferenceFlag*/); // direct_8x8_inference_flag BsWriteOneBit (pLocalBitStringAux, pSps->bFrameCroppingFlag); // bFrameCroppingFlag if (pSps->bFrameCroppingFlag) { BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropLeft); // frame_crop_left_offset BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropRight); // frame_crop_right_offset BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropTop); // frame_crop_top_offset BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropBottom); // frame_crop_bottom_offset } BsWriteOneBit (pLocalBitStringAux, 0/*pSps->bVuiParamPresentFlag*/); // vui_parameters_present_flag return 0; }