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;
77 uint16_t colorA = 0, colorB;
80 uint16_t *pixels = (uint16_t *)s->
frame->
data[0];
89 if (bytestream2_peek_byte(&s->
gb) != 0xe1)
91 bytestream2_peek_byte(&s->
gb));
94 chunk_size = bytestream2_get_be32(&s->
gb) & 0x00FFFFFF;
105 uint8_t opcode = bytestream2_get_byte(&s->
gb);
107 int n_blocks = (opcode & 0x1f) + 1;
110 if ((opcode & 0x80) == 0) {
111 colorA = (opcode << 8) | bytestream2_get_byte(&s->
gb);
113 if ((bytestream2_peek_byte(&s->
gb) & 0x80) != 0) {
122 n_blocks =
FFMIN(n_blocks, total_blocks);
124 switch (opcode & 0xe0) {
135 colorA = bytestream2_get_be16(&s->
gb);
138 block_ptr = row_ptr + pixel_ptr;
139 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
140 for (pixel_x = 0; pixel_x < 4; pixel_x++){
141 pixels[block_ptr] = colorA;
144 block_ptr += row_inc;
151 colorA = bytestream2_get_be16(&s->
gb);
153 colorB = bytestream2_get_be16(&s->
gb);
162 ta = (colorA >> 10) & 0x1F;
163 tb = (colorB >> 10) & 0x1F;
164 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 10;
165 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 10;
168 ta = (colorA >> 5) & 0x1F;
169 tb = (colorB >> 5) & 0x1F;
170 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 5;
171 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 5;
176 color4[1] |= ((11 * ta + 21 *
tb) >> 5);
177 color4[2] |= ((21 * ta + 11 *
tb) >> 5);
183 block_ptr = row_ptr + pixel_ptr;
184 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
186 for (pixel_x = 0; pixel_x < 4; pixel_x++){
187 uint8_t idx = (index >> (2 * (3 - pixel_x))) & 0x03;
188 pixels[block_ptr] = color4[idx];
191 block_ptr += row_inc;
201 block_ptr = row_ptr + pixel_ptr;
202 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
203 for (pixel_x = 0; pixel_x < 4; pixel_x++){
205 if ((pixel_y != 0) || (pixel_x != 0))
206 colorA = bytestream2_get_be16u(&s->
gb);
207 pixels[block_ptr] = colorA;
210 block_ptr += row_inc;
217 " Skip remaining %d bytes of chunk data.\n", opcode,
239 void *
data,
int *got_frame,