25 #define BITSTREAM_READER_LE
42 if (src_size < avctx->
width * avctx->
height * (int64_t)bpp) {
52 for (h = 0; h < avctx->
height; h++) {
53 memcpy(dst, src, avctx->
width * bpp);
54 src += avctx->
width * bpp;
83 for (h = 0; h < avctx->
height; h += 4) {
84 for (w = 0; w < avctx->
width; w += 4) {
89 U[w >> 2] = src[16] + 0x80;
90 V[w >> 2] = src[17] + 0x80;
124 for (h = 0; h < avctx->
height; h += 2) {
125 for (w = 0; w < avctx->
width; w += 2) {
128 U[w >> 1] = src[4] + 0x80;
129 V[w >> 1] = src[5] + 0x80;
160 for (h = 0; h < avctx->
height; h++) {
161 for (w = 0; w < avctx->
width; w++) {
163 U[w] = *src++ ^ 0x80;
164 V[w] = *src++ ^ 0x80;
174 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
185 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
188 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
203 memmove(lru + 1, lru,
sizeof(*lru) * (6 - 1));
206 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
222 memcpy(lru[2], def_lru_555, 8 *
sizeof(*
def_lru));
224 for (y = 0; y <
height; y++) {
225 for (x = 0; x <
width; x++) {
229 dst[x * 3 + 0] = (r << 3) | (r >> 2);
230 dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
231 dst[x * 3 + 2] = (b << 3) | (b >> 2);
245 int nslices, slice, slice_height;
246 uint32_t off, slice_size;
251 nslices = bytestream2_get_le16(&gb);
252 off =
FFALIGN(nslices * 4 + 2, 16);
253 if (src_size < off) {
258 if (!nslices || avctx->
height % nslices) {
264 slice_height = avctx->
height / nslices;
270 for (slice = 0; slice < nslices; slice++) {
271 slice_size = bytestream2_get_le32(&gb);
272 if (slice_size > src_size - off) {
274 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
275 slice_size, src_size - off);
278 if (slice_size <= 16) {
283 if (
AV_RL32(src + off) != slice_size - 16) {
285 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
286 AV_RL32(src + off), slice_size - 16);
292 dst += pic->
linesize[0] * slice_height;
305 for (i = 0; i < 3; i++)
308 for (y = 0; y <
height; y++) {
309 for (x = 0; x <
width; x++) {
326 int nslices, slice, slice_height;
327 uint32_t off, slice_size;
332 nslices = bytestream2_get_le16(&gb);
333 off =
FFALIGN(nslices * 4 + 2, 16);
334 if (src_size < off) {
339 if (!nslices || avctx->
height % nslices) {
345 slice_height = avctx->
height / nslices;
351 for (slice = 0; slice < nslices; slice++) {
352 slice_size = bytestream2_get_le32(&gb);
353 if (slice_size > src_size - off) {
355 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
356 slice_size, src_size - off);
359 if (slice_size <= 16) {
365 if (
AV_RL32(src + off) != slice_size - 16) {
367 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
368 AV_RL32(src + off), slice_size - 16);
374 dst += pic->
linesize[0] * slice_height;
383 int ystride,
int ustride,
int vstride)
388 for (i = 0; i < 3; i++)
391 for (y = 0; y <
height; y += 4) {
392 for (x = 0; x <
width; x += 4) {
393 for (j = 0; j < 4; j++)
394 for (i = 0; i < 4; i++)
395 Y[x + i + j * ystride] =
decode_sym(gb, lru[0]);
413 int nslices, slice, slice_height;
415 uint32_t off, slice_size;
420 nslices = bytestream2_get_le16(&gb);
421 off =
FFALIGN(nslices * 4 + 2, 16);
422 if (src_size < off) {
447 for (slice = 0; slice < nslices; slice++) {
448 slice_size = bytestream2_get_le32(&gb);
449 next_y = ((slice + 1) * avctx->
height) / nslices;
450 slice_height = (next_y & ~3) - (cur_y & ~3);
451 if (slice_size > src_size - off) {
453 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
454 slice_size, src_size - off);
457 if (slice_size <= 16) {
462 if (
AV_RL32(src + off) != slice_size - 16) {
464 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
465 AV_RL32(src + off), slice_size - 16);
472 Y += pic->
linesize[0] * slice_height;
473 U += pic->
linesize[1] * (slice_height >> 2);
474 V += pic->
linesize[2] * (slice_height >> 2);
484 int ystride,
int ustride,
int vstride)
489 for (i = 0; i < 3; i++)
492 for (y = 0; y <
height; y+=2) {
493 for (x = 0; x <
width; x += 2) {
494 Y[x + 0 + 0 * ystride] =
decode_sym(gb, lru[0]);
495 Y[x + 1 + 0 * ystride] =
decode_sym(gb, lru[0]);
496 Y[x + 0 + 1 * ystride] =
decode_sym(gb, lru[0]);
497 Y[x + 1 + 1 * ystride] =
decode_sym(gb, lru[0]);
515 int nslices, slice, slice_height;
517 uint32_t off, slice_size;
522 nslices = bytestream2_get_le16(&gb);
523 off =
FFALIGN(nslices * 4 + 2, 16);
524 if (src_size < off) {
549 for (slice = 0; slice < nslices; slice++) {
550 slice_size = bytestream2_get_le32(&gb);
551 next_y = ((slice + 1) * avctx->
height) / nslices;
552 slice_height = (next_y & ~1) - (cur_y & ~1);
553 if (slice_size > src_size - off) {
555 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
556 slice_size, src_size - off);
559 if (slice_size <= 16) {
564 if (
AV_RL32(src + off) != slice_size - 16) {
566 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
567 AV_RL32(src + off), slice_size - 16);
574 Y += pic->
linesize[0] * slice_height;
575 U += pic->
linesize[1] * (slice_height >> 1);
576 V += pic->
linesize[2] * (slice_height >> 1);
586 int ystride,
int ustride,
int vstride)
591 for (i = 0; i < 3; i++)
594 for (y = 0; y <
height; y++) {
595 for (x = 0; x <
width; x++) {
614 int nslices, slice, slice_height;
615 uint32_t off, slice_size;
620 nslices = bytestream2_get_le16(&gb);
621 off =
FFALIGN(nslices * 4 + 2, 16);
622 if (src_size < off) {
627 if (!nslices || avctx->
height % nslices) {
633 slice_height = avctx->
height / nslices;
643 for (slice = 0; slice < nslices; slice++) {
644 slice_size = bytestream2_get_le32(&gb);
645 if (slice_size > src_size - off) {
647 "invalid slice size %"PRIu32
" (only %"PRIu32
" bytes left)\n",
648 slice_size, src_size - off);
651 if (slice_size <= 16) {
656 if (
AV_RL32(src + off) != slice_size - 16) {
658 "Slice sizes mismatch: got %"PRIu32
" instead of %"PRIu32
"\n",
659 AV_RL32(src + off), slice_size - 16);
666 Y += pic->
linesize[0] * slice_height;
667 U += pic->
linesize[1] * slice_height;
668 V += pic->
linesize[2] * slice_height;
682 if (avpkt->
size < 16) {