示例#1
0
        // Constructor & Deconstructor
        public IntegerCompressor(ArithmeticEncoder enc, uint bits = 16, uint contexts = 1, uint bits_high = 8, uint range = 0)
        {
            Debug.Assert(enc != null);
            this.enc = enc;
            this.dec = null;

            Init(bits, contexts, bits_high, range);
        }
示例#2
0
		// Constructor & Deconstructor
		public IntegerCompressor(ArithmeticEncoder enc, uint bits=16, uint contexts=1, uint bits_high=8, uint range=0)
		{
			Debug.Assert(enc!=null);
			this.enc=enc;
			this.dec=null;

			Init(bits, contexts, bits_high, range);
		}
		public LASwriteItemCompressed_GPSTIME11_v2(ArithmeticEncoder enc)
		{
			// set encoder
			Debug.Assert(enc!=null);
			this.enc=enc;

			// create entropy models and integer compressors
			m_gpstime_multi=enc.createSymbolModel(LASZIP_GPSTIME_MULTI_TOTAL);
			m_gpstime_0diff=enc.createSymbolModel(6);
			ic_gpstime=new IntegerCompressor(enc, 32, 9); // 32 bits, 9 contexts
		}
示例#4
0
        public LASwriteItemCompressed_GPSTIME11_v2(ArithmeticEncoder enc)
        {
            // set encoder
            Debug.Assert(enc != null);
            this.enc = enc;

            // create entropy models and integer compressors
            m_gpstime_multi = enc.createSymbolModel(LASZIP_GPSTIME_MULTI_TOTAL);
            m_gpstime_0diff = enc.createSymbolModel(6);
            ic_gpstime      = new IntegerCompressor(enc, 32, 9);      // 32 bits, 9 contexts
        }
示例#5
0
        public LASwriteItemCompressed_RGB12_v2(ArithmeticEncoder enc)
        {
            // set encoder
            Debug.Assert(enc != null);
            this.enc = enc;

            // create models and integer compressors
            m_byte_used  = enc.createSymbolModel(128);
            m_rgb_diff_0 = enc.createSymbolModel(256);
            m_rgb_diff_1 = enc.createSymbolModel(256);
            m_rgb_diff_2 = enc.createSymbolModel(256);
            m_rgb_diff_3 = enc.createSymbolModel(256);
            m_rgb_diff_4 = enc.createSymbolModel(256);
            m_rgb_diff_5 = enc.createSymbolModel(256);
        }
		public LASwriteItemCompressed_RGB12_v2(ArithmeticEncoder enc)
		{
			// set encoder
			Debug.Assert(enc!=null);
			this.enc=enc;

			// create models and integer compressors
			m_byte_used=enc.createSymbolModel(128);
			m_rgb_diff_0=enc.createSymbolModel(256);
			m_rgb_diff_1=enc.createSymbolModel(256);
			m_rgb_diff_2=enc.createSymbolModel(256);
			m_rgb_diff_3=enc.createSymbolModel(256);
			m_rgb_diff_4=enc.createSymbolModel(256);
			m_rgb_diff_5=enc.createSymbolModel(256);
		}
        public LASwriteItemCompressed_WAVEPACKET13_v1(ArithmeticEncoder enc)
        {
            // set encoder
            Debug.Assert(enc != null);
            this.enc = enc;

            // create models and integer compressors
            m_packet_index   = enc.createSymbolModel(256);
            m_offset_diff[0] = enc.createSymbolModel(4);
            m_offset_diff[1] = enc.createSymbolModel(4);
            m_offset_diff[2] = enc.createSymbolModel(4);
            m_offset_diff[3] = enc.createSymbolModel(4);
            ic_offset_diff   = new IntegerCompressor(enc, 32);
            ic_packet_size   = new IntegerCompressor(enc, 32);
            ic_return_point  = new IntegerCompressor(enc, 32);
            ic_xyz           = new IntegerCompressor(enc, 32, 3);
        }
		public LASwriteItemCompressed_BYTE_v2(ArithmeticEncoder enc, uint number)
		{
			// set encoder
			Debug.Assert(enc!=null);
			this.enc=enc;
			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]=enc.createSymbolModel(256);
			}

			// create last item
			last_item=new byte[number];
		}
示例#9
0
        public LASwriteItemCompressed_BYTE_v2(ArithmeticEncoder enc, uint number)
        {
            // set encoder
            Debug.Assert(enc != null);
            this.enc = enc;
            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] = enc.createSymbolModel(256);
            }

            // create last item
            last_item = new byte[number];
        }
		public LASwriteItemCompressed_POINT10_v2(ArithmeticEncoder enc)
		{
			// set encoder
			Debug.Assert(enc!=null);
			this.enc=enc;

			// create models and integer compressors
			ic_dx=new IntegerCompressor(enc, 32, 2); // 32 bits, 2 context
			ic_dy=new IntegerCompressor(enc, 32, 22); // 32 bits, 22 contexts
			ic_z=new IntegerCompressor(enc, 32, 20); // 32 bits, 20 contexts
			ic_intensity=new IntegerCompressor(enc, 16, 4);
			m_scan_angle_rank[0]=enc.createSymbolModel(256);
			m_scan_angle_rank[1]=enc.createSymbolModel(256);
			ic_point_source_ID=new IntegerCompressor(enc, 16);
			m_changed_values=enc.createSymbolModel(64);
			for(int i=0; i<256; i++)
			{
				m_bit_byte[i]=null;
				m_classification[i]=null;
				m_user_data[i]=null;
			}
		}
示例#11
0
        public LASwriteItemCompressed_POINT10_v2(ArithmeticEncoder enc)
        {
            // set encoder
            Debug.Assert(enc != null);
            this.enc = enc;

            // create models and integer compressors
            ic_dx                = new IntegerCompressor(enc, 32, 2);  // 32 bits, 2 context
            ic_dy                = new IntegerCompressor(enc, 32, 22); // 32 bits, 22 contexts
            ic_z                 = new IntegerCompressor(enc, 32, 20); // 32 bits, 20 contexts
            ic_intensity         = new IntegerCompressor(enc, 16, 4);
            m_scan_angle_rank[0] = enc.createSymbolModel(256);
            m_scan_angle_rank[1] = enc.createSymbolModel(256);
            ic_point_source_ID   = new IntegerCompressor(enc, 16);
            m_changed_values     = enc.createSymbolModel(64);
            for (int i = 0; i < 256; i++)
            {
                m_bit_byte[i]       = null;
                m_classification[i] = null;
                m_user_data[i]      = null;
            }
        }
示例#12
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 encoder (if requested)
			enc=null;
			if(laszip!=null&&laszip.compressor!=0)
			{
				switch(laszip.coder)
				{
					case LASzip.CODER_ARITHMETIC: enc=new ArithmeticEncoder(); break;
					default: return false; // entropy decoder not supported
				}
			}

			// initizalize the writers
			writers=null;
			num_writers=num_items;

			// disable chunking
			chunk_size=uint.MaxValue;

			// always create the raw writers
			writers_raw=new LASwriteItem[num_writers];

			for(uint i=0; i<num_writers; i++)
			{
				switch(items[i].type)
				{
					case LASitem.Type.POINT10: writers_raw[i]=new LASwriteItemRaw_POINT10(); break;
					case LASitem.Type.GPSTIME11: writers_raw[i]=new LASwriteItemRaw_GPSTIME11(); break;
					case LASitem.Type.RGB12: writers_raw[i]=new LASwriteItemRaw_RGB12(); break;
					case LASitem.Type.WAVEPACKET13: writers_raw[i]=new LASwriteItemRaw_WAVEPACKET13(); break;
					case LASitem.Type.BYTE: writers_raw[i]=new LASwriteItemRaw_BYTE(items[i].size); break;
					case LASitem.Type.POINT14: writers_raw[i]=new LASwriteItemRaw_POINT14(); break;
					case LASitem.Type.RGBNIR14: writers_raw[i]=new LASwriteItemRaw_RGBNIR14(); break;
					default: return false;
				}
			}

			// if needed create the compressed writers and set versions
			if(enc!=null)
			{
				writers_compressed=new LASwriteItem[num_writers];

				for(uint i=0; i<num_writers; i++)
				{
					switch(items[i].type)
					{
						case LASitem.Type.POINT10:
							if(items[i].version==1) throw new NotSupportedException("Version 1 POINT10 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_POINT10_v2(enc);
							else return false;
							break;
						case LASitem.Type.GPSTIME11:
							if(items[i].version==1) throw new NotSupportedException("Version 1 GPSTIME11 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_GPSTIME11_v2(enc);
							else return false;
							break;
						case LASitem.Type.RGB12:
							if(items[i].version==1) throw new NotSupportedException("Version 1 RGB12 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_RGB12_v2(enc);
							else return false;
							break;
						case LASitem.Type.WAVEPACKET13:
							if(items[i].version==1) writers_compressed[i]=new LASwriteItemCompressed_WAVEPACKET13_v1(enc);
							else return false;
							break;
						case LASitem.Type.BYTE:
							if(items[i].version==1) throw new NotSupportedException("Version 1 BYTE is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_BYTE_v2(enc, 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;
					chunk_count=0;
					init_chunking=true;
				}
			}

			return true;
		}
示例#13
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 encoder (if requested)
            enc = null;
            if (laszip != null && laszip.compressor != 0)
            {
                switch (laszip.coder)
                {
                case LASzip.CODER_ARITHMETIC: enc = new ArithmeticEncoder(); break;

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

            // initizalize the writers
            writers     = null;
            num_writers = num_items;

            // disable chunking
            chunk_size = uint.MaxValue;

            // always create the raw writers
            writers_raw = new LASwriteItem[num_writers];

            for (uint i = 0; i < num_writers; i++)
            {
                switch (items[i].type)
                {
                case LASitem.Type.POINT10: writers_raw[i] = new LASwriteItemRaw_POINT10(); break;

                case LASitem.Type.GPSTIME11: writers_raw[i] = new LASwriteItemRaw_GPSTIME11(); break;

                case LASitem.Type.RGB12: writers_raw[i] = new LASwriteItemRaw_RGB12(); break;

                case LASitem.Type.WAVEPACKET13: writers_raw[i] = new LASwriteItemRaw_WAVEPACKET13(); break;

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

                case LASitem.Type.POINT14: writers_raw[i] = new LASwriteItemRaw_POINT14(); break;

                case LASitem.Type.RGBNIR14: writers_raw[i] = new LASwriteItemRaw_RGBNIR14(); break;

                default: return(false);
                }
            }

            // if needed create the compressed writers and set versions
            if (enc != null)
            {
                writers_compressed = new LASwriteItem[num_writers];

                for (uint i = 0; i < num_writers; i++)
                {
                    switch (items[i].type)
                    {
                    case LASitem.Type.POINT10:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 POINT10 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_POINT10_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.GPSTIME11:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 GPSTIME11 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_GPSTIME11_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.RGB12:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 RGB12 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_RGB12_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

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

                    case LASitem.Type.BYTE:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 BYTE is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_BYTE_v2(enc, 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;
                    }
                    chunk_count   = 0;
                    init_chunking = true;
                }
            }

            return(true);
        }