Debian Codegraph @

src/LercLib/fpl_Predictor.cpp

raw symbols SCIP
1 /*
2 Copyright 2021 - 2026 Esri
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 A local copy of the license and additional notices are located with the
17 source distribution at:
18
19 http://github.com/Esri/lerc/
20
21 Analytical Raster Compression.
22 Original coding 2021 Yuriy Yakimenko
23 */
24
25 #include "fpl_Predictor.h"
26
27 USING_NAMESPACE_LERC
28
29 int Predictor::getMaxByteDelta (const PredictorType p)
30 {
31 return MAX_DELTA - Predictor::getIntDelta (p);
32 }
33
34 PredictorType Predictor::getType (const char code)
35 {
36 if (code == 0) return PREDICTOR_NONE;
37 if (code == 1) return PREDICTOR_DELTA1;
38 if (code == 2) return PREDICTOR_ROWS_COLS;
39
40 return PREDICTOR_UNKNOWN;
41 }
42
43 unsigned char Predictor::getCode (const PredictorType p)
44 {
45 if (p == PREDICTOR_NONE) return 0;
46 if (p == PREDICTOR_DELTA1) return 1;
47 if (p == PREDICTOR_ROWS_COLS) return 2;
48
49 return -1;
50 }
51
52
53 int Predictor::getIntDelta (const PredictorType p)
54 {
55 switch (p)
56 {
57 case PREDICTOR_NONE:
58 return 0;
59 case PREDICTOR_ROWS_COLS:
60 return 2;
61 case PREDICTOR_DELTA1:
62 return 1;
63 default:
64 return 0;
65 }
66
67 return 0;
68
69 }
70
71 PredictorType Predictor::fromDeltaAndCross (int delta, bool cross)
72 {
73 if (delta < 0)
74 return PREDICTOR_UNKNOWN;
75
76 else if (delta == 0)
77 return PREDICTOR_NONE;
78
79 else if (false == cross)
80 {
81 if (delta == 1)
82 return PREDICTOR_DELTA1;
83 }
84 else
85 {
86 if (delta == 2)
87 return PREDICTOR_ROWS_COLS;
88 }
89
90 return PREDICTOR_UNKNOWN;
91 }