MCPcopy Create free account
hub / github.com/DCMTK/dcmtk / checkTransferSyntax

Method checkTransferSyntax

dcmdata/libsrc/dcitem.cc:169–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167*/
168
169E_TransferSyntax DcmItem::checkTransferSyntax(DcmStream & inStream)
170{
171 Bdebug((3, "dcitem:DcmItem::checkTransferSyntax()" ));
172
173 E_TransferSyntax transferSyntax;
174 char tagAndVR[6];
175 inStream.SetPutbackMark();
176 inStream.ReadBytes(tagAndVR, 6); // check Tag & VR
177 inStream.Putback();
178
179 char c1 = tagAndVR[0];
180 char c2 = tagAndVR[1];
181 char c3 = tagAndVR[2];
182 char c4 = tagAndVR[3];
183 Uint16 t1 = (c1 & 0xff) + ((c2 & 0xff) << 8); // explizite little endian
184 Uint16 t2 = (c3 & 0xff) + ((c4 & 0xff) << 8); // Konversion
185 DcmTag taglittle(t1, t2);
186 DcmTag tagbig(swapShort(t1), swapShort(t2));
187
188 if (taglittle.error() && tagbig.error()) { // no valid tag
189 if (foundVR( &tagAndVR[4])) { // assume little-endian
190 transferSyntax = EXS_LittleEndianExplicit;
191 } else {
192 transferSyntax = EXS_LittleEndianImplicit;
193 }
194 } else {
195 if ( foundVR( &tagAndVR[4] ) ) { // explicit VR
196 if ( taglittle.error() ) {
197 transferSyntax = EXS_BigEndianExplicit;
198 } else if ( tagbig.error() ) {
199 transferSyntax = EXS_LittleEndianExplicit;
200 } else { /* if both are error-free then assume little-endian */
201 transferSyntax = EXS_LittleEndianExplicit;
202 }
203 } else { // implicit VR
204 if ( taglittle.error() ) {
205 transferSyntax = EXS_BigEndianImplicit;
206 } else if ( tagbig.error() ) {
207 transferSyntax = EXS_LittleEndianImplicit;
208 } else { /* if both are error-free then assume little-endian */
209 transferSyntax = EXS_LittleEndianImplicit;
210 }
211 }
212 } // gueltige TransferSyntax
213
214 debug(( 3, "found TransferSyntax(0,2,3)=(%d)", transferSyntax ));
215 Edebug(());
216
217 return transferSyntax;
218} // DcmItem::checkTransferSyntax
219
220
221// ********************************

Callers

nothing calls this directly

Calls 5

swapShortFunction · 0.85
ReadBytesMethod · 0.80
SetPutbackMarkMethod · 0.45
PutbackMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected