Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the length in bytes of all the TLM markers
        /// that are required to
        /// </summary>
        /// <param name="tileparts"></param>
        /// <returns></returns>
        private static int GetTotalTlmLength(int tileparts)
        {
            int tlmCount = BitHacks.DivCeil(tileparts, TlmMarker.MaxEntries);

            if (tlmCount > TlmMarker.MaxMarkers)
            {
                throw new InvalidOperationException(
                          String.Concat(string.Format(
                                            "too many tile-parts {0}, cannot create more ",
                                            "than {1} TLM markers, each marker containing up to ",
                                            "{2} entries",
                                            tileparts, TlmMarker.MaxMarkers, TlmMarker.MaxEntries)));
            }
            int tilepartsRemainder =
                tileparts - ((tlmCount - 1) * TlmMarker.MaxEntries);
            // calculate length for all the full TLM markers
            int tlmLength =
                (tlmCount - 1) * TlmMarker.LengthOf(TlmMarker.MaxEntries);

            // add the length of all TLM markers which are left.
            tlmLength += TlmMarker.LengthOf(tilepartsRemainder);
            // TlmMarker.LengthOf returns the Length of the TLM
            // field as signaled in the marker segment, without
            // without the 2 bytes of the marker itself.
            tlmLength += tlmCount * MarkerSegment.MarkerLength;
            return(tlmLength);
        }
Ejemplo n.º 2
0
        private void AddToTlm(JP2TilePart tp)
        {
            TlmMarker tlm = _tlmMarkers.Last();

            if (tlm.IsFull)
            {
                if (_tlmMarkers.Count >= TlmMarker.MaxMarkers)
                {
                    throw new InvalidOperationException(String.Concat(
                                                            "Cannot add more tile-parts, Exceeded the ",
                                                            "limit of TLM markers in codestream"));
                }

                _tlmMarkers.Add(new TlmMarker((byte)_tlmMarkers.Count));
                tlm = _tlmMarkers.Last();
            }
            tlm.Add(tp);
        }