Пример #1
0
        public void InterWaveCodecTest()
        {
            InterWaveMap   map   = new InterWaveMap();
            InterWaveCodec codec = new InterWaveCodec(map);

            Assert.NotNull(codec._QuantHigh);
            Assert.Equal(10, codec._QuantHigh.Length);
            Assert.NotNull(codec._QuantLow);
            Assert.Equal(16, codec._QuantLow.Length);
            Assert.NotNull(codec._CoefficientState);
            Assert.Equal(256, codec._CoefficientState.Length);
            Assert.NotNull(codec._BucketState);
            Assert.Equal(16, codec._BucketState.Length);
            Assert.Equal(0, codec._CurrentBand);
            Assert.Equal(1, codec._CurrentBitPlane);
            Assert.NotNull(codec._CtxStart);
            Assert.Equal(32, codec._CtxStart.Length);

            Assert.NotNull(codec._CtxBucket);
            Assert.Equal(10, codec._CtxBucket.Length);

            foreach (var b in codec._CtxBucket)
            {
                Assert.NotNull(b);
                Assert.Equal(8, b.Length);
            }
        }
Пример #2
0
        public void CodeSliceTest002()
        {
            var map   = new InterWaveMap();
            var codec = new InterWaveDecoder(map);
            var coder = new ZPCodec();

            Assert.Equal(1, codec.CodeSlice(coder));
        }
Пример #3
0
        public void CodeSliceTest001()
        {
            var map   = new InterWaveMap();
            var codec = new InterWaveDecoder(map);

            codec._CurrentBitPlane = -1;
            Assert.Equal(0, codec.CodeSlice(null));
        }
Пример #4
0
        public void InitTest()
        {
            var map   = new InterWaveMap();
            var codec = new InterWaveDecoder(map);
            var test  = codec.Init(map);

            Assert.NotNull(test);
            Assert.Same(codec, test);
        }
Пример #5
0
        public void NextQuantFastBenchmarkTest()
        {
            InterWaveMap map   = new InterWaveMap(32, 32);
            var          codec = new InterWaveCodec(map);

            for (int i = 0; i < 500000000; i++)
            {
                codec.NextQuantFast();
            }
        }
Пример #6
0
        public InterWaveCodec Init(InterWaveMap map)
        {
            int i = 0;

            int[] q    = _IwQuant;
            int   qidx = 0;

            for (int j = 0; i < 4; j++)
            {
                _QuantLow[i++] = q[qidx++];
            }

            for (int j = 0; j < 4; j++)
            {
                _QuantLow[i++] = q[qidx];
            }

            qidx++;

            for (int j = 0; j < 4; j++)
            {
                _QuantLow[i++] = q[qidx];
            }

            qidx++;

            for (int j = 0; j < 4; j++)
            {
                _QuantLow[i++] = q[qidx];
            }

            qidx++;
            _QuantHigh[0] = 0;

            for (int j = 1; j < 10; j++)
            {
                _QuantHigh[j] = q[qidx++];
            }

            while (_QuantLow[0] >= 32768)
            {
                NextQuant();
            }

            return(this);
        }
Пример #7
0
        public void ImageTest005()
        {
            int width  = 32;
            int height = 32;

            Rectangle rect = new Rectangle
            {
                Right  = 0,
                Left   = width,
                Bottom = 0,
                Top    = height
            };

            InterWaveMap map = new InterWaveMap(width, height);

            map.Image(0, new sbyte[width * height], width, 1, true);
        }
Пример #8
0
        public void ImageTest007()
        {
            int width     = 32;
            int height    = 32;
            int subsample = 1;

            Rectangle rect = new Rectangle
            {
                Right  = 0,
                Left   = width,
                Bottom = 0,
                Top    = height
            };

            InterWaveMap map = new InterWaveMap(width, height);

            map.Image(subsample, rect, 1, new sbyte[width * height + 1], width, 1, true);
        }
Пример #9
0
        public void ImageTest002()
        {
            int width  = 32;
            int height = 32;

            int subsample = 4;

            Rectangle rect = new Rectangle
            {
                Left = 0,
                Top  = height
            };

            InterWaveMap map = new InterWaveMap(width, height);

            Assert.Throws <DjvuArgumentException>(
                () => map.Image(subsample, rect, 1, new sbyte[width * height], width, 1, true));
        }
Пример #10
0
        /// <summary>
        /// Creates a new Codec object.
        /// </summary>
        public InterWaveCodec(InterWaveMap map)
        {
            _CtxStart = new byte[32];

            _CtxBucket = new byte[10][];
            for (int i2 = 0; i2 < _CtxBucket.Length; i2++)
            {
                _CtxBucket[i2] = new byte[8];
            }

            _QuantHigh        = new int[10];
            _QuantLow         = new int[16];
            _CoefficientState = new sbyte[256];
            _BucketState      = new sbyte[16];
            _CurrentBand      = 0;
            _CurrentBitPlane  = 1;
            _Map = map;
            Init(map);
        }
Пример #11
0
        public void BackwardFilterTest002()
        {
            InterWaveMap map = new InterWaveMap();

            Assert.Throws <DjvuFormatException>(() => InterWaveMap.BackwardFilter(null, 0, 10, 16, 17, 0));
        }