Exemplo n.º 1
0
        public IParseResult <TOutput> Parse(ISequence <TInput> t)
        {
            // small optimization, don't allocate a buffer if we only need one item
            if (_find.Length == 1)
            {
                return(t.Peek().Equals(_find[0]) ? new SuccessResult <TOutput>(_produce(new[] { t.GetNext() })) : (IParseResult <TOutput>) new FailResult <TOutput>());
            }

            var window = new WindowSequence <TInput>(t);
            var buffer = new TInput[_find.Length];

            for (var i = 0; i < _find.Length; i++)
            {
                buffer[i] = window.GetNext();
                if (buffer[i].Equals(_find[i]))
                {
                    continue;
                }

                window.Rewind();
                return(new FailResult <TOutput>());
            }

            return(new SuccessResult <TOutput>(_produce(buffer)));
        }
 public ICSInfo(int frameLength)
 {
     this.frameLength  = frameLength;
     windowShape       = new int[2];
     windowSequence    = WindowSequence.ONLY_LONG_SEQUENCE;
     windowGroupLength = new int[MAX_WINDOW_GROUP_COUNT];
     ltpData1Present   = false;
     ltpData2Present   = false;
 }
Exemplo n.º 3
0
    /// <summary>
    /// 恢复场景切换窗口序列
    /// </summary>
    /// <returns>窗口组</returns>
    public List <int> RestoreToggleSceneWindowSequence()
    {
        List <int>             winIds = new List <int>();
        Stack <WindowSequence> stack  = OnGetOpenWindowSequence();

        if (stack.Count > 0)
        {
            Dictionary <int, UIWindowHolder> winHolders = OnSearchAllWindowHolders();
            WindowSequence ws = stack.Pop();
            winIds = ws.sequenceCloseWindows;
        }
        return(winIds);
    }
        // --- ========== decoding ========== ---
        public void decode(BitStream inStream, DecoderConfig conf, bool commonWindow)
        {
            var sf = conf.getSampleFrequency();

            if (sf.getIndex() == -1)
            {
                throw new AACException("invalid sample frequency");
            }

            inStream.skipBit(); //reserved
            windowSequence        = (WindowSequence)inStream.readBits(2);
            windowShape[PREVIOUS] = windowShape[CURRENT];
            windowShape[CURRENT]  = inStream.readBit();

            windowGroupCount     = 1;
            windowGroupLength[0] = 1;
            if (windowSequence == WindowSequence.EIGHT_SHORT_SEQUENCE)
            {
                maxSFB = inStream.readBits(4);
                int i;
                for (i = 0; i < 7; i++)
                {
                    if (inStream.readBool())
                    {
                        windowGroupLength[windowGroupCount - 1]++;
                    }
                    else
                    {
                        windowGroupCount++;
                        windowGroupLength[windowGroupCount - 1] = 1;
                    }
                }
                windowCount           = 8;
                swbOffsets            = SWB_OFFSET_SHORT_WINDOW[sf.getIndex()];
                swbCount              = SWB_SHORT_WINDOW_COUNT[sf.getIndex()];
                predictionDataPresent = false;
            }
            else
            {
                maxSFB                = inStream.readBits(6);
                windowCount           = 1;
                swbOffsets            = SWB_OFFSET_LONG_WINDOW[sf.getIndex()];
                swbCount              = SWB_LONG_WINDOW_COUNT[sf.getIndex()];
                predictionDataPresent = inStream.readBool();
                if (predictionDataPresent)
                {
                    readPredictionData(inStream, conf.getProfile(), sf, commonWindow);
                }
            }
        }
Exemplo n.º 5
0
        public IParseResult <TOutput> Parse(ISequence <TInput> t)
        {
            var window  = new WindowSequence <TInput>(t);
            var outputs = new object[_parsers.Count];

            for (var i = 0; i < _parsers.Count; i++)
            {
                var result = _parsers[i].ParseUntyped(window);
                if (!result.Success)
                {
                    window.Rewind();
                    return(new FailResult <TOutput>());
                }

                outputs[i] = result.Value;
            }

            return(new SuccessResult <TOutput>(_produce(outputs)));
        }
Exemplo n.º 6
0
    /// <summary>
    /// 获得自动存储序列
    /// </summary>
    /// <param name="_closeWinIds">关闭的窗口组</param>
    /// <returns>存储序列</returns>
    public List <int> GetAutoRestoreSequence(List <int> _closeWinIds)
    {
        List <int>             winIds = new List <int>();
        Stack <WindowSequence> stack  = OnGetOpenWindowSequence();

#if DEBUGLOG
        Debug.LogFormat("【Before】GetAutoRestoreSequence=>Close【{0}】,Stack=>【{1}】", _closeWinIds.JsonSerialize(), stack.JsonSerialize());
#endif
        if (stack.Count > 0)
        {
            WindowSequence ws = stack.Peek();
            if (ws.IsSameOpenWindow(_closeWinIds))
            {
                winIds = ws.sequenceCloseWindows;
                stack.Pop();
            }
        }
#if DEBUGLOG
        Debug.LogFormat("【After】GetAutoRestoreSequence=>Close【{0}】,Stack=>【{1}】", _closeWinIds.JsonSerialize(), stack.JsonSerialize());
#endif
        return(winIds);
    }
 public void setData(ICSInfo info)
 {
     windowSequence        = info.windowSequence;
     windowShape[PREVIOUS] = windowShape[CURRENT];
     windowShape[CURRENT]  = info.windowShape[CURRENT];
     maxSFB = info.maxSFB;
     predictionDataPresent = info.predictionDataPresent;
     if (predictionDataPresent)
     {
         icPredict = info.icPredict;
     }
     ltpData1Present = info.ltpData1Present;
     if (ltpData1Present)
     {
         throw new NotImplementedException();
         //ltPredict1.copy(info.ltPredict1);
         //ltPredict2.copy(info.ltPredict2);
     }
     windowCount       = info.windowCount;
     windowGroupCount  = info.windowGroupCount;
     windowGroupLength = info.windowGroupLength.ToArray();
     swbCount          = info.swbCount;
     swbOffsets        = info.swbOffsets.ToArray();
 }
Exemplo n.º 8
0
    /// <summary>
    /// 开启窗口序列
    /// </summary>
    /// <param name="_winCfgs">窗口配置组</param>
    public void OpenWindowSerialize(XLS_Config_Table_UIWindowSetting[] _winCfgs)
    {
        Dictionary <int, int>            sameLayerLessThenSiblingIndex = new Dictionary <int, int>();
        List <int>                       lessThenSiblingIndex          = new List <int>();
        Dictionary <int, UIWindowHolder> winHolders          = OnSearchAllWindowHolders();
        List <int>                       openWinIds          = new List <int>();
        List <int>                       sequenceCloseWinIds = new List <int>();

        if (_winCfgs != null && _winCfgs.Length > 0)
        {
            #region 统计需要隐藏的各层级的最大SiblingIndex
            foreach (XLS_Config_Table_UIWindowSetting cfg in _winCfgs)
            {
                if (!openWinIds.Contains(cfg.id))
                {
                    openWinIds.Add(cfg.id);
                }
                switch (cfg.winOpenMode)
                {
                case enUIWindowOpenMode.WhenDisplayHiddenSameLayerAndLessThanSiblingIndex:
                    if (!sameLayerLessThenSiblingIndex.ContainsKey(cfg.layer))
                    {
                        sameLayerLessThenSiblingIndex.Add(cfg.layer, winHolders[cfg.id].windowSiblingIndex);
                    }
                    else
                    {
                        sameLayerLessThenSiblingIndex[cfg.layer] = Mathf.Max(sameLayerLessThenSiblingIndex[cfg.layer], winHolders[cfg.id].windowSiblingIndex);
                    }
                    break;

                case enUIWindowOpenMode.WhenDisplayHiddenLessThanSiblingIndex:
                    if (!lessThenSiblingIndex.Contains(winHolders[cfg.id].windowSiblingIndex))
                    {
                        lessThenSiblingIndex.Add(winHolders[cfg.id].windowSiblingIndex);
                    }
                    else
                    {
                        lessThenSiblingIndex[0] = Mathf.Max(lessThenSiblingIndex[0], winHolders[cfg.id].windowSiblingIndex);
                    }
                    break;
                }
            }
            #endregion
        }
        List <int> hiddenWinIds = new List <int>();
        if (winHolders != null && winHolders.Count > 0)
        {
            #region 收集要隐藏的窗口ID
            foreach (KeyValuePair <int, UIWindowHolder> holder in winHolders)
            {
                if (
                    sameLayerLessThenSiblingIndex.ContainsKey(holder.Value.winCfg.layer) &&
                    holder.Value.windowSiblingIndex < sameLayerLessThenSiblingIndex[holder.Value.winCfg.layer]
                    )
                {
                    if (!hiddenWinIds.Contains(holder.Key))
                    {
                        hiddenWinIds.Add(holder.Key);
                    }
                    if (!sequenceCloseWinIds.Contains(holder.Key) && holder.Value.winCfg.isAutoRestoreSequenceWindow)
                    {
                        sequenceCloseWinIds.Add(holder.Key);
                    }
                }
                if (
                    lessThenSiblingIndex.Count > 0 &&
                    holder.Value.windowSiblingIndex < lessThenSiblingIndex[0]
                    )
                {
                    if (!hiddenWinIds.Contains(holder.Key))
                    {
                        hiddenWinIds.Add(holder.Key);
                    }
                    if (!sequenceCloseWinIds.Contains(holder.Key) && holder.Value.winCfg.isAutoRestoreSequenceWindow)
                    {
                        sequenceCloseWinIds.Add(holder.Key);
                    }
                }
            }
            #endregion
        }

        foreach (int wid in hiddenWinIds)
        {
            winHolders[wid].SetTargetActive(false);
        }

        Stack <WindowSequence> winSeq = OnGetOpenWindowSequence();
        if (winSeq.Count > 0)
        {
            WindowSequence ws = winSeq.Peek();
            if (!ws.IsSameOpenWindow(openWinIds))
            {
                winSeq.Push(new WindowSequence(openWinIds, sequenceCloseWinIds));
            }
        }
        else if (openWinIds.Count > 0)
        {
            winSeq.Push(new WindowSequence(openWinIds, sequenceCloseWinIds));
        }
#if DEBUGLOG
        Debug.LogFormat("sameLayerLessThenSiblingIndex【{0}】,lessThenSiblingIndex【{1}】,hiddenWinIds【{2}】",
                        sameLayerLessThenSiblingIndex.JsonSerialize(), lessThenSiblingIndex.JsonSerialize(), hiddenWinIds.JsonSerialize());
        Debug.LogFormat("open windows=>【{0}】,sequence close windows=>【{1}】", openWinIds.JsonSerialize(), sequenceCloseWinIds.JsonSerialize());
#endif
    }