1 /*
2 * AVS video decoder.
3 * Copyright (c) 2006 Aurelien Jacobs <aurel@gnuage.org>
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
25
26
30
37
44
45
46 static int
49 {
52 int buf_size = avpkt->
size;
58 int i, j, x,
y,
stride,
ret, vect_w = 3, vect_h = 3;
62
67
70
71 if (buf_end - buf < 4)
73 sub_type = buf[0];
74 type = buf[1];
75 buf += 4;
76
78 int first, last;
79 uint32_t *pal = (uint32_t *) p->
data[1];
80
82 last = first +
AV_RL16(buf + 2);
83 if (first >= 256 || last > 256 || buf_end - buf < 4 + 4 + 3 * (last - first))
85 buf += 4;
86 for (i=first; i<last; i++, buf+=3) {
87 pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
88 pal[i] |= 0xFFU << 24 | (pal[i] >> 6) & 0x30303;
89 }
90
91 sub_type = buf[0];
92 type = buf[1];
93 buf += 4;
94 }
95
98
99 switch (sub_type) {
104 vect_w = 3;
105 vect_h = 3;
106 break;
107
109 vect_w = 2;
110 vect_h = 2;
111 break;
112
114 vect_w = 2;
115 vect_h = 3;
116 break;
117
118 default:
120 }
121
122 if (buf_end - buf < 256 * vect_w * vect_h)
124 table = buf + (256 * vect_w * vect_h);
126 int map_size = ((318 / vect_w + 7) / 8) * (198 / vect_h);
127 if (buf_end - table < map_size)
130 table += map_size;
131 }
132
133 for (y=0; y<198; y+=vect_h) {
134 for (x=0; x<318; x+=vect_w) {
136 if (buf_end - table < 1)
138 vect = &buf[*table++ * (vect_w * vect_h)];
139 for (j=0; j<vect_w; j++) {
140 out[(y + 0) * stride + x + j] = vect[(0 * vect_w) + j];
141 out[(y + 1) * stride + x + j] = vect[(1 * vect_w) + j];
142 if (vect_h == 3)
143 out[(y + 2) * stride + x + j] =
144 vect[(2 * vect_w) + j];
145 }
146 }
147 }
150 }
151
154 *got_frame = 1;
155
156 return buf_size;
157 }
158
160 {
162
166
169
170 return 0;
171 }
172
174 {
177 return 0;
178 }
179
180
191 };