d/p/fix_charls_2: Fix compilation with CharLS 2.0
Gert Wollny
5 years ago
0 | Description: Fix compiling with CharLS 2.0 | |
1 | Author: Gert Wollny <gewo@debian.org> | |
2 | ||
3 | diff -ur gdcm/CMakeLists.txt gdcm-2.8.8/CMakeLists.txt | |
4 | --- gdcm/CMakeLists.txt 2019-01-13 08:57:04.807970487 +0100 | |
5 | +++ gdcm-2.8.8/CMakeLists.txt 2019-01-13 08:51:36.459974494 +0100 | |
6 | @@ -368,7 +368,7 @@ | |
7 | ||
8 | if(GDCM_USE_SYSTEM_CHARLS) | |
9 | find_package(CharLS REQUIRED) | |
10 | - set(GDCM_CHARLS_LIBRARIES ${CHARLS_LIBRARIES}) | |
11 | + set(GDCM_CHARLS_LIBRARIES ${CHARLS_LIBRARY}) | |
12 | else() | |
13 | set(GDCM_CHARLS_LIBRARIES gdcmcharls) | |
14 | endif() | |
15 | diff -ur gdcm/Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx gdcm-2.8.8/Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx | |
16 | --- gdcm/Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx 2018-10-28 18:03:34.314814207 +0100 | |
17 | +++ gdcm-2.8.8/Source/MediaStorageAndFileFormat/gdcmJPEGLSCodec.cxx 2019-01-13 08:47:03.239977827 +0100 | |
18 | @@ -22,6 +22,12 @@ | |
19 | // CharLS includes | |
20 | #include "gdcm_charls.h" | |
21 | ||
22 | +#include <cstring> | |
23 | + | |
24 | +using BYTE=unsigned char; | |
25 | +#define ILV_LINE charls::InterleaveMode::Line; | |
26 | +#define ILV_NONE charls::InterleaveMode::None; | |
27 | + | |
28 | #if defined(__GNUC__) && GCC_VERSION < 50101 | |
29 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" | |
30 | #endif | |
31 | @@ -61,7 +67,7 @@ | |
32 | ||
33 | JlsParameters metadata = {}; | |
34 | //assert(buf_size < INT_MAX); | |
35 | - if (JpegLsReadHeader(dummy_buffer, (unsigned int)buf_size, &metadata) != OK) | |
36 | + if (JpegLsReadHeader(dummy_buffer, (unsigned int)buf_size, &metadata, NULL) != charls::ApiResult::OK) | |
37 | { | |
38 | return false; | |
39 | } | |
40 | @@ -71,22 +77,22 @@ | |
41 | ||
42 | this->Dimensions[0] = metadata.width; | |
43 | this->Dimensions[1] = metadata.height; | |
44 | - if( metadata.bitspersample <= 8 ) | |
45 | + if( metadata.bitsPerSample <= 8 ) | |
46 | { | |
47 | this->PF = PixelFormat( PixelFormat::UINT8 ); | |
48 | } | |
49 | - else if( metadata.bitspersample <= 16 ) | |
50 | + else if( metadata.bitsPerSample <= 16 ) | |
51 | { | |
52 | - assert( metadata.bitspersample > 8 ); | |
53 | + assert( metadata.bitsPerSample > 8 ); | |
54 | this->PF = PixelFormat( PixelFormat::UINT16 ); | |
55 | } | |
56 | else | |
57 | { | |
58 | assert(0); | |
59 | } | |
60 | - this->PF.SetBitsStored( (uint16_t)metadata.bitspersample ); | |
61 | + this->PF.SetBitsStored( (uint16_t)metadata.bitsPerSample ); | |
62 | assert( this->PF.IsValid() ); | |
63 | -// switch( metadata.bitspersample ) | |
64 | +// switch( metadata.bitsPerSample ) | |
65 | // { | |
66 | // case 8: | |
67 | // this->PF = PixelFormat( PixelFormat::UINT8 ); | |
68 | @@ -115,9 +121,9 @@ | |
69 | else assert(0); | |
70 | ||
71 | // allowedlossyerror == 0 => Lossless | |
72 | - LossyFlag = metadata.allowedlossyerror != 0; | |
73 | + LossyFlag = metadata.allowedLossyError != 0; | |
74 | ||
75 | - if( metadata.allowedlossyerror == 0 ) | |
76 | + if( metadata.allowedLossyError == 0 ) | |
77 | { | |
78 | ts = TransferSyntax::JPEGLSLossless; | |
79 | } | |
80 | @@ -156,20 +162,20 @@ | |
81 | size_t cbyteCompressed = totalLen; | |
82 | ||
83 | JlsParameters params = {}; | |
84 | - if(JpegLsReadHeader(pbyteCompressed, cbyteCompressed, ¶ms) != OK ) | |
85 | + if(JpegLsReadHeader(pbyteCompressed, cbyteCompressed, ¶ms, NULL) != charls::ApiResult::OK ) | |
86 | { | |
87 | gdcmDebugMacro( "Could not parse JPEG-LS header" ); | |
88 | return false; | |
89 | } | |
90 | ||
91 | - // allowedlossyerror == 0 => Lossless | |
92 | - LossyFlag = params.allowedlossyerror!= 0; | |
93 | + // allowedLossyError == 0 => Lossless | |
94 | + LossyFlag = params.allowedLossyError!= 0; | |
95 | ||
96 | - rgbyteOut.resize(params.height *params.width * ((params.bitspersample + 7) / 8) * params.components); | |
97 | + rgbyteOut.resize(params.height *params.width * ((params.bitsPerSample + 7) / 8) * params.components); | |
98 | ||
99 | - JLS_ERROR result = JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed, ¶ms); | |
100 | + auto result = JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed, ¶ms, NULL); | |
101 | ||
102 | - if (result != OK) | |
103 | + if (result != charls::ApiResult::OK) | |
104 | { | |
105 | gdcmErrorMacro( "Could not decode JPEG-LS stream" ); | |
106 | return false; | |
107 | @@ -229,23 +235,23 @@ | |
108 | size_t cbyteCompressed = totalLen; | |
109 | ||
110 | JlsParameters params = {}; | |
111 | - if( JpegLsReadHeader(pbyteCompressed, cbyteCompressed, ¶ms) != OK ) | |
112 | + if( JpegLsReadHeader(pbyteCompressed, cbyteCompressed, ¶ms, NULL) != charls::ApiResult::OK ) | |
113 | { | |
114 | gdcmDebugMacro( "Could not parse JPEG-LS header" ); | |
115 | return false; | |
116 | } | |
117 | ||
118 | - // allowedlossyerror == 0 => Lossless | |
119 | - LossyFlag = params.allowedlossyerror!= 0; | |
120 | + // allowedLossyError == 0 => Lossless | |
121 | + LossyFlag = params.allowedLossyError!= 0; | |
122 | ||
123 | std::vector<BYTE> rgbyteOut; | |
124 | - rgbyteOut.resize(params.height *params.width * ((params.bitspersample + 7) / 8) * params.components); | |
125 | + rgbyteOut.resize(params.height *params.width * ((params.bitsPerSample + 7) / 8) * params.components); | |
126 | ||
127 | - JLS_ERROR result = JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed, ¶ms); | |
128 | + auto result = JpegLsDecode(&rgbyteOut[0], rgbyteOut.size(), pbyteCompressed, cbyteCompressed, ¶ms, NULL); | |
129 | bool r = true; | |
130 | ||
131 | delete[] mybuffer; | |
132 | - if (result != OK) | |
133 | + if (result != charls::ApiResult::OK) | |
134 | { | |
135 | return false; | |
136 | } | |
137 | @@ -285,7 +291,7 @@ | |
138 | provide the possiblity to tune the JPEG-LS internals for better compression | |
139 | ratios. Expect a lot of work and testing to achieve small improvements. | |
140 | ||
141 | - Lossy/lossless is controlled by the field allowedlossyerror. If you put in | |
142 | + Lossy/lossless is controlled by the field allowedLossyError. If you put in | |
143 | 0, encoding is lossless. If it is non-zero, then encoding is lossy. The | |
144 | value of 3 is often suggested as a default. | |
145 | ||
146 | @@ -305,7 +311,7 @@ | |
147 | that for 12 bit, the encoder fails if the unused bits are non-zero, but the | |
148 | sample dit not suffer from that. | |
149 | */ | |
150 | - params.allowedlossyerror = !LossyFlag ? 0 : LossyError; | |
151 | + params.allowedLossyError = !LossyFlag ? 0 : LossyError; | |
152 | params.components = sample_pixel; | |
153 | // D_CLUNIE_RG3_JPLY.dcm. The famous 16bits allocated / 10 bits stored with the pixel value = 1024 | |
154 | // CharLS properly encode 1024 considering it as 10bits data, so the output | |
155 | @@ -316,28 +322,28 @@ | |
156 | if( true || pf.GetPixelRepresentation() ) | |
157 | { | |
158 | // gdcmData/CT_16b_signed-UsedBits13.dcm | |
159 | - params.bitspersample = bitsallocated; | |
160 | + params.bitsPerSample = bitsallocated; | |
161 | } | |
162 | else | |
163 | { | |
164 | - params.bitspersample = bitsstored; | |
165 | + params.bitsPerSample = bitsstored; | |
166 | } | |
167 | params.height = image_height; | |
168 | params.width = image_width; | |
169 | ||
170 | if (sample_pixel == 4) | |
171 | { | |
172 | - params.ilv = ILV_LINE; | |
173 | + params.interleaveMode = ILV_LINE; | |
174 | } | |
175 | else if (sample_pixel == 3) | |
176 | { | |
177 | - params.ilv = ILV_LINE; | |
178 | - params.colorTransform = COLORXFORM_HP1; | |
179 | + params.interleaveMode = ILV_LINE; | |
180 | + params.colorTransformation = charls::ColorTransformation::HP1; | |
181 | } | |
182 | ||
183 | ||
184 | - JLS_ERROR error = JpegLsEncode(outdata, outlen, &complen, indata, inlen, ¶ms); | |
185 | - if( error != OK ) | |
186 | + auto error = JpegLsEncode(outdata, outlen, &complen, indata, inlen, ¶ms, NULL); | |
187 | + if( error != charls::ApiResult::OK ) | |
188 | { | |
189 | gdcmErrorMacro( "Error compressing: " << (int)error ); | |
190 | return false; | |
191 | diff -ur gdcm/Utilities/gdcm_charls.h gdcm-2.8.8/Utilities/gdcm_charls.h | |
192 | --- gdcm/Utilities/gdcm_charls.h 2018-04-10 09:03:57.874058559 +0200 | |
193 | +++ gdcm-2.8.8/Utilities/gdcm_charls.h 2019-01-13 08:30:27.575989976 +0100 | |
194 | @@ -18,13 +18,7 @@ | |
195 | #include "gdcmTypes.h" | |
196 | #ifdef GDCM_USE_SYSTEM_CHARLS | |
197 | // It is expected that version 1.1.0 is used | |
198 | -# include <CharLS/header.h> | |
199 | -# include <CharLS/interface.h> | |
200 | -# include <CharLS/util.h> | |
201 | -# include <CharLS/defaulttraits.h> | |
202 | -# include <CharLS/losslesstraits.h> | |
203 | -# include <CharLS/colortransform.h> | |
204 | -# include <CharLS/processline.h> | |
205 | +# include <CharLS/charls.h> | |
206 | #else | |
207 | #include "gdcmcharls/header.h" | |
208 | #include "gdcmcharls/interface.h" |