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

Function WelsWriteSpsSyntax

codec/encoder/core/src/au_set.cpp:264–333  ·  view source on GitHub ↗

! ************************************************************************************* * \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. *********************

Source from the content-addressed store, hash-verified

262 *************************************************************************************
263 */
264int32_t WelsWriteSpsSyntax (SWelsSPS* pSps, SBitStringAux* pBitStringAux, int32_t* pSpsIdDelta, bool bBaseLayer) {
265 SBitStringAux* pLocalBitStringAux = pBitStringAux;
266
267 assert (pSps != NULL && pBitStringAux != NULL);
268
269 BsWriteBits (pLocalBitStringAux, 8, pSps->uiProfileIdc);
270
271 BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet0Flag); // bConstraintSet0Flag
272 BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet1Flag); // bConstraintSet1Flag
273 BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet2Flag); // bConstraintSet2Flag
274 BsWriteOneBit (pLocalBitStringAux, pSps->bConstraintSet3Flag); // bConstraintSet3Flag
275 if (PRO_HIGH == pSps->uiProfileIdc || PRO_EXTENDED == pSps->uiProfileIdc ||
276 PRO_MAIN == pSps->uiProfileIdc) {
277 BsWriteOneBit (pLocalBitStringAux, 1); // bConstraintSet4Flag: If profile_idc is equal to 77, 88, or 100, constraint_set4_flag equal to 1 indicates that the value of frame_mbs_only_flag is equal to 1. constraint_set4_flag equal to 0 indicates that the value of frame_mbs_only_flag may or may not be equal to 1.
278 BsWriteOneBit (pLocalBitStringAux, 1); // bConstraintSet5Flag: If profile_idc is equal to 77, 88, or 100, constraint_set5_flag equal to 1 indicates that B slice types are not present in the coded video sequence. constraint_set5_flag equal to 0 indicates that B slice types may or may not be present in the coded video sequence.
279 BsWriteBits (pLocalBitStringAux, 2, 0); // reserved_zero_2bits, equal to 0
280 } else {
281 BsWriteBits (pLocalBitStringAux, 4, 0); // reserved_zero_4bits, equal to 0
282 }
283 BsWriteBits (pLocalBitStringAux, 8, pSps->iLevelIdc); // iLevelIdc
284 BsWriteUE (pLocalBitStringAux, pSps->uiSpsId + pSpsIdDelta[pSps->uiSpsId]); // seq_parameter_set_id
285
286 if (PRO_SCALABLE_BASELINE == pSps->uiProfileIdc || PRO_SCALABLE_HIGH == pSps->uiProfileIdc ||
287 PRO_HIGH == pSps->uiProfileIdc || PRO_HIGH10 == pSps->uiProfileIdc ||
288 PRO_HIGH422 == pSps->uiProfileIdc || PRO_HIGH444 == pSps->uiProfileIdc ||
289 PRO_CAVLC444 == pSps->uiProfileIdc || 44 == pSps->uiProfileIdc) {
290 BsWriteUE (pLocalBitStringAux, 1); //uiChromaFormatIdc, now should be 1
291 BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthLuma
292 BsWriteUE (pLocalBitStringAux, 0); //uiBitDepthChroma
293 BsWriteOneBit (pLocalBitStringAux, 0); //qpprime_y_zero_transform_bypass_flag
294 BsWriteOneBit (pLocalBitStringAux, 0); //seq_scaling_matrix_present_flag
295 }
296
297 BsWriteUE (pLocalBitStringAux, pSps->uiLog2MaxFrameNum - 4); // log2_max_frame_num_minus4
298 BsWriteUE (pLocalBitStringAux, pSps->uiPocType); // pic_order_cnt_type
299 if (pSps->uiPocType == 0) {
300 BsWriteUE (pLocalBitStringAux, pSps->iLog2MaxPocLsb - 4); // log2_max_pic_order_cnt_lsb_minus4
301 } else if (pSps->uiPocType == 1) {
302 // TODO: implement
303 assert (0);
304 } else {
305 // no-op for uiPocType 2.
306 }
307
308 BsWriteUE (pLocalBitStringAux, pSps->iNumRefFrames); // max_num_ref_frames
309 BsWriteOneBit (pLocalBitStringAux, pSps->bGapsInFrameNumValueAllowedFlag); //gaps_in_frame_numvalue_allowed_flag
310 BsWriteUE (pLocalBitStringAux, pSps->iMbWidth - 1); // pic_width_in_mbs_minus1
311 BsWriteUE (pLocalBitStringAux, pSps->iMbHeight - 1); // pic_height_in_map_units_minus1
312 BsWriteOneBit (pLocalBitStringAux, true/*pSps->bFrameMbsOnlyFlag*/); // bFrameMbsOnlyFlag
313
314 uint8_t d8x8 = 0;
315 if (pSps->iLevelIdc >= 30)
316 d8x8 = 1;
317 BsWriteOneBit (pLocalBitStringAux, d8x8/*pSps->bDirect8x8InferenceFlag*/); // direct_8x8_inference_flag
318
319 BsWriteOneBit (pLocalBitStringAux, pSps->bFrameCroppingFlag); // bFrameCroppingFlag
320 if (pSps->bFrameCroppingFlag) {
321 BsWriteUE (pLocalBitStringAux, pSps->sFrameCrop.iCropLeft); // frame_crop_left_offset

Callers 2

WelsWriteSpsNalFunction · 0.85
WelsWriteSubsetSpsSyntaxFunction · 0.85

Calls 4

BsWriteBitsFunction · 0.85
BsWriteOneBitFunction · 0.85
BsWriteUEFunction · 0.85
WelsWriteVUIFunction · 0.85

Tested by

no test coverage detected