Пример #1
0
        public virtual void WarmupHashHashLongestMatchQuickly(int size, uint[] dict, global::encode.hash.HashLongestMatchQuickly hasher)
        {
            int _g1 = 0;

            while ((_g1 < size))
            {
                hasher.Store(dict, 0, _g1++);
            }
        }
Пример #2
0
 public static void __hx_ctor_encode_hash_HashLongestMatchQuickly(global::encode.hash.HashLongestMatchQuickly __hx_this, int kBucketBits, int kBucketSweep, bool kUseDictionary)
 {
     unchecked {
         __hx_this.kBucketBits    = kBucketBits;
         __hx_this.kBucketSweep   = kBucketSweep;
         __hx_this.kUseDictionary = kUseDictionary;
         __hx_this.kBucketSize    = ((uint)((1 << kBucketBits)));
         __hx_this.buckets_       = ((uint[])(new uint[((int)(((uint)((__hx_this.kBucketSize + kBucketSweep)))))]));
         __hx_this.Reset();
     }
 }
Пример #3
0
        public override object __hx_setField(string field, int hash, object @value, bool handleProperties)
        {
            unchecked {
                switch (hash)
                {
                case 695309794:
                {
                    this.hash_h9 = ((global::encode.hash.HashLongestMatch)(@value));
                    return(@value);
                }


                case 695309793:
                {
                    this.hash_h8 = ((global::encode.hash.HashLongestMatch)(@value));
                    return(@value);
                }


                case 695309792:
                {
                    this.hash_h7 = ((global::encode.hash.HashLongestMatch)(@value));
                    return(@value);
                }


                case 695309791:
                {
                    this.hash_h6 = ((global::encode.hash.HashLongestMatch)(@value));
                    return(@value);
                }


                case 695309790:
                {
                    this.hash_h5 = ((global::encode.hash.HashLongestMatch)(@value));
                    return(@value);
                }


                case 695309789:
                {
                    this.hash_h4 = ((global::encode.hash.HashLongestMatchQuickly)(@value));
                    return(@value);
                }


                case 695309788:
                {
                    this.hash_h3 = ((global::encode.hash.HashLongestMatchQuickly)(@value));
                    return(@value);
                }


                case 695309787:
                {
                    this.hash_h2 = ((global::encode.hash.HashLongestMatchQuickly)(@value));
                    return(@value);
                }


                case 695309786:
                {
                    this.hash_h1 = ((global::encode.hash.HashLongestMatchQuickly)(@value));
                    return(@value);
                }


                default:
                {
                    return(base.__hx_setField(field, hash, @value, handleProperties));
                }
                }
            }
        }
Пример #4
0
        public static void CreateBackwardReferences_HashLongestMatchQuickly(int num_bytes, int position, uint[] ringbuffer, int ringbuffer_mask, int max_backward_limit, int quality, global::encode.hash.HashLongestMatchQuickly hasher, int[] dist_cache, global::Array <int> last_insert_len, global::Array <object> commands, int commands_off, global::Array <int> num_commands, global::Array <int> num_literals)
        {
            unchecked {
                if (((num_bytes >= 3) && (position >= 3)))
                {
                    hasher.Store(ringbuffer, ((position - 3) & ringbuffer_mask), (position - 3));
                    hasher.Store(ringbuffer, ((position - 2) & ringbuffer_mask), (position - 2));
                    hasher.Store(ringbuffer, ((position - 1) & ringbuffer_mask), (position - 1));
                }

                int orig_commands_off = commands_off;
                int insert_length     = last_insert_len[0];
                int i      = (position & ringbuffer_mask);
                int i_diff = (position - i);
                int i_end  = (i + num_bytes);
                int random_heuristics_window_size = (((quality < 9)) ? (64) : (512));
                int apply_random_heuristics       = (i + random_heuristics_window_size);
                while (((i + 3) < i_end))
                {
                    int max_length   = (i_end - i);
                    int max_distance = ((int)(global::System.Math.Min(((double)((i + i_diff))), ((double)(max_backward_limit)))));
                    global::Array <int>    best_len      = new global::Array <int>(new int[] { 0 });
                    global::Array <int>    best_len_code = new global::Array <int>(new int[] { 0 });
                    global::Array <int>    best_dist     = new global::Array <int>(new int[] { 0 });
                    global::Array <double> best_score    = new global::Array <double>(new double[] { 4.0 });
                    bool match_found = hasher.FindLongestMatch(ringbuffer, ringbuffer_mask, dist_cache, (i + i_diff), max_length, max_distance, best_len, best_len_code, best_dist, best_score);
                    if (match_found)
                    {
                        int delayed_backward_references_in_row = 0;
                        while (true)
                        {
                            --max_length;
                            global::Array <int>    best_len_2      = new global::Array <int>(new int[] { (((quality < 5)) ? (((int)(global::System.Math.Min(((double)((best_len[0] - 1))), ((double)(max_length)))))) : (0)) });
                            global::Array <int>    best_len_code_2 = new global::Array <int>(new int[] { 0 });
                            global::Array <int>    best_dist_2     = new global::Array <int>(new int[] { 0 });
                            global::Array <double> best_score_2    = new global::Array <double>(new double[] { 4.0 });
                            max_distance = ((int)(global::System.Math.Min(((double)(((i + i_diff) + 1))), ((double)(max_backward_limit)))));
                            hasher.Store(ringbuffer, i, (i + i_diff));
                            match_found = hasher.FindLongestMatch(ringbuffer, ringbuffer_mask, dist_cache, ((i + i_diff) + 1), max_length, max_distance, best_len_2, best_len_code_2, best_dist_2, best_score_2);
                            if ((match_found && (best_score_2[0] >= (best_score[0] + 7.0))))
                            {
                                ++i;
                                ++insert_length;
                                best_len[0]      = best_len_2[0];
                                best_len_code[0] = best_len_code_2[0];
                                best_dist[0]     = best_dist_2[0];
                                best_score[0]    = best_score_2[0];
                                if ((++delayed_backward_references_in_row < 4))
                                {
                                    continue;
                                }
                            }

                            break;
                        }

                        apply_random_heuristics = ((i + (2 * best_len[0])) + random_heuristics_window_size);
                        max_distance            = ((int)(global::System.Math.Min(((double)((i + i_diff))), ((double)(max_backward_limit)))));
                        int distance_code = global::encode.Backward_references.ComputeDistanceCode(best_dist[0], max_distance, quality, dist_cache);
                        if (((best_dist[0] <= max_distance) && (distance_code > 0)))
                        {
                            ((int[])(dist_cache))[3] = ((int)(((int[])(dist_cache))[2]));
                            ((int[])(dist_cache))[2] = ((int)(((int[])(dist_cache))[1]));
                            ((int[])(dist_cache))[1] = ((int)(((int[])(dist_cache))[0]));
                            ((int[])(dist_cache))[0] = best_dist[0];
                        }

                        global::encode.command.Command command = new global::encode.command.Command();
                        command.Command4(insert_length, best_len[0], best_len_code[0], distance_code);
                        commands[commands_off++] = command;
                        num_literals[0]         += insert_length;
                        insert_length            = 0;
                        {
                            int _g1 = 1;
                            int _g  = best_len[0];
                            while ((_g1 < _g))
                            {
                                int j = _g1++;
                                hasher.Store(ringbuffer, (i + j), ((i + i_diff) + j));
                            }
                        }

                        i += best_len[0];
                    }
                    else
                    {
                        ++insert_length;
                        hasher.Store(ringbuffer, i, (i + i_diff));
                        ++i;
                        if ((i > apply_random_heuristics))
                        {
                            if ((i > (apply_random_heuristics + (4 * random_heuristics_window_size))))
                            {
                                int i_jump = ((int)(global::System.Math.Min(((double)((i + 16))), ((double)((i_end - 4))))));
                                while ((i < i_jump))
                                {
                                    hasher.Store(ringbuffer, i, (i + i_diff));
                                    insert_length += 4;
                                    i             += 4;
                                }
                            }
                            else
                            {
                                int i_jump1 = ((int)(global::System.Math.Min(((double)((i + 8))), ((double)((i_end - 3))))));
                                while ((i < i_jump1))
                                {
                                    hasher.Store(ringbuffer, i, (i + i_diff));
                                    insert_length += 2;
                                    i             += 2;
                                }
                            }
                        }
                    }
                }

                insert_length     += (i_end - i);
                last_insert_len[0] = insert_length;
                num_commands[0]   += (commands_off - orig_commands_off);
            }
        }