1 /*
2 * Interplay C93 video decoder
3 * Copyright (c) 2007 Anssi Hannula <anssi.hannula@gmail.com>
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
26
31
43
46
47 #define C93_HAS_PALETTE 0x01
48 #define C93_FIRST_FRAME 0x02
49
51 {
53
56
57 return 0;
58 }
59
61 {
64
67 if (!
s->pictures[0] || !
s->pictures[1])
69
70 return 0;
71 }
72
75 {
81
83 /* silently ignoring predictive blocks in first frame */
84 return 0;
85 }
86
91 }
92
97 }
98 }
99
102 }
103
104 return 0;
105 }
106
108 int height,
int bpp, uint8_t cols[4], uint8_t grps[4], uint32_t col)
109 {
110 int x, y;
111 for (y = 0; y <
height; y++) {
112 if (grps)
113 cols[0] = grps[3 * (y >> 1)];
114 for (x = 0; x <
width; x++) {
115 if (grps)
116 cols[1]= grps[(x >> 1) + 1];
117 out[x + y*
stride] = cols[col & ((1 << bpp) - 1)];
118 col >>= bpp;
119 }
120 }
121 }
122
125 {
126 const uint8_t *buf = avpkt->
data;
127 int buf_size = avpkt->
size;
134
137
139
142
144
146 b = bytestream2_get_byte(&gb);
150 } else {
153 }
154
155 for (y = 0; y <
HEIGHT; y += 8) {
157 for (x = 0; x <
WIDTH; x += 8) {
160 uint8_t cols[4], grps[4];
162
163 if (!bt)
164 bt = bytestream2_get_byte(&gb);
165
166 block_type= bt & 0x0F;
167 switch (block_type) {
169 offset = bytestream2_get_le16(&gb);
172 break;
173
177 for (j = 0; j < 8; j += 4) {
178 for (
i = 0;
i < 8;
i += 4) {
179 int offset = bytestream2_get_le16(&gb);
186 }
190 }
191 }
192 break;
193
196 for (
i = 0;
i < 8;
i++) {
198 NULL, bytestream2_get_byte(&gb));
199 }
200
201 break;
202
206 for (j = 0; j < 8; j += 4) {
207 for (
i = 0;
i < 8;
i += 4) {
211 1, cols,
NULL, bytestream2_get_le16(&gb));
215 2, cols,
NULL, bytestream2_get_le32(&gb));
216 } else {
219 1, cols, grps, bytestream2_get_le16(&gb));
220 }
221 }
222 }
223 break;
224
226 break;
227
229 for (j = 0; j < 8; j++)
231 break;
232
233 default:
235 block_type, x, y);
237 }
238 bt >>= 4;
240 }
241 }
242
244 uint32_t *palette = (uint32_t *) newpic->
data[1];
245 for (
i = 0;
i < 256;
i++) {
246 palette[
i] = 0xFF
U << 24 | bytestream2_get_be24(&gb);
247 }
249 } else {
251 memcpy(newpic->
data[1], oldpic->
data[1], 256 * 4);
252 }
253
256 *got_frame = 1;
257
258 return buf_size;
259 }
260
272 };