26 #define BITSTREAM_READER_LE
63 uint8_t *dst,
const int dst_size)
68 const uint8_t *dst_end = dst + dst_size;
72 tree_size = bytestream2_get_byte(&s->
gb);
73 eof = bytestream2_get_byte(&s->
gb);
74 tree_root = eof + tree_size;
78 bits = bytestream2_get_byte(&s->
gb);
81 int bit = !!(bits &
mask);
84 node = bytestream2_get_byte(&tree);
96 bits = bytestream2_get_byteu(&s->
gb);
105 uint8_t *dest,
const int dest_len)
109 uint8_t *orig_dest = dest;
110 const uint8_t *dest_end = dest + dest_len;
112 while (dest < dest_end) {
116 opcode = bytestream2_get_byteu(&s->
gb);
120 if ((opcode & 0x80) == 0) {
122 back = ((opcode & 0x60) << 3) + bytestream2_get_byte(&s->
gb) + 1;
123 size2 = ((opcode & 0x1c) >> 2) + 3;
124 }
else if ((opcode & 0x40) == 0) {
125 size = bytestream2_peek_byte(&s->
gb) >> 6;
126 back = (bytestream2_get_be16(&s->
gb) & 0x3fff) + 1;
127 size2 = (opcode & 0x3f) + 4;
130 back = ((opcode & 0x10) << 12) + bytestream2_get_be16(&s->
gb) + 1;
131 size2 = ((opcode & 0x0c) << 6) + bytestream2_get_byte(&s->
gb) + 5;
132 if (size + size2 > dest_end - dest)
135 if (dest + size + size2 > dest_end ||
136 dest - orig_dest + size < back)
143 int finish = opcode >= 0xfc;
145 size = finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
146 if (dest_end - dest < size)
154 return dest - orig_dest;
163 const uint8_t *src, *src_end;
164 const uint8_t *table;
165 int mode, offset, dec_size, table_size;
174 mode = bytestream2_get_le16(&s->
gb);
176 table_size = bytestream2_get_le16(&s->
gb);
177 offset = table_size * 2;
196 src_end = src + dec_size;
198 for (j = 0; j < avctx->
height >> 1; j++) {
199 for (i = 0; i < avctx->
width >> 1; i++) {
201 if (val && val < table_size) {
202 val =
AV_RL16(table + (val << 1));
203 uval = (val >> 3) & 0xF8;
204 vval = (val >> 8) & 0xF8;
205 U[i] = uval | (uval >> 5);
206 V[i] = vval | (vval >> 5);
218 for (j = 0; j < avctx->
height >> 2; j++) {
219 for (i = 0; i < avctx->
width >> 1; i += 2) {
221 if (val && val < table_size) {
222 val =
AV_RL16(table + (val << 1));
223 uval = (val >> 3) & 0xF8;
224 vval = (val >> 8) & 0xF8;
225 U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
226 V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
243 unsigned chroma_off, corr_off;
248 chroma_off = bytestream2_get_le32(&s->
gb);
249 corr_off = bytestream2_get_le32(&s->
gb);
268 for (j = 1; j < avctx->
width - 1; j += 2) {
269 cur = (last + *src++) & 0x1F;
270 ybuf[j] = last + cur;
271 ybuf[j+1] = cur << 1;
276 ybuf += avctx->
width;
278 for (i = 1; i < avctx->
height; i++) {
279 last = ((prev_buf[0] >> 1) + *src++) & 0x1F;
281 for (j = 1; j < avctx->
width - 1; j += 2) {
282 cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;
283 ybuf[j] = last + cur;
284 ybuf[j+1] = cur << 1;
289 ybuf += avctx->
width;
293 int corr_end, dec_size;
296 if (chroma_off > corr_off)
297 corr_end = chroma_off;
302 for (i = 0; i < dec_size; i++)
308 for (j = 0; j < avctx->
height; j++) {
309 for (i = 0; i < avctx->
width; i++)
310 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
338 for (i = 0; i < avctx->
height; i++) {
339 last = (ybuf[0] + (*src++ << 1)) & 0x3F;
341 for (j = 1; j < avctx->
width - 1; j += 2) {
342 cur = (ybuf[j + 1] + (*src++ << 1)) & 0x3F;
343 ybuf[j] = (last + cur) >> 1;
348 ybuf += avctx->
width;
353 for (j = 0; j < avctx->
height; j++) {
354 for (i = 0; i < avctx->
width; i++)
355 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
364 void *
data,
int *data_size,
381 ftype = bytestream2_get_le32(&s->
gb);