func (this *TDecTop) xDecodeVPS() { vps := TLibCommon.NewTComVPS() this.m_cEntropyDecoder.DecodeVPS(vps) this.m_parameterSetManagerDecoder.SetVPS(vps) this.m_prevPOC = TLibCommon.MAX_INT }
func (this *TAppEncTop) xInitLibCfg() { ///< initialize internal variables vps := TLibCommon.NewTComVPS() vps.SetMaxTLayers(uint(this.m_maxTempLayer)) if this.m_maxTempLayer == 1 { vps.SetTemporalNestingFlag(true) } vps.SetMaxLayers(1) for i := 0; i < TLibCommon.MAX_TLAYER; i++ { vps.SetNumReorderPics(uint(this.m_numReorderPics[i]), uint(i)) vps.SetMaxDecPicBuffering(uint(this.m_maxDecPicBuffering[i]), uint(i)) } pcEncCfg := TLibEncoder.NewTEncCfg() pcEncCfg.SetVPS(vps) pcEncCfg.SetProfile(TLibCommon.PROFILE(this.m_profile)) pcEncCfg.SetLevel(TLibCommon.TIER(this.m_levelTier), TLibCommon.LEVEL(this.m_level)) //#if L0046_CONSTRAINT_FLAGS pcEncCfg.SetProgressiveSourceFlag(this.m_progressiveSourceFlag) pcEncCfg.SetInterlacedSourceFlag(this.m_interlacedSourceFlag) pcEncCfg.SetNonPackedConstraintFlag(this.m_nonPackedConstraintFlag) pcEncCfg.SetFrameOnlyConstraintFlag(this.m_frameOnlyConstraintFlag) //#endif pcEncCfg.SetFrameRate(this.m_iFrameRate) pcEncCfg.SetFrameSkip(this.m_FrameSkip) pcEncCfg.SetSourceWidth(this.m_iSourceWidth) pcEncCfg.SetSourceHeight(this.m_iSourceHeight) pcEncCfg.SetConformanceWindow(this.m_confLeft, this.m_confRight, this.m_confTop, this.m_confBottom) pcEncCfg.SetFramesToBeEncoded(this.m_framesToBeEncoded) //====== Coding Structure ======== pcEncCfg.SetIntraPeriod(this.m_iIntraPeriod) pcEncCfg.SetDecodingRefreshType(this.m_iDecodingRefreshType) pcEncCfg.SetGOPSize(this.m_iGOPSize) pcEncCfg.SetGopList(this.m_GOPList[:]) pcEncCfg.SetExtraRPSs(this.m_extraRPSs) for i := 0; i < TLibCommon.MAX_TLAYER; i++ { pcEncCfg.SetNumReorderPics(this.m_numReorderPics[i], uint(i)) pcEncCfg.SetMaxDecPicBuffering(uint(this.m_maxDecPicBuffering[i]), uint(i)) } for uiLoop := 0; uiLoop < TLibCommon.MAX_TLAYER; uiLoop++ { pcEncCfg.SetLambdaModifier(uint(uiLoop), this.m_adLambdaModifier[uiLoop]) } pcEncCfg.SetQP(this.m_iQP) pcEncCfg.SetPad(this.m_aiPad[:]) pcEncCfg.SetMaxTempLayer(this.m_maxTempLayer) pcEncCfg.SetUseAMP(this.m_enableAMP) //===== Slice ======== //====== Loop/Deblock Filter ======== pcEncCfg.SetLoopFilterDisable(this.m_bLoopFilterDisable) pcEncCfg.SetLoopFilterOffsetInPPS(this.m_loopFilterOffsetInPPS) pcEncCfg.SetLoopFilterBetaOffset(this.m_loopFilterBetaOffsetDiv2) pcEncCfg.SetLoopFilterTcOffset(this.m_loopFilterTcOffsetDiv2) pcEncCfg.SetDeblockingFilterControlPresent(this.m_DeblockingFilterControlPresent) //====== Motion search ======== pcEncCfg.SetFastSearch(this.m_iFastSearch) pcEncCfg.SetSearchRange(this.m_iSearchRange) pcEncCfg.SetBipredSearchRange(this.m_bipredSearchRange) //====== Quality control ======== pcEncCfg.SetMaxDeltaQP(this.m_iMaxDeltaQP) pcEncCfg.SetMaxCuDQPDepth(this.m_iMaxCuDQPDepth) pcEncCfg.SetChromaCbQpOffset(this.m_cbQpOffset) pcEncCfg.SetChromaCrQpOffset(this.m_crQpOffset) //#if ADAPTIVE_QP_SELECTION pcEncCfg.SetUseAdaptQpSelect(this.m_bUseAdaptQpSelect) //#endif var lowestQP int lowestQP = -6 * (TLibCommon.G_bitDepthY - 8) // XXX: check if (this.m_iMaxDeltaQP == 0) && (this.m_iQP == lowestQP) && (this.m_useLossless == true) { this.m_bUseAdaptiveQP = false } pcEncCfg.SetUseAdaptiveQP(this.m_bUseAdaptiveQP) pcEncCfg.SetQPAdaptationRange(this.m_iQPAdaptationRange) //====== Tool list ======== pcEncCfg.SetUseSBACRD(this.m_bUseSBACRD) pcEncCfg.SetDeltaQpRD(this.m_uiDeltaQpRD) pcEncCfg.SetUseASR(this.m_bUseASR) pcEncCfg.SetUseHADME(this.m_bUseHADME) pcEncCfg.SetUseLossless(this.m_useLossless) pcEncCfg.SetUseLComb(this.m_bUseLComb) pcEncCfg.SetdQPs(this.m_aidQP) pcEncCfg.SetUseRDOQ(this.m_useRDOQ) pcEncCfg.SetUseRDOQTS(this.m_useRDOQTS) //#if L0232_RD_PENALTY pcEncCfg.SetRDpenalty(this.m_rdPenalty) //#endif pcEncCfg.SetQuadtreeTULog2MaxSize(this.m_uiQuadtreeTULog2MaxSize) pcEncCfg.SetQuadtreeTULog2MinSize(this.m_uiQuadtreeTULog2MinSize) pcEncCfg.SetQuadtreeTUMaxDepthInter(this.m_uiQuadtreeTUMaxDepthInter) pcEncCfg.SetQuadtreeTUMaxDepthIntra(this.m_uiQuadtreeTUMaxDepthIntra) pcEncCfg.SetUseFastEnc(this.m_bUseFastEnc) pcEncCfg.SetUseEarlyCU(this.m_bUseEarlyCU) pcEncCfg.SetUseFastDecisionForMerge(this.m_useFastDecisionForMerge) pcEncCfg.SetUseCbfFastMode(this.m_bUseCbfFastMode) pcEncCfg.SetUseEarlySkipDetection(this.m_useEarlySkipDetection) pcEncCfg.SetUseTransformSkip(this.m_useTransformSkip) pcEncCfg.SetUseTransformSkipFast(this.m_useTransformSkipFast) pcEncCfg.SetUseConstrainedIntraPred(this.m_bUseConstrainedIntraPred) pcEncCfg.SetPCMLog2MinSize(this.m_uiPCMLog2MinSize) pcEncCfg.SetUsePCM(this.m_usePCM) pcEncCfg.SetPCMLog2MaxSize(this.m_pcmLog2MaxSize) pcEncCfg.SetMaxNumMergeCand(this.m_maxNumMergeCand) //====== Weighted Prediction ======== pcEncCfg.SetUseWP(this.m_useWeightedPred) pcEncCfg.SetWPBiPred(this.m_useWeightedBiPred) //====== Parallel Merge Estimation ======== pcEncCfg.SetLog2ParallelMergeLevelMinus2(this.m_log2ParallelMergeLevel - 2) //====== Slice ======== pcEncCfg.SetSliceMode(this.m_sliceMode) pcEncCfg.SetSliceArgument(this.m_sliceArgument) //====== Dependent Slice ======== pcEncCfg.SetSliceSegmentMode(this.m_sliceSegmentMode) pcEncCfg.SetSliceSegmentArgument(this.m_sliceSegmentArgument) iNumPartInCU := 1 << (this.m_uiMaxCUDepth << 1) if this.m_sliceSegmentMode == TLibCommon.FIXED_NUMBER_OF_LCU { pcEncCfg.SetSliceSegmentArgument(this.m_sliceSegmentArgument * iNumPartInCU) } if this.m_sliceMode == TLibCommon.FIXED_NUMBER_OF_LCU { pcEncCfg.SetSliceArgument(this.m_sliceArgument * iNumPartInCU) } if this.m_sliceMode == TLibCommon.FIXED_NUMBER_OF_TILES { pcEncCfg.SetSliceArgument(this.m_sliceArgument) } if this.m_sliceMode == 0 { this.m_bLFCrossSliceBoundaryFlag = true } pcEncCfg.SetLFCrossSliceBoundaryFlag(this.m_bLFCrossSliceBoundaryFlag) pcEncCfg.SetUseSAO(this.m_bUseSAO) pcEncCfg.SetMaxNumOffsetsPerPic(this.m_maxNumOffsetsPerPic) pcEncCfg.SetSaoLcuBoundary(this.m_saoLcuBoundary) pcEncCfg.SetSaoLcuBasedOptimization(this.m_saoLcuBasedOptimization) pcEncCfg.SetPCMInputBitDepthFlag(this.m_bPCMInputBitDepthFlag) pcEncCfg.SetPCMFilterDisableFlag(this.m_bPCMFilterDisableFlag) pcEncCfg.SetDecodedPictureHashSEIEnabled(this.m_decodedPictureHashSEIEnabled) pcEncCfg.SetRecoveryPointSEIEnabled(this.m_recoveryPointSEIEnabled) pcEncCfg.SetBufferingPeriodSEIEnabled(this.m_bufferingPeriodSEIEnabled) pcEncCfg.SetPictureTimingSEIEnabled(this.m_pictureTimingSEIEnabled) pcEncCfg.SetFramePackingArrangementSEIEnabled(this.m_framePackingSEIEnabled) pcEncCfg.SetFramePackingArrangementSEIType(this.m_framePackingSEIType) pcEncCfg.SetFramePackingArrangementSEIId(this.m_framePackingSEIId) pcEncCfg.SetFramePackingArrangementSEIQuincunx(this.m_framePackingSEIQuincunx) pcEncCfg.SetFramePackingArrangementSEIInterpretation(this.m_framePackingSEIInterpretation) pcEncCfg.SetDisplayOrientationSEIAngle(this.m_displayOrientationSEIAngle) pcEncCfg.SetTemporalLevel0IndexSEIEnabled(this.m_temporalLevel0IndexSEIEnabled) pcEncCfg.SetUniformSpacingIdr(this.m_iUniformSpacingIdr) pcEncCfg.SetNumColumnsMinus1(this.m_iNumColumnsMinus1) pcEncCfg.SetNumRowsMinus1(this.m_iNumRowsMinus1) if this.m_iUniformSpacingIdr == 0 { pcEncCfg.SetColumnWidth(this.m_pColumnWidth) pcEncCfg.SetRowHeight(this.m_pRowHeight) } pcEncCfg.XCheckGSParameters() uiTilesCount := (this.m_iNumRowsMinus1 + 1) * (this.m_iNumColumnsMinus1 + 1) if uiTilesCount == 1 { this.m_bLFCrossTileBoundaryFlag = true } pcEncCfg.SetLFCrossTileBoundaryFlag(this.m_bLFCrossTileBoundaryFlag) pcEncCfg.SetWaveFrontSynchro(this.m_iWaveFrontSynchro) pcEncCfg.SetWaveFrontSubstreams(this.m_iWaveFrontSubstreams) pcEncCfg.SetTMVPModeId(this.m_TMVPModeId) pcEncCfg.SetUseScalingListId(this.m_useScalingListId) pcEncCfg.SetScalingListFile(this.m_scalingListFile) pcEncCfg.SetSignHideFlag(this.m_signHideFlag) //#if RATE_CONTROL_LAMBDA_DOMAIN pcEncCfg.SetUseRateCtrl(this.m_RCEnableRateControl) pcEncCfg.SetTargetBitrate(this.m_RCTargetBitrate) pcEncCfg.SetKeepHierBit(this.m_RCKeepHierarchicalBit) pcEncCfg.SetLCULevelRC(this.m_RCLCULevelRC) pcEncCfg.SetUseLCUSeparateModel(this.m_RCUseLCUSeparateModel) pcEncCfg.SetInitialQP(this.m_RCInitialQP) pcEncCfg.SetForceIntraQP(this.m_RCForceIntraQP) //#else // pcEncCfg.SetUseRateCtrl ( this.m_enableRateCtrl); // pcEncCfg.SetTargetBitrate ( this.m_targetBitrate); // pcEncCfg.SetNumLCUInUnit ( this.m_numLCUInUnit); //#endif pcEncCfg.SetTransquantBypassEnableFlag(this.m_TransquantBypassEnableFlag) pcEncCfg.SetCUTransquantBypassFlagValue(this.m_CUTransquantBypassFlagValue) pcEncCfg.SetUseRecalculateQPAccordingToLambda(this.m_recalculateQPAccordingToLambda) pcEncCfg.SetUseStrongIntraSmoothing(this.m_useStrongIntraSmoothing) pcEncCfg.SetActiveParameterSetsSEIEnabled(this.m_activeParameterSetsSEIEnabled) pcEncCfg.SetVuiParametersPresentFlag(this.m_vuiParametersPresentFlag) pcEncCfg.SetAspectRatioIdc(this.m_aspectRatioIdc) pcEncCfg.SetSarWidth(this.m_sarWidth) pcEncCfg.SetSarHeight(this.m_sarHeight) pcEncCfg.SetOverscanInfoPresentFlag(this.m_overscanInfoPresentFlag) pcEncCfg.SetOverscanAppropriateFlag(this.m_overscanAppropriateFlag) pcEncCfg.SetVideoSignalTypePresentFlag(this.m_videoSignalTypePresentFlag) pcEncCfg.SetVideoFormat(this.m_videoFormat) pcEncCfg.SetVideoFullRangeFlag(this.m_videoFullRangeFlag) pcEncCfg.SetColourDescriptionPresentFlag(this.m_colourDescriptionPresentFlag) pcEncCfg.SetColourPrimaries(this.m_colourPrimaries) pcEncCfg.SetTransferCharacteristics(this.m_transferCharacteristics) pcEncCfg.SetMatrixCoefficients(this.m_matrixCoefficients) pcEncCfg.SetChromaLocInfoPresentFlag(this.m_chromaLocInfoPresentFlag) pcEncCfg.SetChromaSampleLocTypeTopField(this.m_chromaSampleLocTypeTopField) pcEncCfg.SetChromaSampleLocTypeBottomField(this.m_chromaSampleLocTypeBottomField) pcEncCfg.SetNeutralChromaIndicationFlag(this.m_neutralChromaIndicationFlag) pcEncCfg.SetDefaultDisplayWindow(this.m_defDispWinLeftOffset, this.m_defDispWinRightOffset, this.m_defDispWinTopOffset, this.m_defDispWinBottomOffset) pcEncCfg.SetFrameFieldInfoPresentFlag(this.m_frameFieldInfoPresentFlag) pcEncCfg.SetPocProportionalToTimingFlag(this.m_pocProportionalToTimingFlag) pcEncCfg.SetNumTicksPocDiffOneMinus1(this.m_numTicksPocDiffOneMinus1) pcEncCfg.SetBitstreamRestrictionFlag(this.m_bitstreamRestrictionFlag) pcEncCfg.SetTilesFixedStructureFlag(this.m_tilesFixedStructureFlag) pcEncCfg.SetMotionVectorsOverPicBoundariesFlag(this.m_motionVectorsOverPicBoundariesFlag) pcEncCfg.SetMinSpatialSegmentationIdc(this.m_minSpatialSegmentationIdc) pcEncCfg.SetMaxBytesPerPicDenom(this.m_maxBytesPerPicDenom) pcEncCfg.SetMaxBitsPerMinCuDenom(this.m_maxBitsPerMinCuDenom) pcEncCfg.SetLog2MaxMvLengthHorizontal(this.m_log2MaxMvLengthHorizontal) pcEncCfg.SetLog2MaxMvLengthVertical(this.m_log2MaxMvLengthVertical) this.m_cTEncTop.SetEncCfg(pcEncCfg) }