49 const unsigned char *
buf;
54 #define ADVANCE_BLOCK() \
57 if (pixel_ptr >= width) \
60 row_ptr += stride * 4; \
63 if (total_blocks < 0) \
65 av_log(s->avctx, AV_LOG_ERROR, "warning: block counter just went negative (this should not happen)\n"); \
74 int row_inc = stride - 4;
79 unsigned short colorA = 0, colorB;
80 unsigned short color4[4];
81 unsigned char index, idx;
82 unsigned short ta, tb;
83 unsigned short *pixels = (
unsigned short *)s->
frame.
data[0];
92 if (s->
buf[stream_ptr] != 0xe1)
97 chunk_size =
AV_RB32(&s->
buf[stream_ptr]) & 0x00FFFFFF;
101 if (chunk_size != s->
size)
104 chunk_size = s->
size;
110 while (stream_ptr < chunk_size) {
111 opcode = s->
buf[stream_ptr++];
113 n_blocks = (opcode & 0x1f) + 1;
116 if ((opcode & 0x80) == 0) {
117 colorA = (opcode << 8) | (s->
buf[stream_ptr++]);
119 if ((s->
buf[stream_ptr] & 0x80) != 0) {
128 switch (opcode & 0xe0) {
142 block_ptr = row_ptr + pixel_ptr;
143 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
144 for (pixel_x = 0; pixel_x < 4; pixel_x++){
145 pixels[block_ptr] = colorA;
148 block_ptr += row_inc;
169 ta = (colorA >> 10) & 0x1F;
170 tb = (colorB >> 10) & 0x1F;
171 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10;
172 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10;
175 ta = (colorA >> 5) & 0x1F;
176 tb = (colorB >> 5) & 0x1F;
177 color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5;
178 color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5;
183 color4[1] |= ((11 * ta + 21 * tb) >> 5);
184 color4[2] |= ((21 * ta + 11 * tb) >> 5);
186 if (s->
size - stream_ptr < n_blocks * 4)
189 block_ptr = row_ptr + pixel_ptr;
190 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
191 index = s->
buf[stream_ptr++];
192 for (pixel_x = 0; pixel_x < 4; pixel_x++){
193 idx = (index >> (2 * (3 - pixel_x))) & 0x03;
194 pixels[block_ptr] = color4[idx];
197 block_ptr += row_inc;
205 if (s->
size - stream_ptr < 30)
207 block_ptr = row_ptr + pixel_ptr;
208 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
209 for (pixel_x = 0; pixel_x < 4; pixel_x++){
211 if ((pixel_y != 0) || (pixel_x !=0)) {
215 pixels[block_ptr] = colorA;
218 block_ptr += row_inc;
226 " Skip remaining %d bytes of chunk data.\n", opcode,
227 chunk_size - stream_ptr);
246 void *
data,
int *data_size,
249 const uint8_t *buf = avpkt->
data;
250 int buf_size = avpkt->
size;