-
Notifications
You must be signed in to change notification settings - Fork 26
/
LASreadItemCompressed_BYTE_v2.cs
88 lines (76 loc) · 2.19 KB
/
LASreadItemCompressed_BYTE_v2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//===============================================================================
//
// FILE: lasreaditemcompressed_byte_v2.cs
//
// CONTENTS:
//
// Implementation of LASreadItemCompressed for BYTE items (version 2).
//
// PROGRAMMERS:
//
// [email protected] - http://rapidlasso.com
//
// COPYRIGHT:
//
// (c) 2005-2012, martin isenburg, rapidlasso - tools to catch reality
// (c) of the C# port 2014 by Shinta <[email protected]>
//
// This is free software; you can redistribute and/or modify it under the
// terms of the GNU Lesser General Licence as published by the Free Software
// Foundation. See the COPYING file for more information.
//
// This software is distributed WITHOUT ANY WARRANTY and without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// CHANGE HISTORY: omitted for easier Copy&Paste (pls see the original)
//
//===============================================================================
using System;
using System.Diagnostics;
namespace laszip.net
{
class LASreadItemCompressed_BYTE_v2 : LASreadItemCompressed
{
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 override bool init(laszip_point item)
{
// init state
// init models and integer compressors
for(uint i=0; i<number; i++)
{
dec.initSymbolModel(m_byte[i]);
}
// init last item
Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
return true;
}
public override void read(laszip_point item)
{
for(uint i=0; i<number; i++)
{
int value=(int)(last_item[i]+dec.decodeSymbol(m_byte[i]));
item.extra_bytes[i]=(byte)MyDefs.U8_FOLD(value);
}
Buffer.BlockCopy(item.extra_bytes, 0, last_item, 0, (int)number);
}
ArithmeticDecoder dec;
uint number;
byte[] last_item;
ArithmeticModel[] m_byte;
}
}