35 unsigned int w, h,
depth,
type, maptype, maplength,
stride, x,
y,
len, alen;
108 if (buf_end - buf < maplength)
111 if (depth > 8 && maplength) {
112 av_log(avctx,
AV_LOG_WARNING,
"useless colormap found or file is corrupted, trying to recover\n");
114 }
else if (maplength) {
115 unsigned int len = maplength / 3;
117 if (maplength % 3 || maplength > 768) {
123 for (x = 0; x <
len; x++, ptr += 4)
124 *(uint32_t *)ptr = (0xFF
U<<24) + (buf[x]<<16) + (buf[len+x]<<8) + buf[len+len+x];
129 if (maplength && depth < 8) {
133 stride = (w + 15 >> 3) * depth;
140 len = (depth * w + 7) >> 3;
141 alen = len + (len & 1);
148 while (ptr != end && buf < buf_end) {
150 if (buf_end - buf < 1)
170 for (y = 0; y < h; y++) {
171 if (buf_end - buf < len)
173 memcpy(ptr, buf, len);
181 for (y=0; y<h; y++) {
182 for (x = 0; x < (w + 7 >> 3) * depth; x++) {
184 ptr[8*x] = ptr2[x] >> 7;
185 ptr[8*x+1] = ptr2[x] >> 6 & 1;
186 ptr[8*x+2] = ptr2[x] >> 5 & 1;
187 ptr[8*x+3] = ptr2[x] >> 4 & 1;
188 ptr[8*x+4] = ptr2[x] >> 3 & 1;
189 ptr[8*x+5] = ptr2[x] >> 2 & 1;
190 ptr[8*x+6] = ptr2[x] >> 1 & 1;
191 ptr[8*x+7] = ptr2[x] & 1;
193 ptr[2*x] = ptr2[x] >> 4;
194 ptr[2*x+1] = ptr2[x] & 0xF;
198 ptr2 += (w + 15 >> 3) * depth;
205 return buf - bufstart;