/src/assimp/contrib/Open3DGC/o3dgcSC3DMCEncoder.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | Copyright (c) 2013 Khaled Mammou - Advanced Micro Devices, Inc. |
3 | | |
4 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | | of this software and associated documentation files (the "Software"), to deal |
6 | | in the Software without restriction, including without limitation the rights |
7 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
8 | | copies of the Software, and to permit persons to whom the Software is |
9 | | furnished to do so, subject to the following conditions: |
10 | | |
11 | | The above copyright notice and this permission notice shall be included in |
12 | | all copies or substantial portions of the Software. |
13 | | |
14 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
19 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
20 | | THE SOFTWARE. |
21 | | */ |
22 | | |
23 | | |
24 | | #pragma once |
25 | | #ifndef O3DGC_SC3DMC_ENCODER_H |
26 | | #define O3DGC_SC3DMC_ENCODER_H |
27 | | |
28 | | #include "o3dgcCommon.h" |
29 | | #include "o3dgcBinaryStream.h" |
30 | | #include "o3dgcIndexedFaceSet.h" |
31 | | #include "o3dgcSC3DMCEncodeParams.h" |
32 | | #include "o3dgcTriangleListEncoder.h" |
33 | | |
34 | | namespace o3dgc |
35 | | { |
36 | | //! |
37 | | template<class T> |
38 | | class SC3DMCEncoder |
39 | | { |
40 | | public: |
41 | | //! Constructor. |
42 | | SC3DMCEncoder(void) |
43 | 0 | { |
44 | 0 | m_posSize = 0; |
45 | 0 | m_quantFloatArray = 0; |
46 | 0 | m_quantFloatArraySize = 0; |
47 | 0 | m_sizeBufferAC = 0; |
48 | 0 | m_bufferAC = 0; |
49 | 0 | m_normals = 0; |
50 | 0 | m_normalsSize = 0; |
51 | 0 | m_streamType = O3DGC_STREAM_TYPE_UNKOWN; |
52 | 0 | }; |
53 | | //! Destructor. |
54 | | ~SC3DMCEncoder(void) |
55 | 0 | { |
56 | 0 | delete [] m_normals; |
57 | 0 | delete [] m_quantFloatArray; |
58 | 0 | delete [] m_bufferAC; |
59 | 0 | } |
60 | | //! |
61 | | O3DGCErrorCode Encode(const SC3DMCEncodeParams & params, |
62 | | const IndexedFaceSet<T> & ifs, |
63 | | BinaryStream & bstream); |
64 | | const SC3DMCStats & GetStats() const { return m_stats;} |
65 | | |
66 | | private: |
67 | | O3DGCErrorCode EncodeHeader(const SC3DMCEncodeParams & params, |
68 | | const IndexedFaceSet<T> & ifs, |
69 | | BinaryStream & bstream); |
70 | | O3DGCErrorCode EncodePayload(const SC3DMCEncodeParams & params, |
71 | | const IndexedFaceSet<T> & ifs, |
72 | | BinaryStream & bstream); |
73 | | O3DGCErrorCode EncodeFloatArray(const Real * const floatArray, |
74 | | unsigned long numfloatArray, |
75 | | unsigned long dimfloatArray, |
76 | | unsigned long stride, |
77 | | const Real * const minfloatArray, |
78 | | const Real * const maxfloatArray, |
79 | | unsigned long nQBits, |
80 | | const IndexedFaceSet<T> & ifs, |
81 | | O3DGCSC3DMCPredictionMode predMode, |
82 | | BinaryStream & bstream); |
83 | | O3DGCErrorCode QuantizeFloatArray(const Real * const floatArray, |
84 | | unsigned long numFloatArray, |
85 | | unsigned long dimFloatArray, |
86 | | unsigned long stride, |
87 | | const Real * const minfloatArray, |
88 | | const Real * const maxfloatArray, |
89 | | unsigned long nQBits); |
90 | | O3DGCErrorCode EncodeIntArray(const long * const intArray, |
91 | | unsigned long numIntArray, |
92 | | unsigned long dimIntArray, |
93 | | unsigned long stride, |
94 | | const IndexedFaceSet<T> & ifs, |
95 | | O3DGCSC3DMCPredictionMode predMode, |
96 | | BinaryStream & bstream); |
97 | | O3DGCErrorCode ProcessNormals(const IndexedFaceSet<T> & ifs); |
98 | | TriangleListEncoder<T> m_triangleListEncoder; |
99 | | long * m_quantFloatArray; |
100 | | unsigned long m_posSize; |
101 | | unsigned long m_quantFloatArraySize; |
102 | | unsigned char * m_bufferAC; |
103 | | unsigned long m_sizeBufferAC; |
104 | | SC3DMCPredictor m_neighbors [O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS]; |
105 | | unsigned long m_freqSymbols[O3DGC_SC3DMC_MAX_PREDICTION_SYMBOLS]; |
106 | | unsigned long m_freqPreds [O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS]; |
107 | | Vector<long> m_predictors; |
108 | | Real * m_normals; |
109 | | unsigned long m_normalsSize; |
110 | | SC3DMCStats m_stats; |
111 | | O3DGCStreamType m_streamType; |
112 | | }; |
113 | | } |
114 | | #include "o3dgcSC3DMCEncoder.inl" // template implementation |
115 | | #endif // O3DGC_SC3DMC_ENCODER_H |
116 | | |