1 /*
2 * Copyright (c) 2012 Konstantin Shishkov
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * Common header for Microsoft Screen 1 and 2
24 */
25
26 #ifndef AVCODEC_MSS12_H
27 #define AVCODEC_MSS12_H
28
33
34 #define MODEL_MIN_SYMS 2
35 #define MODEL_MAX_SYMS 256
36 #define THRESH_ADAPTIVE -1
38 #define THRESH_HIGH 50
39
47
50 union {
57
65
67
74
93
101
102 #define ARITH_GET_BIT(VERSION) \
103 static int arith ## VERSION ## _get_bit(ArithCoder *c) \
104 { \
105 int range = c->high - c->low + 1; \
106 int bit = 2 * c->value - c->low >= c->high; \
107 \
108 if (bit) \
109 c->low += range >> 1; \
110 else \
111 c->high = c->low + (range >> 1) - 1; \
112 \
113 arith ## VERSION ## _normalise(c); \
114 \
115 return bit; \
116 }
117
118 #define ARITH_GET_MODEL_SYM(VERSION) \
119 static int arith ## VERSION ## _get_model_sym(ArithCoder *c, Model *m) \
120 { \
121 int idx, val; \
122 \
123 idx = arith ## VERSION ## _get_prob(c, m->cum_prob); \
124 \
125 val = m->idx2sym[idx]; \
126 ff_mss12_model_update(m, idx); \
127 \
128 arith ## VERSION ## _normalise(c); \
129 \
130 return val; \
131 }
132
133 #endif /* AVCODEC_MSS12_H */