51 const unsigned char *
buf;
56 #define ADVANCE_BLOCK() \
59 if (pixel_ptr >= width) \
62 row_ptr += stride * 4; \
65 if (total_blocks < 0) \
67 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
76 int row_inc = stride - 4;
81 unsigned short colorA = 0, colorB;
82 unsigned short color4[4];
83 unsigned char index, idx;
84 unsigned short ta,
tb;
85 unsigned short *pixels = (
unsigned short *)s->
frame->
data[0];
94 if (s->
buf[stream_ptr] != 0xe1)
99 chunk_size =
AV_RB32(&s->
buf[stream_ptr]) & 0x00FFFFFF;
103 if (chunk_size != s->
size)
106 chunk_size = s->
size;
112 while (stream_ptr < chunk_size) {
113 opcode = s->
buf[stream_ptr++];
115 n_blocks = (opcode & 0x1f) + 1;
118 if ((opcode & 0x80) == 0) {
119 colorA = (opcode << 8) | (s->
buf[stream_ptr++]);
121 if ((s->
buf[stream_ptr] & 0x80) != 0) {
130 switch (opcode & 0xe0) {
145 block_ptr = row_ptr + pixel_ptr;
146 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
147 for (pixel_x = 0; pixel_x < 4; pixel_x++){
148 pixels[block_ptr] = colorA;
151 block_ptr += row_inc;
171 ta = (colorA >> 10) & 0x1F;
172 tb = (colorB >> 10) & 0x1F;
173 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 10;
174 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 10;
177 ta = (colorA >> 5) & 0x1F;
178 tb = (colorB >> 5) & 0x1F;
179 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 5;
180 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 5;
185 color4[1] |= ((11 * ta + 21 *
tb) >> 5);
186 color4[2] |= ((21 * ta + 11 *
tb) >> 5);
188 if (s->
size - stream_ptr < n_blocks * 4)
192 block_ptr = row_ptr + pixel_ptr;
193 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
194 index = s->
buf[stream_ptr++];
195 for (pixel_x = 0; pixel_x < 4; pixel_x++){
196 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
197 pixels[block_ptr] = color4[idx];
200 block_ptr += row_inc;
207 if (s->
size - stream_ptr < 30)
210 block_ptr = row_ptr + pixel_ptr;
211 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
212 for (pixel_x = 0; pixel_x < 4; pixel_x++){
214 if ((pixel_y != 0) || (pixel_x !=0)) {
218 pixels[block_ptr] = colorA;
221 block_ptr += row_inc;
228 " Skip remaining %d bytes of chunk data.\n", opcode,
229 chunk_size - stream_ptr);
250 void *
data,
int *got_frame,
254 int buf_size = avpkt->
size;