32 #define HEADER_SIZE 27
34 #define MODEL2_SCALE 13
35 #define MODEL_SCALE 15
36 #define MODEL256_SEC_SCALE 9
44 typedef struct Model {
59 #define RAC_BOTTOM 0x01000000
181 m->
freqs[i] = sum * scale >> 16;
196 for (i = 0; i < m->
num_syms - 1; i++)
229 for (i = 0; i < 256; i++) {
236 for (i = 0; i < 256; i++) {
237 m->
freqs[i] = sum * scale >> 16;
243 while (sidx < m->sec_size)
256 for (i = 0; i < 255; i++)
283 for (i = 0; i <
FFMIN(size, 4); i++)
285 c->
range = 0xFFFFFFFF;
296 }
else if (!c->
low) {
340 bit = (c->
low >= helper);
358 int prob, prob2, helper, val;
369 if (helper <= c->low) {
376 end = (end2 + val) >> 1;
377 }
while (end != val);
379 c->
range = prob2 - prob;
390 int prob, prob2, helper, val;
401 end = start = m->
secondary[ssym + 1] + 1;
402 while (end > val + 1) {
403 ssym = (end + val) >> 1;
404 if (m->
freqs[ssym] <= helper) {
408 end = (end + val) >> 1;
417 c->
range = prob2 - prob;
458 for (i = 0; i < block_size; i++, dst +=
stride)
459 memset(dst, fc->
fill_val, block_size);
472 for (i = 0; i < vec_size; i++)
476 memset(prev_line, 0,
sizeof(prev_line));
478 for (j = 0; j < block_size; j++) {
481 for (i = 0; i < block_size; i++) {
499 int skip, val, sign, pos = 1, zz_pos, dc;
502 memset(block, 0,
sizeof(*block) * 64);
524 block[0] = dc * bc->
qmat[0];
551 block[zz_pos] = val * bc->
qmat[zz_pos];
555 return pos == 64 ? 0 : -1;
560 int *
block,
int mb_x,
int mb_y)
564 int nblocks = block_size >> 3;
569 for (j = 0; j < nblocks; j++) {
570 for (i = 0; i < nblocks; i++) {
571 if (
decode_dct(c, bc, block, bx + i, by + j)) {
585 const int hsize = block_size >> 1;
589 for (j = 0; j < block_size; j++) {
590 for (i = 0; i < block_size; i++) {
591 if (i < hsize && j < hsize)
595 block[i] *= hc->
scale;
599 block -= block_size * block_size;
601 for (j = 0; j < hsize; j++) {
602 for (i = 0; i < hsize; i++) {
604 B = block[i + hsize];
605 C = block[i + hsize * block_size];
606 D = block[i + hsize * block_size + hsize];
612 dst[i * 2] = av_clip_uint8(t1 - t2);
613 dst[i * 2 +
stride] = av_clip_uint8(t1 + t2);
614 dst[i * 2 + 1] = av_clip_uint8(t3 - t4);
615 dst[i * 2 + 1 +
stride] = av_clip_uint8(t3 + t4);
626 for (i = 0; i < 3; i++) {
628 for (j = 0; j < 5; j++)
635 for (j = 0; j < 125; j++)
661 for (i = 0; i < 3; i++) {
662 for (j = 0; j < 5; j++)
668 for (j = 0; j < 125; j++)
681 int buf_size = avpkt->
size;
686 int dec_width, dec_height, dec_x, dec_y, quality, keyframe;
687 int x, y, i, mb_width, mb_height, blk_size, btype;
692 "Frame should have at least %d bytes, got %d instead\n",
698 keyframe = bytestream2_get_be32(&gb);
699 if (keyframe & ~0x301) {
703 keyframe = !(keyframe & 1);
705 dec_x = bytestream2_get_be16(&gb);
706 dec_y = bytestream2_get_be16(&gb);
707 dec_width = bytestream2_get_be16(&gb);
708 dec_height = bytestream2_get_be16(&gb);
710 if (dec_x + dec_width > avctx->
width ||
711 dec_y + dec_height > avctx->
height ||
712 (dec_width | dec_height) & 0xF) {
714 dec_width, dec_height, dec_x, dec_y);
718 quality = bytestream2_get_byte(&gb);
719 if (quality < 1 || quality > 100) {
753 mb_width = dec_width >> 4;
754 mb_height = dec_height >> 4;
758 for (y = 0; y < mb_height; y++) {
759 for (x = 0; x < mb_width; x++) {
760 for (i = 0; i < 3; i++) {
767 dst[i] + x * blk_size,
772 dst[i] + x * blk_size,
777 dst[i] + x * blk_size,
783 dst[i] + x * blk_size,
814 if ((avctx->
width & 0xF) || (avctx->
height & 0xF)) {
816 "Image dimensions should be a multiple of 16.\n");
821 for (i = 0; i < 3; i++) {
822 int b_width = avctx->
width >> (2 + !!i);
823 int b_height = avctx->
height >> (2 + !!i);
853 for (i = 0; i < 3; i++)