-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from sPHENIX-Collaboration/bz3compression
Bz2compression
- Loading branch information
Showing
10 changed files
with
223 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include "bz2buffer.h" | ||
#include "oncsBuffer.h" | ||
#include <bzlib.h> | ||
|
||
|
||
// the constructor first ---------------- | ||
bz2buffer::bz2buffer (PHDWORD *array , const int length ) | ||
|
||
{ | ||
|
||
is_good =1; | ||
bufferarray=0; | ||
theBuffer=0; | ||
|
||
unsigned int bytes; | ||
unsigned int outputlength_in_bytes; | ||
if (array[1] == BZ2BUFFERMARKER) | ||
{ | ||
bytes = array[0]-4*BUFFERHEADERLENGTH; | ||
outputlength_in_bytes = array[3]; | ||
} | ||
else if ( u4swap(array[1]) == BZ2BUFFERMARKER ) | ||
{ | ||
bytes = i4swap(array[0])-16; | ||
outputlength_in_bytes = i4swap(array[3]); | ||
} | ||
|
||
else | ||
{ | ||
COUT << __FILE__ << " " << __LINE__ << " wrong buffer marker = " << std::hex << array[1] << std::dec << std::endl; | ||
is_good = 0; | ||
return; | ||
} | ||
|
||
|
||
unsigned int outputlength = (outputlength_in_bytes+3)/4; | ||
bufferarray = new PHDWORD[outputlength]; | ||
|
||
unsigned int olen = 4*outputlength; | ||
|
||
int status = BZ2_bzBuffToBuffDecompress ( (char *) bufferarray, &olen, | ||
( char *) &array[4], bytes, 0, 0 ); | ||
|
||
if ( status || olen != outputlength_in_bytes) | ||
{ | ||
COUT << __FILE__ << " " << __LINE__ << " wrong-sized buffer: " << olen << " should be " << outputlength_in_bytes << std::endl; | ||
is_good = 0; | ||
// delete [] bufferarray; | ||
// bufferarray = 0; | ||
// return; | ||
} | ||
if ( bufferarray[1]== BUFFERMARKER || buffer::u4swap(bufferarray[1])== BUFFERMARKER ) | ||
{ | ||
theBuffer = new prdfBuffer(bufferarray, outputlength); | ||
} | ||
else if ( bufferarray[1]== ONCSBUFFERMARKER || buffer::u4swap(bufferarray[1])== ONCSBUFFERMARKER ) | ||
{ | ||
theBuffer = new oncsBuffer(bufferarray, outputlength); | ||
} | ||
else | ||
{ | ||
theBuffer = 0; | ||
} | ||
} | ||
|
||
// --------------------------------------------------------- | ||
Event * bz2buffer::getEvent() | ||
{ | ||
if ( theBuffer) return theBuffer->getEvent(); | ||
return 0; | ||
} | ||
|
||
// --------------------------------------------------------- | ||
int bz2buffer::getBufferSequence() const | ||
{ | ||
if ( !theBuffer) return 0; | ||
return theBuffer->getBufferSequence(); | ||
} | ||
|
||
// --------------------------------------------------------- | ||
|
||
bz2buffer::~bz2buffer() | ||
{ | ||
if ( theBuffer) delete theBuffer; | ||
if ( bufferarray) delete [] bufferarray; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#ifndef __BZ2BUFFER_H | ||
#define __BZ2BUFFER_H | ||
|
||
#include "prdfBuffer.h" | ||
|
||
#ifndef __CINT__ | ||
class WINDOWSEXPORT bz2buffer : public prdfBuffer{ | ||
#else | ||
class bz2buffer : public prdfBuffer{ | ||
#endif | ||
|
||
public: | ||
|
||
//** Constructors | ||
|
||
bz2buffer( PHDWORD *array, const int length); | ||
~bz2buffer(); | ||
|
||
Event * getEvent(); | ||
|
||
int getBufferSequence() const; | ||
|
||
protected: | ||
|
||
PHDWORD *bufferarray; | ||
buffer *theBuffer; | ||
|
||
int _broken; | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters