CSJ2K.j2k.codestream.reader.FileBitstreamReaderAgent.readLyResCompPos C# (CSharp) Метод

readLyResCompPos() приватный Метод

Reads packets of the current tile according to the layer-resolution-component-position progressiveness.
private readLyResCompPos ( int lys, int lye, int ress, int rese, int comps, int compe ) : bool
lys int Index of the first layer for each component and resolution. /// ///
lye int Index of the last layer. /// ///
ress int Index of the first resolution level. /// ///
rese int Index of the last resolution level. /// ///
comps int Index of the first component. /// ///
compe int Index of the last component. /// ///
Результат bool
        private bool readLyResCompPos(int[][] lys, int lye, int ress, int rese, int comps, int compe)
        {
            int minlys = 10000;
            for (int c = comps; c < compe; c++)
            {
                //loop on components
                // Check if this component exists
                if (c >= mdl.Length)
                    continue;

                for (int r = ress; r < rese; r++)
                {
                    //loop on resolution levels
                    if (lys[c] != null && r < lys[c].Length && lys[c][r] < minlys)
                    {
                        minlys = lys[c][r];
                    }
                }
            }

            int t = TileIdx;
            int start;
            bool status = false;
            int lastByte = firstPackOff[t][curTilePart] + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
            int numLayers = ((System.Int32) decSpec.nls.getTileDef(t));
            int nPrec = 1;
            int hlen, plen;
            System.String strInfo = "Tile " + TileIdx + " (tile-part:" + curTilePart + "): offset, length, header length\n"; ;
            bool pph = false;
            if (((System.Boolean) decSpec.pphs.getTileDef(t)))
            {
                pph = true;
            }
            for (int l = minlys; l < lye; l++)
            {
                // loop on layers
                for (int r = ress; r < rese; r++)
                {
                    // loop on resolution levels
                    for (int c = comps; c < compe; c++)
                    {
                        // loop on components
                        // Checks if component exists
                        if (c >= mdl.Length)
                            continue;
                        // Checks if resolution level exists
                        if (r >= lys[c].Length)
                            continue;
                        if (r > mdl[c])
                            continue;
                        // Checks if layer exists
                        if (l < lys[c][r] || l >= numLayers)
                            continue;

                        nPrec = pktDec.getNumPrecinct(c, r);
                        for (int p = 0; p < nPrec; p++)
                        {
                            // loop on precincts
                            start = in_Renamed.Pos;

                            // If packed packet headers are used, there is no need
                            // to check that there are bytes enough to read header
                            if (pph)
                            {
                                pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
                            }

                            // If we are about to read outside of tile-part,
                            // skip to next tile-part
                            if (start > lastByte && curTilePart < firstPackOff[t].Length - 1)
                            {
                                curTilePart++;
                                in_Renamed.seek(firstPackOff[t][curTilePart]);
                                lastByte = in_Renamed.Pos + tilePartLen[t][curTilePart] - 1 - tilePartHeadLen[t][curTilePart];
                            }

                            // Read SOP marker segment if necessary
                            status = pktDec.readSOPMarker(nBytes, p, c, r);

                            if (status)
                            {
                                if (printInfo)
                                {
                                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, strInfo);
                                }
                                return true;
                            }

                            if (!pph)
                            {
                                status = pktDec.readPktHead(l, r, c, p, cbI[c][r], nBytes);
                            }

                            if (status)
                            {
                                if (printInfo)
                                {
                                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, strInfo);
                                }
                                return true;
                            }

                            // Store packet's head length
                            hlen = in_Renamed.Pos - start;
                            pktHL.Add((System.Int32) hlen);

                            // Reads packet's body
                            status = pktDec.readPktBody(l, r, c, p, cbI[c][r], nBytes);
                            plen = in_Renamed.Pos - start;
                            strInfo += (" Pkt l=" + l + ",r=" + r + ",c=" + c + ",p=" + p + ": " + start + ", " + plen + ", " + hlen + "\n");

                            if (status)
                            {
                                if (printInfo)
                                {
                                    FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, strInfo);
                                }
                                return true;
                            }
                        } // end loop on precincts
                    } // end loop on components
                } // end loop on resolution levels
            } // end loop on layers

            if (printInfo)
            {
                FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.INFO, strInfo);
            }
            return false; // Decoding rate was not reached
        }