Beispiel #1
0
        public void QueryLayerResolutionLrcpTest()
        {
            int layerIdx = 1;
            int resIdx   = 1;

            int precinctsInResolution    = 1;
            int components               = 3;
            int resolutions              = 3;
            int packetsInLayerResolution = precinctsInResolution * components;
            int packetsInLayer           = packetsInLayerResolution * resolutions;

            int expectedStart = layerIdx * packetsInLayer;

            expectedStart += resIdx * packetsInLayerResolution;
            int          expectedEnd = expectedStart + packetsInLayerResolution;
            PreciseQuery q           = PreciseQuery.Create(_queryContext);

            PacketInterval[] intervals = q
                                         .Quality(layerIdx)
                                         .Resolution(resIdx)
                                         .Execute()
                                         .ToArray();

            Assert.AreEqual(intervals.Length, 1);
            Assert.AreEqual(intervals[0].PacketStart, expectedStart);
            Assert.AreEqual(intervals[0].PacketEnd, expectedEnd);
            Assert.AreEqual(intervals[0].Count, packetsInLayerResolution);
        }
Beispiel #2
0
        public void QueryResolutionLrcpTest()
        {
            int resIdx = 1;

            int precinctsInResolution = 1;
            int layers      = 2;
            int components  = 3;
            int resolutions = 3;
            int packetsInLayerResolution = precinctsInResolution * components;
            int packetsInLayer           = packetsInLayerResolution * resolutions;

            int expectedStartInLayer = resIdx * packetsInLayerResolution;

            int[] expectedStarts = new int[layers];
            for (int ly = 0; ly < layers; ly++)
            {
                expectedStarts[ly]  = ly * packetsInLayer;
                expectedStarts[ly] += expectedStartInLayer;
            }

            PreciseQuery q = PreciseQuery.Create(_queryContext);

            PacketInterval[] intervals = q
                                         .Resolution(resIdx)
                                         .Execute()
                                         .ToArray();

            Assert.AreEqual(intervals.Length, layers);
            for (int ly = 0; ly < layers; ly++)
            {
                Assert.AreEqual(intervals[ly].PacketStart, expectedStarts[ly]);
                Assert.AreEqual(intervals[ly].Count, packetsInLayerResolution);
            }
        }
Beispiel #3
0
        public void QueryResolutionRpclTest()
        {
            int          resolutions = _rpclCodestream.DecompositionLevels + 1;
            PreciseQuery q           = PreciseQuery.Create(_queryContext);

            IEnumerable <PacketInterval>[] intervals =
                new IEnumerable <PacketInterval> [resolutions];
            for (int r = 0; r < resolutions; r++)
            {
                intervals[r] = q.Resolution(r).Execute();
            }
            int packetStart    = 0;
            int layersMulComps =
                _rpclCodestream.QualityLayers * _rpclCodestream.Components;

            for (int r = 0; r < resolutions; r++)
            {
                int packetsInResolution = layersMulComps;
                // NOTE TO SELF: I can calculate everything
                // programatically, but then I would duplicate
                // the code that I need to test, and may
                // have two places with possible bugs.
                PacketInterval[] ivals = intervals[r].ToArray();
                Assert.AreEqual(ivals.Length, 1);
                PacketInterval ival           = ivals[0];
                var            cod            = _rpclCodestream.Markers[MarkerType.COD] as CodMarker;
                int            precinctsInRes = GetPrecinctsInResolution(r, cod);
                packetsInResolution *= precinctsInRes;
                Assert.AreEqual(packetStart, ival.PacketStart);
                Assert.AreEqual(packetsInResolution, ival.Count);
                packetStart += packetsInResolution;
            }
        }
Beispiel #4
0
        private void CopyTileResLevel(JP2Codestream dst, JP2Codestream src, ushort tIdx, int r)
        {
            int decomps     = src.DecompositionLevels;
            var dstTilePart = dst.CreateTilePart(tIdx, r == decomps);

            // get all packets for this resolution level and source tile
            // currently support only a single tile in source image for every
            // destination tile.
            QueryContext queryContext = new QueryContext(src, 0);
            PreciseQuery preciseQuery = PreciseQuery.Create(queryContext);
            var          intervals    = preciseQuery
                                        .Resolution(r)
                                        .Execute();
            JP2Tile srcTile = src.Tiles[0];
            // add packet lengths
            Func <JP2TilePart, int, int, int, int> addPacketLengths =
                (tpSrc, pckStart, pckCount, voidParam) =>
            {
                var lengths = tpSrc.GetPacketLengths(pckStart, pckCount);
                dstTilePart.AddPacketLengths(lengths);
                return(voidParam);
            };

            EnumerateIntervals <int>(intervals, srcTile, addPacketLengths);

            // bulk transfer packet data
            dstTilePart.Flush();
            byte[] buffer = new byte[1 << 16];
            Func <JP2TilePart, int, int, uint, uint> bulkTransfer =
                (tpSrc, pckStart, pckCount, dstOffset) =>
            {
                uint dataCount = JP2TilePart.BulkTransferData(
                    dstTilePart,
                    dstOffset,
                    tpSrc,
                    pckStart,
                    pckCount,
                    buffer);
                return(dstOffset + dataCount);
            };

            EnumerateIntervals <uint>(
                intervals,
                srcTile,
                bulkTransfer);
            dstTilePart.Close();
            srcTile.Close();
        }
Beispiel #5
0
        public void QueryLayerLrcpTest()
        {
            int resolutions            = 3;
            int precinctsPerResolution = 1;
            int components             = 3;
            int packetsInLayer         = 1;

            packetsInLayer *= resolutions;
            packetsInLayer *= precinctsPerResolution;
            packetsInLayer *= components;
            PreciseQuery q = PreciseQuery.Create(_queryContext);

            PacketInterval[] intervals = q.Quality(1).Execute().ToArray();
            Assert.AreEqual(intervals.Length, 1);
            Assert.AreEqual(intervals[0].PacketStart, packetsInLayer);
            Assert.AreEqual(intervals[0].PacketEnd, 2 * packetsInLayer);
            Assert.AreEqual(intervals[0].Count, packetsInLayer);
        }
Beispiel #6
0
        public void EmptyQueryTest()
        {
            int layers                 = 2;
            int resolutions            = 3;
            int precinctsPerResolution = 1;
            int components             = 3;
            int expectedPackets        = 1;

            expectedPackets *= layers;
            expectedPackets *= resolutions;
            expectedPackets *= components;
            expectedPackets *= precinctsPerResolution;
            int actualPackets = _lrcpCodestream.Tiles[_tileIdx].GetPacketCounts().Sum();

            Assert.AreEqual(expectedPackets, actualPackets);
            PreciseQuery q = PreciseQuery.Create(_queryContext);

            PacketInterval[] intervals = q.Execute().ToArray();
            Assert.AreEqual(intervals.Length, 1);
            Assert.AreEqual(intervals[0].TileIndex, _tileIdx);
            Assert.AreEqual(intervals[0].PacketStart, 0);
            Assert.AreEqual(intervals[0].Count, actualPackets);
            Assert.AreEqual(intervals[0].PacketEnd, actualPackets);
        }