23 #define BITSTREAM_READER_LE
40 if (src_size < avctx->
width * avctx->
height * (int64_t)bpp) {
50 for (h = 0; h < avctx->
height; h++) {
51 memcpy(dst, src, avctx->
width * bpp);
52 src += avctx->
width * bpp;
81 for (h = 0; h < avctx->
height; h += 4) {
82 for (w = 0; w < avctx->
width; w += 4) {
87 U[w >> 2] = src[16] + 0x80;
88 V[w >> 2] = src[17] + 0x80;
122 for (h = 0; h < avctx->
height; h += 2) {
123 for (w = 0; w < avctx->
width; w += 2) {
126 U[w >> 1] = src[4] + 0x80;
127 V[w >> 1] = src[5] + 0x80;
158 for (h = 0; h < avctx->
height; h++) {
159 for (w = 0; w < avctx->
width; w++) {
161 U[w] = *src++ ^ 0x80;
162 V[w] = *src++ ^ 0x80;
172 static const uint8_t def_lru[8] = { 0x00, 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0, 0xFF };
183 memmove(lru + 1, lru,
sizeof(*lru) * (8 - 1));
186 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
201 memmove(lru + 1, lru,
sizeof(*lru) * (6 - 1));
204 memmove(lru + 1, lru,
sizeof(*lru) * (c - 1));
220 memcpy(lru[2], def_lru_555, 8 *
sizeof(*
def_lru));
222 for (y = 0; y <
height; y++) {
223 for (x = 0; x <
width; x++) {
227 dst[x * 3 + 0] = (r << 3) | (r >> 2);
228 dst[x * 3 + 1] = is_565 ? (g << 2) | (g >> 4) : (g << 3) | (g >> 2);
229 dst[x * 3 + 2] = (b << 3) | (b >> 2);
243 int nslices, slice, slice_height;
244 uint32_t
off, slice_size;
249 nslices = bytestream2_get_le16(&gb);
250 off =
FFALIGN(nslices * 4 + 2, 16);
251 if (src_size < off) {
256 if (!nslices || avctx->
height % nslices) {
262 slice_height = avctx->
height / nslices;
268 for (slice = 0; slice < nslices; slice++) {
269 slice_size = bytestream2_get_le32(&gb);
270 if (slice_size > src_size - off) {
272 "invalid slice size %d (only %d bytes left)\n",
273 slice_size, src_size - off);
276 if (slice_size <= 16) {
281 if (
AV_RL32(src + off) != slice_size - 16) {
283 "Slice sizes mismatch: got %d instead of %d\n",
284 AV_RL32(src + off), slice_size - 16);
290 dst += pic->
linesize[0] * slice_height;
303 for (i = 0; i < 3; i++)
306 for (y = 0; y <
height; y++) {
307 for (x = 0; x <
width; x++) {
324 int nslices, slice, slice_height;
325 uint32_t
off, slice_size;
330 nslices = bytestream2_get_le16(&gb);
331 off =
FFALIGN(nslices * 4 + 2, 16);
332 if (src_size < off) {
337 if (!nslices || avctx->
height % nslices) {
343 slice_height = avctx->
height / nslices;
349 for (slice = 0; slice < nslices; slice++) {
350 slice_size = bytestream2_get_le32(&gb);
351 if (slice_size > src_size - off) {
353 "invalid slice size %d (only %d bytes left)\n",
354 slice_size, src_size - off);
357 if (slice_size <= 16) {
362 if (
AV_RL32(src + off) != slice_size - 16) {
364 "Slice sizes mismatch: got %d instead of %d\n",
365 AV_RL32(src + off), slice_size - 16);
371 dst += pic->
linesize[0] * slice_height;
380 int ystride,
int ustride,
int vstride)
385 for (i = 0; i < 3; i++)
388 for (y = 0; y <
height; y += 4) {
389 for (x = 0; x <
width; x += 4) {
390 for (j = 0; j < 4; j++)
391 for (i = 0; i < 4; i++)
392 Y[x + i + j * ystride] =
decode_sym(gb, lru[0]);
410 int nslices, slice, slice_height, ref_slice_height;
412 uint32_t
off, slice_size;
417 nslices = bytestream2_get_le16(&gb);
418 off =
FFALIGN(nslices * 4 + 2, 16);
419 if (src_size < off) {
424 if (!nslices || avctx->
height % nslices) {
430 ref_slice_height = avctx->
height / nslices;
445 next_y = ref_slice_height;
446 for (slice = 0; slice < nslices; slice++) {
447 slice_size = bytestream2_get_le32(&gb);
448 slice_height = (next_y & ~3) - (cur_y & ~3);
449 if (slice_size > src_size - off) {
451 "invalid slice size %d (only %d bytes left)\n",
452 slice_size, src_size - off);
455 if (slice_size <= 16) {
460 if (
AV_RL32(src + off) != slice_size - 16) {
462 "Slice sizes mismatch: got %d instead of %d\n",
463 AV_RL32(src + off), slice_size - 16);
470 Y += pic->
linesize[0] * slice_height;
471 U += pic->
linesize[1] * (slice_height >> 2);
472 V += pic->
linesize[2] * (slice_height >> 2);
475 next_y += ref_slice_height;
483 int ystride,
int ustride,
int vstride)
488 for (i = 0; i < 3; i++)
491 for (y = 0; y <
height; y+=2) {
492 for (x = 0; x <
width; x += 2) {
493 Y[x + 0 + 0 * ystride] =
decode_sym(gb, lru[0]);
494 Y[x + 1 + 0 * ystride] =
decode_sym(gb, lru[0]);
495 Y[x + 0 + 1 * ystride] =
decode_sym(gb, lru[0]);
496 Y[x + 1 + 1 * ystride] =
decode_sym(gb, lru[0]);
514 int nslices, slice, slice_height, ref_slice_height;
516 uint32_t
off, slice_size;
521 nslices = bytestream2_get_le16(&gb);
522 off =
FFALIGN(nslices * 4 + 2, 16);
523 if (src_size < off) {
528 if (!nslices || avctx->
height % nslices) {
534 ref_slice_height = avctx->
height / nslices;
549 next_y = ref_slice_height;
550 for (slice = 0; slice < nslices; slice++) {
551 slice_size = bytestream2_get_le32(&gb);
552 slice_height = (next_y & ~1) - (cur_y & ~1);
553 if (slice_size > src_size - off) {
555 "invalid slice size %d (only %d 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 %d instead of %d\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);
579 next_y += ref_slice_height;
587 int ystride,
int ustride,
int vstride)
592 for (i = 0; i < 3; i++)
595 for (y = 0; y <
height; y++) {
596 for (x = 0; x <
width; x++) {
615 int nslices, slice, slice_height;
616 uint32_t
off, slice_size;
621 nslices = bytestream2_get_le16(&gb);
622 off =
FFALIGN(nslices * 4 + 2, 16);
623 if (src_size < off) {
628 if (!nslices || avctx->
height % nslices) {
634 slice_height = avctx->
height / nslices;
644 for (slice = 0; slice < nslices; slice++) {
645 slice_size = bytestream2_get_le32(&gb);
646 if (slice_size > src_size - off) {
648 "invalid slice size %d (only %d bytes left)\n",
649 slice_size, src_size - off);
652 if (slice_size <= 16) {
657 if (
AV_RL32(src + off) != slice_size - 16) {
659 "Slice sizes mismatch: got %d instead of %d\n",
660 AV_RL32(src + off), slice_size - 16);
667 Y += pic->
linesize[0] * slice_height;
668 U += pic->
linesize[1] * slice_height;
669 V += pic->
linesize[2] * slice_height;
683 if (avpkt->
size < 16) {