+ spec->chosen_matches = &ctx->chosen_matches[spec->window_pos];
+ next_chosen_match = spec->chosen_matches;
+
+ while (window_ptr != window_end) {
+ raw_match = lzx_get_near_optimal_match(ctx);
+
+ LZX_ASSERT(!(raw_match.len == LZX_MIN_MATCH_LEN &&
+ raw_match.offset == ctx->max_window_size -
+ LZX_MIN_MATCH_LEN));
+ if (raw_match.len >= LZX_MIN_MATCH_LEN) {
+ lzx_match.data = lzx_tally_match(raw_match.len,
+ raw_match.offset,
+ &freqs, &ctx->queue);
+ window_ptr += raw_match.len;
+ } else {
+ lzx_match.data = lzx_tally_literal(*window_ptr, &freqs);
+ window_ptr += 1;
+ }
+ *next_chosen_match++ = lzx_match;
+ }
+ spec->num_chosen_matches = next_chosen_match - spec->chosen_matches;
+ lzx_make_huffman_codes(&freqs, &spec->codes, ctx->num_main_syms);