Ejemplo n.º 1
0
        private string ReadKeyIfIncluded(Bitstream stream, List<string> keyHistory)
        {
            var has_key = stream.ReadBool();

            if (!has_key)
            {
                return null;
            }

            var is_substring = stream.ReadBool();

            string key;

            if (!is_substring)
            {
                key = stream.ReadString();
            }
            else
            {
                var fromIndex = (int) stream.ReadBits(5);
                var fromLength = (int) stream.ReadBits(5);
                key = keyHistory[fromIndex].Substring(0, fromLength);

                key += stream.ReadString();
            }

            if (keyHistory.Count == KEY_HISTORY_SIZE)
            {
                keyHistory.RemoveAt(0);
            }

            keyHistory.Add(key);

            return key;
        }