blob: 4637ddd1e9b10820129cb91d6ac1fb68db083e3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright (C) 2004 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_
#define DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_
#include "entropy_encoder_model_kernel_abstract.h"
#include "../algs.h"
#include "../assert.h"
#include <iostream>
namespace dlib
{
template <
typename eem_base
>
class entropy_encoder_model_kernel_c : public eem_base
{
const unsigned long alphabet_size;
typedef typename eem_base::entropy_encoder_type entropy_encoder;
public:
entropy_encoder_model_kernel_c (
entropy_encoder& coder
) : eem_base(coder), alphabet_size(eem_base::get_alphabet_size()) {}
void encode (
unsigned long symbol
);
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template <
typename eem_base
>
void entropy_encoder_model_kernel_c<eem_base>::
encode (
unsigned long symbol
)
{
// make sure requires clause is not broken
DLIB_CASSERT(symbol < alphabet_size,
"\tvoid entropy_encoder_model::encode()"
<< "\n\tthe symbol must be in the range 0 to alphabet_size-1"
<< "\n\talphabet_size: " << alphabet_size
<< "\n\tsymbol: " << symbol
<< "\n\tthis: " << this
);
// call the real function
eem_base::encode(symbol);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_
|