1 /*
2 * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
3 * Copyright (c) 2012 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * Microsoft Screen 1 (aka Windows Media Video V7 Screen) decoder
25 */
26
29
35
37 {
38 for (;;) {
39 if (c->
high >= 0x8000) {
40 if (c->
low < 0x8000) {
41 if (c->
low >= 0x4000 && c->
high < 0xC000) {
45 } else {
46 return;
47 }
48 } else {
52 }
53 }
59 }
60 }
61
63
65 {
66 int range = c->high - c->low + 1;
67 int val = (((c->value - c->low + 1) << bits) - 1) / range;
68 int prob = range * val;
69
70 c->high = ((prob + range) >> bits) + c->low - 1;
71 c->low += prob >>
bits;
72
74
75 return val;
76 }
77
79 {
80 int range = c->
high - c->
low + 1;
81 int val = ((c->
value - c->
low + 1) * mod_val - 1) / range;
82 int prob = range * val;
83
84 c->
high = (prob + range) / mod_val + c->
low - 1;
85 c->
low += prob / mod_val;
86
88
89 return val;
90 }
91
93 {
94 int range = c->
high - c->
low + 1;
95 int val = ((c->
value - c->
low + 1) * probs[0] - 1) / range;
96 int sym = 1;
97
98 while (probs[sym] > val)
99 sym++;
100
101 c->
high = range * probs[sym - 1] / probs[0] + c->
low - 1;
102 c->
low += range * probs[sym] / probs[0];
103
104 return sym;
105 }
106
108
110 {
111 c->low = 0;
112 c->high = 0xFFFF;
114 c->gbc.gb = gb;
115 c->get_model_sym = arith_get_model_sym;
117 }
118
120 {
121 int i, ncol,
r,
g,
b;
123
125 return 0;
126
128 for (i = 0; i < ncol; i++) {
132 *pal++ = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
133 }
134
135 return !!ncol;
136 }
137
140 {
142 int buf_size = avpkt->
size;
147 int pal_changed = 0;
148 int ret;
149
152
158 return ret;
159 }
160
163 c->
keyframe = !arith_get_bit(&acoder);
170 } else {
175 }
182
183 *got_frame = 1;
185
186 /* always report that the buffer was completely consumed */
187 return buf_size;
188 }
189
191 {
193 int ret;
194
197
199
201
202 return ret;
203 }
204
206 {
208
212
213 return 0;
214 }
215
226 };