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
30
36
38 {
39 for (;;) {
40 if (c->
high >= 0x8000) {
41 if (c->
low < 0x8000) {
42 if (c->
low >= 0x4000 && c->
high < 0xC000) {
46 } else {
47 return;
48 }
49 } else {
53 }
54 }
60 }
61 }
62
64
66 {
67 int range = c->high - c->low + 1;
68 int val = (((c->value - c->low + 1) << bits) - 1) / range;
69 int prob = range *
val;
70
71 c->high = ((prob + range) >> bits) + c->low - 1;
72 c->low += prob >>
bits;
73
75
77 }
78
80 {
81 int range = c->
high - c->
low + 1;
82 int val = ((c->
value - c->
low + 1) * mod_val - 1) / range;
83 int prob = range *
val;
84
85 c->
high = (prob + range) / mod_val + c->
low - 1;
86 c->
low += prob / mod_val;
87
89
91 }
92
94 {
95 int range = c->
high - c->
low + 1;
96 int val = ((c->
value - c->
low + 1) * probs[0] - 1) / range;
97 int sym = 1;
98
99 while (probs[sym] > val)
100 sym++;
101
102 c->
high = range * probs[sym - 1] / probs[0] + c->
low - 1;
103 c->
low += range * probs[sym] / probs[0];
104
105 return sym;
106 }
107
109
111 {
112 c->low = 0;
113 c->high = 0xFFFF;
115 c->gbc.gb = gb;
116 c->get_model_sym = arith_get_model_sym;
118 }
119
121 {
122 int i, ncol,
r,
g,
b;
124
126 return 0;
127
129 for (i = 0; i < ncol; i++) {
133 *pal++ = (0xFF
U << 24) | (r << 16) | (g << 8) | b;
134 }
135
136 return !!ncol;
137 }
138
141 {
146 int pal_changed = 0;
148
151
153
156
159 c->
keyframe = !arith_get_bit(&acoder);
166 } else {
171 }
178
181
182 *got_frame = 1;
183
184 /* always report that the buffer was completely consumed */
186 }
187
189 {
192
194
198
200 if (ret < 0)
202
204
206 }
207
209 {
211
214
215 return 0;
216 }
217
228 };