50 unsigned int w, h,
depth, type, maptype, maplength,
stride, x, y,
len, alen;
130 if (buf_end - buf < maplength)
133 if (depth > 8 && maplength) {
134 av_log(avctx,
AV_LOG_WARNING,
"useless colormap found or file is corrupted, trying to recover\n");
136 }
else if (maplength) {
137 unsigned int len = maplength / 3;
139 if (maplength % 3 || maplength > 768) {
145 for (x = 0; x <
len; x++, ptr += 4)
146 *(uint32_t *)ptr = (0xFF
U<<24) + (buf[x]<<16) + (buf[len+x]<<8) + buf[len+len+x];
151 if (maplength && depth < 8) {
155 stride = (w + 15 >> 3) * depth;
162 len = (depth * w + 7) >> 3;
163 alen = len + (len & 1);
170 while (ptr != end && buf < buf_end) {
172 if (buf_end - buf < 1)
192 for (y = 0; y < h; y++) {
193 if (buf_end - buf < len)
195 memcpy(ptr, buf, len);
203 for (y=0; y<h; y++) {
204 for (x = 0; x < (w + 7 >> 3) * depth; x++) {
206 ptr[8*x] = ptr2[x] >> 7;
207 ptr[8*x+1] = ptr2[x] >> 6 & 1;
208 ptr[8*x+2] = ptr2[x] >> 5 & 1;
209 ptr[8*x+3] = ptr2[x] >> 4 & 1;
210 ptr[8*x+4] = ptr2[x] >> 3 & 1;
211 ptr[8*x+5] = ptr2[x] >> 2 & 1;
212 ptr[8*x+6] = ptr2[x] >> 1 & 1;
213 ptr[8*x+7] = ptr2[x] & 1;
215 ptr[2*x] = ptr2[x] >> 4;
216 ptr[2*x+1] = ptr2[x] & 0xF;
220 ptr2 += (w + 15 >> 3) * depth;
228 return buf - bufstart;