Ejemplo n.º 1
0
		public IntegerCompressor(ArithmeticDecoder dec, uint bits=16, uint contexts=1, uint bits_high=8, uint range=0)
		{
			Debug.Assert(dec!=null);
			this.enc=null;
			this.dec=dec;

			Init(bits, contexts, bits_high, range);
		}
Ejemplo n.º 2
0
        public IntegerCompressor(ArithmeticDecoder dec, uint bits = 16, uint contexts = 1, uint bits_high = 8, uint range = 0)
        {
            Debug.Assert(dec != null);
            this.enc = null;
            this.dec = dec;

            Init(bits, contexts, bits_high, range);
        }
        public LASreadItemCompressed_RGB12_v1(ArithmeticDecoder dec)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;

            // create models and integer compressors
            m_byte_used = dec.createSymbolModel(64);
            ic_rgb      = new IntegerCompressor(dec, 8, 6);
        }
		public LASreadItemCompressed_GPSTIME11_v2(ArithmeticDecoder dec)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;

			// create entropy models and integer compressors
			m_gpstime_multi=dec.createSymbolModel(LASZIP_GPSTIME_MULTI_TOTAL);
			m_gpstime_0diff=dec.createSymbolModel(6);
			ic_gpstime=new IntegerCompressor(dec, 32, 9); // 32 bits, 9 contexts
		}
Ejemplo n.º 5
0
        public LASreadItemCompressed_BYTE_v1(ArithmeticDecoder dec, uint number)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;
            Debug.Assert(number != 0);
            this.number = number;

            // create models and integer compressors
            ic_byte = new IntegerCompressor(dec, 8, number);

            // create last item
            last_item = new byte[number];
        }
		public LASreadItemCompressed_BYTE_v1(ArithmeticDecoder dec, uint number)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;
			Debug.Assert(number!=0);
			this.number=number;

			// create models and integer compressors
			ic_byte=new IntegerCompressor(dec, 8, number);

			// create last item
			last_item=new byte[number];
		}
        public LASreadItemCompressed_RGB12_v2(ArithmeticDecoder dec)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;

            // create models and integer compressors
            m_byte_used  = dec.createSymbolModel(128);
            m_rgb_diff_0 = dec.createSymbolModel(256);
            m_rgb_diff_1 = dec.createSymbolModel(256);
            m_rgb_diff_2 = dec.createSymbolModel(256);
            m_rgb_diff_3 = dec.createSymbolModel(256);
            m_rgb_diff_4 = dec.createSymbolModel(256);
            m_rgb_diff_5 = dec.createSymbolModel(256);
        }
		public LASreadItemCompressed_RGB12_v2(ArithmeticDecoder dec)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;

			// create models and integer compressors
			m_byte_used=dec.createSymbolModel(128);
			m_rgb_diff_0=dec.createSymbolModel(256);
			m_rgb_diff_1=dec.createSymbolModel(256);
			m_rgb_diff_2=dec.createSymbolModel(256);
			m_rgb_diff_3=dec.createSymbolModel(256);
			m_rgb_diff_4=dec.createSymbolModel(256);
			m_rgb_diff_5=dec.createSymbolModel(256);
		}
		public LASreadItemCompressed_WAVEPACKET13_v1(ArithmeticDecoder dec)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;

			// create models and integer compressors
			m_packet_index=dec.createSymbolModel(256);
			m_offset_diff[0]=dec.createSymbolModel(4);
			m_offset_diff[1]=dec.createSymbolModel(4);
			m_offset_diff[2]=dec.createSymbolModel(4);
			m_offset_diff[3]=dec.createSymbolModel(4);
			ic_offset_diff=new IntegerCompressor(dec, 32);
			ic_packet_size=new IntegerCompressor(dec, 32);
			ic_return_point=new IntegerCompressor(dec, 32);
			ic_xyz=new IntegerCompressor(dec, 32, 3);
		}
Ejemplo n.º 10
0
        public LASreadItemCompressed_WAVEPACKET13_v1(ArithmeticDecoder dec)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;

            // create models and integer compressors
            m_packet_index   = dec.createSymbolModel(256);
            m_offset_diff[0] = dec.createSymbolModel(4);
            m_offset_diff[1] = dec.createSymbolModel(4);
            m_offset_diff[2] = dec.createSymbolModel(4);
            m_offset_diff[3] = dec.createSymbolModel(4);
            ic_offset_diff   = new IntegerCompressor(dec, 32);
            ic_packet_size   = new IntegerCompressor(dec, 32);
            ic_return_point  = new IntegerCompressor(dec, 32);
            ic_xyz           = new IntegerCompressor(dec, 32, 3);
        }
		public LASreadItemCompressed_BYTE_v2(ArithmeticDecoder dec, uint number)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;
			Debug.Assert(number>0);
			this.number=number;

			// create models and integer compressors
			m_byte=new ArithmeticModel[number];
			for(uint i=0; i<number; i++)
			{
				m_byte[i]=dec.createSymbolModel(256);
			}

			// create last item
			last_item=new byte[number];
		}
        public LASreadItemCompressed_BYTE_v2(ArithmeticDecoder dec, uint number)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;
            Debug.Assert(number > 0);
            this.number = number;

            // create models and integer compressors
            m_byte = new ArithmeticModel[number];
            for (uint i = 0; i < number; i++)
            {
                m_byte[i] = dec.createSymbolModel(256);
            }

            // create last item
            last_item = new byte[number];
        }
		public LASreadItemCompressed_POINT10_v1(ArithmeticDecoder dec)
		{
			// set decoder
			Debug.Assert(dec!=null);
			this.dec=dec;

			// create models and integer compressors
			ic_dx=new IntegerCompressor(dec, 32); // 32 bits, 1 context
			ic_dy=new IntegerCompressor(dec, 32, 20); // 32 bits, 20 contexts
			ic_z=new IntegerCompressor(dec, 32, 20); // 32 bits, 20 contexts
			ic_intensity=new IntegerCompressor(dec, 16);
			ic_scan_angle_rank=new IntegerCompressor(dec, 8, 2);
			ic_point_source_ID=new IntegerCompressor(dec, 16);
			m_changed_values=dec.createSymbolModel(64);
			for(int i=0; i<256; i++)
			{
				m_bit_byte[i]=null;
				m_classification[i]=null;
				m_user_data[i]=null;
			}
		}
        public LASreadItemCompressed_POINT10_v1(ArithmeticDecoder dec)
        {
            // set decoder
            Debug.Assert(dec != null);
            this.dec = dec;

            // create models and integer compressors
            ic_dx              = new IntegerCompressor(dec, 32);     // 32 bits, 1 context
            ic_dy              = new IntegerCompressor(dec, 32, 20); // 32 bits, 20 contexts
            ic_z               = new IntegerCompressor(dec, 32, 20); // 32 bits, 20 contexts
            ic_intensity       = new IntegerCompressor(dec, 16);
            ic_scan_angle_rank = new IntegerCompressor(dec, 8, 2);
            ic_point_source_ID = new IntegerCompressor(dec, 16);
            m_changed_values   = dec.createSymbolModel(64);
            for (int i = 0; i < 256; i++)
            {
                m_bit_byte[i]       = null;
                m_classification[i] = null;
                m_user_data[i]      = null;
            }
        }
Ejemplo n.º 15
0
        // should only be called *once*
        public bool setup(uint num_items, LASitem[] items, LASzip laszip = null)
        {
            // is laszip exists then we must use its items
            if (laszip != null)
            {
                if (num_items != laszip.num_items)
                {
                    return(false);
                }
                if (items != laszip.items)
                {
                    return(false);
                }
            }

            // create entropy decoder (if requested)
            dec = null;
            if (laszip != null && laszip.compressor != 0)
            {
                switch (laszip.coder)
                {
                case LASzip.CODER_ARITHMETIC: dec = new ArithmeticDecoder(); break;

                default: return(false);                        // entropy decoder not supported
                }
            }

            // initizalize the readers
            readers     = null;
            num_readers = num_items;

            // disable chunking
            chunk_size = uint.MaxValue;

            // always create the raw readers
            readers_raw = new LASreadItem[num_readers];
            for (int i = 0; i < num_readers; i++)
            {
                switch (items[i].type)
                {
                case LASitem.Type.POINT10: readers_raw[i] = new LASreadItemRaw_POINT10(); break;

                case LASitem.Type.GPSTIME11: readers_raw[i] = new LASreadItemRaw_GPSTIME11(); break;

                case LASitem.Type.RGB12: readers_raw[i] = new LASreadItemRaw_RGB12(); break;

                case LASitem.Type.WAVEPACKET13: readers_raw[i] = new LASreadItemRaw_WAVEPACKET13(); break;

                case LASitem.Type.BYTE: readers_raw[i] = new LASreadItemRaw_BYTE(items[i].size); break;

                case LASitem.Type.POINT14: readers_raw[i] = new LASreadItemRaw_POINT14(); break;

                case LASitem.Type.RGBNIR14: readers_raw[i] = new LASreadItemRaw_RGBNIR14(); break;

                default: return(false);
                }
                point_size += items[i].size;
            }

            if (dec != null)
            {
                readers_compressed = new LASreadItem[num_readers];

                // seeks with compressed data need a seek point
                for (int i = 0; i < num_readers; i++)
                {
                    switch (items[i].type)
                    {
                    case LASitem.Type.POINT10:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_POINT10_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_POINT10_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.GPSTIME11:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_GPSTIME11_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_GPSTIME11_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.RGB12:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_RGB12_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_RGB12_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.WAVEPACKET13:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_WAVEPACKET13_v1(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.BYTE:
                        seek_point.extra_bytes     = new byte[items[i].size];
                        seek_point.num_extra_bytes = items[i].size;
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_BYTE_v1(dec, items[i].size);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_BYTE_v2(dec, items[i].size);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    default: return(false);
                    }
                }

                if (laszip.compressor == LASzip.COMPRESSOR_POINTWISE_CHUNKED)
                {
                    if (laszip.chunk_size != 0)
                    {
                        chunk_size = laszip.chunk_size;
                    }
                    number_chunks = uint.MaxValue;
                }
            }
            return(true);
        }
Ejemplo n.º 16
0
		// should only be called *once*
		public bool setup(uint num_items, LASitem[] items, LASzip laszip=null)
		{
			// is laszip exists then we must use its items
			if(laszip!=null)
			{
				if(num_items!=laszip.num_items) return false;
				if(items!=laszip.items) return false;
			}

			// create entropy decoder (if requested)
			dec=null;
			if(laszip!=null&&laszip.compressor!=0)
			{
				switch(laszip.coder)
				{
					case LASzip.CODER_ARITHMETIC: dec=new ArithmeticDecoder(); break;
					default: return false; // entropy decoder not supported
				}
			}

			// initizalize the readers
			readers=null;
			num_readers=num_items;

			// disable chunking
			chunk_size=uint.MaxValue;

			// always create the raw readers
			readers_raw=new LASreadItem[num_readers];
			for(int i=0; i<num_readers; i++)
			{
				switch(items[i].type)
				{
					case LASitem.Type.POINT10: readers_raw[i]=new LASreadItemRaw_POINT10(); break;
					case LASitem.Type.GPSTIME11: readers_raw[i]=new LASreadItemRaw_GPSTIME11(); break;
					case LASitem.Type.RGB12: readers_raw[i]=new LASreadItemRaw_RGB12(); break;
					case LASitem.Type.WAVEPACKET13: readers_raw[i]=new LASreadItemRaw_WAVEPACKET13(); break;
					case LASitem.Type.BYTE: readers_raw[i]=new LASreadItemRaw_BYTE(items[i].size); break;
					case LASitem.Type.POINT14: readers_raw[i]=new LASreadItemRaw_POINT14(); break;
					case LASitem.Type.RGBNIR14: readers_raw[i]=new LASreadItemRaw_RGBNIR14(); break;
					default: return false;
				}
				point_size+=items[i].size;
			}

			if(dec!=null)
			{
				readers_compressed=new LASreadItem[num_readers];

				// seeks with compressed data need a seek point
				for(int i=0; i<num_readers; i++)
				{
					switch(items[i].type)
					{
						case LASitem.Type.POINT10:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_POINT10_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_POINT10_v2(dec);
							else return false;
							break;
						case LASitem.Type.GPSTIME11:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_GPSTIME11_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_GPSTIME11_v2(dec);
							else return false;
							break;
						case LASitem.Type.RGB12:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_RGB12_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_RGB12_v2(dec);
							else return false;
							break;
						case LASitem.Type.WAVEPACKET13:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_WAVEPACKET13_v1(dec);
							else return false;
							break;
						case LASitem.Type.BYTE:
							seek_point.extra_bytes=new byte[items[i].size];
							seek_point.num_extra_bytes=items[i].size;
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_BYTE_v1(dec, items[i].size);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_BYTE_v2(dec, items[i].size);
							else return false;
							break;
						default: return false;
					}
				}

				if(laszip.compressor==LASzip.COMPRESSOR_POINTWISE_CHUNKED)
				{
					if(laszip.chunk_size!=0) chunk_size=laszip.chunk_size;
					number_chunks=uint.MaxValue;
				}
			}
			return true;
		}