33 #define HEADER_SIZE 27
35 #define MODEL2_SCALE 13
36 #define MODEL_SCALE 15
37 #define MODEL256_SEC_SCALE 9
45 typedef struct Model {
60 #define RAC_BOTTOM 0x01000000
182 m->
freqs[i] = sum * scale >> 16;
197 for (i = 0; i < m->
num_syms - 1; i++)
230 for (i = 0; i < 256; i++) {
237 for (i = 0; i < 256; i++) {
238 m->
freqs[i] = sum * scale >> 16;
244 while (sidx < m->sec_size)
257 for (i = 0; i < 255; i++)
284 for (i = 0; i <
FFMIN(size, 4); i++)
286 c->
range = 0xFFFFFFFF;
297 }
else if (!c->
low) {
341 bit = (c->
low >= helper);
359 int prob, prob2, helper,
val;
370 if (helper <= c->low) {
377 end = (end2 +
val) >> 1;
378 }
while (end != val);
380 c->
range = prob2 - prob;
391 int prob, prob2, helper,
val;
402 end = start = m->
secondary[ssym + 1] + 1;
403 while (end > val + 1) {
404 ssym = (end +
val) >> 1;
405 if (m->
freqs[ssym] <= helper) {
409 end = (end +
val) >> 1;
418 c->
range = prob2 - prob;
459 for (i = 0; i < block_size; i++, dst +=
stride)
460 memset(dst, fc->
fill_val, block_size);
473 for (i = 0; i < vec_size; i++)
477 memset(prev_line, 0,
sizeof(prev_line));
479 for (j = 0; j < block_size; j++) {
482 for (i = 0; i < block_size; i++) {
500 int skip,
val, sign, pos = 1, zz_pos,
dc;
503 memset(block, 0,
sizeof(*block) * 64);
525 block[0] = dc * bc->
qmat[0];
552 block[zz_pos] = val * bc->
qmat[zz_pos];
556 return pos == 64 ? 0 : -1;
561 int *
block,
int mb_x,
int mb_y)
565 int nblocks = block_size >> 3;
570 for (j = 0; j < nblocks; j++) {
571 for (i = 0; i < nblocks; i++) {
572 if (
decode_dct(c, bc, block, bx + i, by + j)) {
586 const int hsize = block_size >> 1;
590 for (j = 0; j < block_size; j++) {
591 for (i = 0; i < block_size; i++) {
592 if (i < hsize && j < hsize)
596 block[i] *= hc->
scale;
600 block -= block_size * block_size;
602 for (j = 0; j < hsize; j++) {
603 for (i = 0; i < hsize; i++) {
605 B = block[i + hsize];
606 C = block[i + hsize * block_size];
607 D = block[i + hsize * block_size + hsize];
613 dst[i * 2] = av_clip_uint8(t1 - t2);
614 dst[i * 2 +
stride] = av_clip_uint8(t1 + t2);
615 dst[i * 2 + 1] = av_clip_uint8(t3 - t4);
616 dst[i * 2 + 1 +
stride] = av_clip_uint8(t3 + t4);
627 for (i = 0; i < 3; i++) {
629 for (j = 0; j < 5; j++)
636 for (j = 0; j < 125; j++)
662 for (i = 0; i < 3; i++) {
663 for (j = 0; j < 5; j++)
669 for (j = 0; j < 125; j++)
682 int buf_size = avpkt->
size;
687 int dec_width, dec_height, dec_x, dec_y, quality, keyframe;
688 int x,
y, i, mb_width, mb_height, blk_size, btype;
693 "Frame should have at least %d bytes, got %d instead\n",
699 keyframe = bytestream2_get_be32(&gb);
700 if (keyframe & ~0x301) {
704 keyframe = !(keyframe & 1);
706 dec_x = bytestream2_get_be16(&gb);
707 dec_y = bytestream2_get_be16(&gb);
708 dec_width = bytestream2_get_be16(&gb);
709 dec_height = bytestream2_get_be16(&gb);
711 if (dec_x + dec_width > avctx->
width ||
712 dec_y + dec_height > avctx->
height ||
713 (dec_width | dec_height) & 0xF) {
715 dec_width, dec_height, dec_x, dec_y);
719 quality = bytestream2_get_byte(&gb);
720 if (quality < 1 || quality > 100) {
750 mb_width = dec_width >> 4;
751 mb_height = dec_height >> 4;
755 for (y = 0; y < mb_height; y++) {
756 for (x = 0; x < mb_width; x++) {
757 for (i = 0; i < 3; i++) {
764 dst[i] + x * blk_size,
769 dst[i] + x * blk_size,
774 dst[i] + x * blk_size,
780 dst[i] + x * blk_size,
813 if ((avctx->
width & 0xF) || (avctx->
height & 0xF)) {
815 "Image dimensions should be a multiple of 16.\n");
820 for (i = 0; i < 3; i++) {
821 int b_width = avctx->
width >> (2 + !!i);
822 int b_height = avctx->
height >> (2 + !!i);
850 for (i = 0; i < 3; i++)