50 const unsigned char *
buf;
55 #define ADVANCE_BLOCK() \
58 if (pixel_ptr >= width) \
61 row_ptr += stride * 4; \
64 if (total_blocks < 0) \
66 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
75 int row_inc = stride - 4;
80 unsigned short colorA = 0, colorB;
81 unsigned short color4[4];
82 unsigned char index, idx;
83 unsigned short ta, tb;
84 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
93 if (s->
buf[stream_ptr] != 0xe1)
98 chunk_size =
AV_RB32(&s->
buf[stream_ptr]) & 0x00FFFFFF;
102 if (chunk_size != s->
size)
105 chunk_size = s->
size;
111 while (stream_ptr < chunk_size) {
112 opcode = s->
buf[stream_ptr++];
114 n_blocks = (opcode & 0x1f) + 1;
117 if ((opcode & 0x80) == 0) {
118 colorA = (opcode << 8) | (s->
buf[stream_ptr++]);
120 if ((s->
buf[stream_ptr] & 0x80) != 0) {
129 switch (opcode & 0xe0) {
143 block_ptr = row_ptr + pixel_ptr;
144 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
145 for (pixel_x = 0; pixel_x < 4; pixel_x++){
146 pixels[block_ptr] = colorA;
149 block_ptr += row_inc;
170 ta = (colorA >> 10) & 0x1F;
171 tb = (colorB >> 10) & 0x1F;
172 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
173 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
176 ta = (colorA >> 5) & 0x1F;
177 tb = (colorB >> 5) & 0x1F;
178 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
179 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
184 color4[1] |= ((11 * ta + 21 * tb) >> 5);
185 color4[2] |= ((21 * ta + 11 * tb) >> 5);
187 if (s->
size - stream_ptr < n_blocks * 4)
190 block_ptr = row_ptr + pixel_ptr;
191 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
192 index = s->
buf[stream_ptr++];
193 for (pixel_x = 0; pixel_x < 4; pixel_x++){
194 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
195 pixels[block_ptr] = color4[idx];
198 block_ptr += row_inc;
206 if (s->
size - stream_ptr < 16)
208 block_ptr = row_ptr + pixel_ptr;
209 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
210 for (pixel_x = 0; pixel_x < 4; pixel_x++){
212 if ((pixel_y != 0) || (pixel_x !=0)) {
216 pixels[block_ptr] = colorA;
219 block_ptr += row_inc;
227 " Skip remaining %d bytes of chunk data.\n", opcode,
228 chunk_size - stream_ptr);
248 void *
data,
int *got_frame,
252 int buf_size = avpkt->
size;