tudocomp
– The TU Dortmund Compression Framework
RoundContextImpl.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace tdc {namespace esp {
6  template<typename Source, typename F>
7  inline size_t split_where(const Source& src, size_t i, bool max, F f) {
8  for(size_t j = i; j < src.size() - 1; j++) {
9  if (!f(src[j], src[j + 1])) {
10  return j + (max ? 1 : 0);
11  }
12  }
13  return src.size();
14  }
15 
16  template<typename round_view_t>
18  auto& ctx = *this;
19 
20  // Split up the input into metablocks of type 2 or 1/3
21  for (size_t i = 0; i < src.size();) {
22  size_t j;
23 
24  // Scan for non-repeating
25  // NB: First to not find a size-1 repeating prefix
26  j = split_where(src, i, !ctx.behavior_metablocks_maximimze_repeating,
27  [](size_t a, size_t b){ return a != b; });
28  if(j != i) {
29  auto s = src.slice(i, j);
30 
31  auto mb = debug.metablock();
32  mb.init(2, s, i);
33 
34  MetablockContext<round_view_t> mbctx(*this, mb);
35 
36  mbctx.eager_mb2(s);
37  i = j;
38  }
39 
40  // Scan for repeating
41  j = split_where(src, i, ctx.behavior_metablocks_maximimze_repeating,
42  [](size_t a, size_t b){ return a == b; });
43  if(j != i) {
44  auto s = src.slice(i, j);
45 
46  auto mb = debug.metablock();
47  mb.init(1, s, i);
48 
49  MetablockContext<round_view_t> mbctx(*this, mb);
50 
51  mbctx.eager_mb13(s, 1);
52  i = j;
53  }
54  }
55  }
56 }}
void split(round_view_t)
Contains the text compression and encoding framework.
Definition: namespaces.hpp:11
void eager_mb2(const Source &src)
Definition: meta_blocks.hpp:65
size_t split_where(const Source &src, size_t i, bool max, F f)
len_compact_t src
Definition: LZSSFactors.hpp:38
void eager_mb13(const Source &src, size_t t)
Definition: meta_blocks.hpp:34