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;
99 "MOV chunk size %d != encoded chunk size %d\n",
109 uint8_t opcode = bytestream2_get_byte(&s->
gb);
111 int n_blocks = (opcode & 0x1f) + 1;
114 if ((opcode & 0x80) == 0) {
115 colorA = (opcode << 8) | bytestream2_get_byte(&s->
gb);
117 if ((bytestream2_peek_byte(&s->
gb) & 0x80) != 0) {
126 n_blocks =
FFMIN(n_blocks, total_blocks);
128 switch (opcode & 0xe0) {
139 colorA = bytestream2_get_be16(&s->
gb);
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;
155 colorA = bytestream2_get_be16(&s->
gb);
157 colorB = bytestream2_get_be16(&s->
gb);
166 ta = (colorA >> 10) & 0x1F;
167 tb = (colorB >> 10) & 0x1F;
168 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 10;
169 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 10;
172 ta = (colorA >> 5) & 0x1F;
173 tb = (colorB >> 5) & 0x1F;
174 color4[1] |= ((11 * ta + 21 *
tb) >> 5) << 5;
175 color4[2] |= ((21 * ta + 11 *
tb) >> 5) << 5;
180 color4[1] |= ((11 * ta + 21 *
tb) >> 5);
181 color4[2] |= ((21 * ta + 11 *
tb) >> 5);
187 block_ptr = row_ptr + pixel_ptr;
188 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
190 for (pixel_x = 0; pixel_x < 4; pixel_x++){
191 uint8_t idx = (index >> (2 * (3 - pixel_x))) & 0x03;
192 pixels[block_ptr] = color4[idx];
195 block_ptr += row_inc;
205 block_ptr = row_ptr + pixel_ptr;
206 for (pixel_y = 0; pixel_y < 4; pixel_y++) {
207 for (pixel_x = 0; pixel_x < 4; pixel_x++){
209 if ((pixel_y != 0) || (pixel_x != 0))
210 colorA = bytestream2_get_be16u(&s->
gb);
211 pixels[block_ptr] = colorA;
214 block_ptr += row_inc;
221 " Skip remaining %d bytes of chunk data.\n", opcode,
243 void *
data,
int *got_frame,