org.javaseis.compress
Class TraceCompressor

java.lang.Object
  extended by org.javaseis.compress.TraceCompressor
All Implemented Interfaces:
java.io.Serializable

public class TraceCompressor
extends java.lang.Object
implements java.io.Serializable

The jsTraceCompressor class provides compression support for (trace) data. For 16 or -8bit compression, the trace is divided into sample windows. The maximum value in each window is used to scale trace samples to 16 or 8-bits. The floating point scalars are stored in the buffer first, followed by the 16 or 8-bit trace samples. Methods are provided to position the buffer for compression or decompression in trace units.

Author:
Chuck Mosher.
See Also:
Serialized Form

Field Summary
protected  byte[] _buffer08
           
protected  int _buffer08LengthInFloats
           
protected  char[] _buffer16
           
protected  int _buffer16LengthInFloats
           
protected  java.nio.ByteBuffer _bufferViewByte
           
protected  java.nio.FloatBuffer _bufferViewFloat
           
protected  java.nio.ShortBuffer _bufferViewShort
           
protected  int _bytesPerSample
           
protected  int _numSamples
           
protected  int _numSamplesX
           
protected  int _numWindows
           
protected  int _recordLengthInBytes
           
protected  int _recordLengthInFloats
           
protected  int _recordLengthInShorts
           
protected  float[] _scalars
           
protected  int _scalarsLengthInBytes
           
protected  int _scalarsLengthInShorts
           
protected  byte[] _traceDataByte
           
protected  short[] _traceDataShort
           
protected  DataFormat _traceFormat
           
protected  int _tracePosition
           
protected static int CLIPPING_MAX_INT08
           
protected static int CLIPPING_MAX_INT16
           
protected static int CLIPPING_MIN_INT08
           
protected static int CLIPPING_MIN_INT16
           
protected static int WNDWLEN08
           
protected static int WNDWLEN16
           
 
Constructor Summary
TraceCompressor(DataFormat traceFormat, int numSamples, java.nio.ByteBuffer bufferByte)
          Constructs an instace of jsTraceCompressor.
 
Method Summary
protected  void arrayCopyByteToFloat(int numSamples, byte[] traceIn, float[] traceOut)
          Copies trace data from byte array to float array.
protected  void arrayCopyFloatToByte(int numSamples, float[] traceIn, byte[] traceOut)
          Copies trace data from float array to byte array (clipping if necessary).
protected  void arrayCopyFloatToShort(int numSamples, float[] traceIn, short[] traceOut)
          Copies trac edata from byte array to float array.
protected  void arrayCopyShortToFloat(int numSamples, short[] traceIn, float[] traceOut)
          Copies trace data from short array to float array.
 int getPosition()
          Gets the buffer position in trace units.
static int getRecordLength(DataFormat traceFormat, int numSamples)
          Gets the record length in bytes.
static void main(java.lang.String[] args)
          The "main" method used for testing.
 void packFrame(int numTraces, float[][] traceData)
          Packs frame data into compression buffer.
 void packTrace(float[] traceData)
          Packs trace data into DataFormat.FLOAT,INT16,INT08 buffer.
 void packTrace08(float[] traceData)
          Packs trace data into DataFormat.COMPRESSED_INT08 buffer.
 void packTrace16(float[] traceData)
          Packs trace data into DataFormat.COMPRESSED_INT16 buffer.
 int setPosition(int tracePosition)
          Sets the buffer position in trace units.
 void unpackFrame(int numTraces, float[][] traceData)
          Unpacks frame data from compression buffer.
 void unpackTrace(float[] traceData)
          Unpacks trace data from DataFormat.FLOAT,INT16,INT08 buffer.
 void unpackTrace08(float[] traceData)
          Unpacks trace data from DataFormat.COMPRESSED_INT08 buffer.
 void unpackTrace16(float[] traceData)
          Unpacks trace data from DataFormat.COMPRESSED_INT16 buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_buffer08

protected byte[] _buffer08

_buffer08LengthInFloats

protected int _buffer08LengthInFloats

_buffer16

protected char[] _buffer16

_buffer16LengthInFloats

protected int _buffer16LengthInFloats

_bufferViewByte

protected java.nio.ByteBuffer _bufferViewByte

_bufferViewFloat

protected java.nio.FloatBuffer _bufferViewFloat

_bufferViewShort

protected java.nio.ShortBuffer _bufferViewShort

_bytesPerSample

protected int _bytesPerSample

_numSamples

protected int _numSamples

_numSamplesX

protected int _numSamplesX

_numWindows

protected int _numWindows

_recordLengthInBytes

protected int _recordLengthInBytes

_recordLengthInFloats

protected int _recordLengthInFloats

_recordLengthInShorts

protected int _recordLengthInShorts

_scalars

protected float[] _scalars

_scalarsLengthInBytes

protected int _scalarsLengthInBytes

_scalarsLengthInShorts

protected int _scalarsLengthInShorts

_traceDataByte

protected byte[] _traceDataByte

_traceDataShort

protected short[] _traceDataShort

_traceFormat

protected DataFormat _traceFormat

_tracePosition

protected int _tracePosition

CLIPPING_MAX_INT08

protected static final int CLIPPING_MAX_INT08
See Also:
Constant Field Values

CLIPPING_MAX_INT16

protected static final int CLIPPING_MAX_INT16
See Also:
Constant Field Values

CLIPPING_MIN_INT08

protected static final int CLIPPING_MIN_INT08
See Also:
Constant Field Values

CLIPPING_MIN_INT16

protected static final int CLIPPING_MIN_INT16
See Also:
Constant Field Values

WNDWLEN08

protected static int WNDWLEN08

WNDWLEN16

protected static int WNDWLEN16
Constructor Detail

TraceCompressor

public TraceCompressor(DataFormat traceFormat,
                       int numSamples,
                       java.nio.ByteBuffer bufferByte)
Constructs an instace of jsTraceCompressor.

Parameters:
traceFormat - The format type (i.e. DataFormat.INT16, etc).
numSamples - The number of samples per trace.
bufferByte - The buffer used to store compressed trace data.
Method Detail

arrayCopyByteToFloat

protected void arrayCopyByteToFloat(int numSamples,
                                    byte[] traceIn,
                                    float[] traceOut)
Copies trace data from byte array to float array.

Parameters:
numSamples - The number of samples in the arrays.
traceIn - The input byte array.
traceOut - The output float array.

arrayCopyFloatToByte

protected void arrayCopyFloatToByte(int numSamples,
                                    float[] traceIn,
                                    byte[] traceOut)
Copies trace data from float array to byte array (clipping if necessary).

Parameters:
numSamples - The number of samples in the arrays.
traceIn - The input float array.
traceOut - The output byte array.

arrayCopyFloatToShort

protected void arrayCopyFloatToShort(int numSamples,
                                     float[] traceIn,
                                     short[] traceOut)
Copies trac edata from byte array to float array.

Parameters:
numSamples - The number of samples in the arrays.
traceIn - The input byte array.
traceOut - The output float array.

arrayCopyShortToFloat

protected void arrayCopyShortToFloat(int numSamples,
                                     short[] traceIn,
                                     float[] traceOut)
Copies trace data from short array to float array.

Parameters:
numSamples - The number of samples in the arrays.
traceIn - The input short array.
traceOut - The output float array.

getPosition

public int getPosition()
Gets the buffer position in trace units.

Returns:
The buffer position in trace units.

getRecordLength

public static int getRecordLength(DataFormat traceFormat,
                                  int numSamples)
                           throws SeisException
Gets the record length in bytes.

Parameters:
traceFormat - The trace format.
numSamples - The number of samples per trace.
Returns:
The record length in bytes.
Throws:
SeisException

main

public static void main(java.lang.String[] args)
                 throws SeisException
The "main" method used for testing.

Parameters:
args - The arguments for testing.
Throws:
SeisException - Thrown on testing errors.

packFrame

public void packFrame(int numTraces,
                      float[][] traceData)
Packs frame data into compression buffer.

Parameters:
traceData - The array of frame data to compress.

packTrace

public void packTrace(float[] traceData)
Packs trace data into DataFormat.FLOAT,INT16,INT08 buffer.

Parameters:
traceData - The array of trace data to compress.

packTrace08

public void packTrace08(float[] traceData)
Packs trace data into DataFormat.COMPRESSED_INT08 buffer.

Parameters:
traceData - The array of trace data to compress.

packTrace16

public void packTrace16(float[] traceData)
Packs trace data into DataFormat.COMPRESSED_INT16 buffer.

Parameters:
traceData - The array of trace data to compress.

setPosition

public int setPosition(int tracePosition)
Sets the buffer position in trace units.

Parameters:
tracePosition - The desired buffer position in trace units.
Returns:
The buffer position in trace units.

unpackFrame

public void unpackFrame(int numTraces,
                        float[][] traceData)
Unpacks frame data from compression buffer.

Parameters:
traceData - The array to contain decompressed frame data.

unpackTrace

public void unpackTrace(float[] traceData)
Unpacks trace data from DataFormat.FLOAT,INT16,INT08 buffer.

Parameters:
traceData - The array to contain decompressed trace data.

unpackTrace08

public void unpackTrace08(float[] traceData)
Unpacks trace data from DataFormat.COMPRESSED_INT08 buffer.

Parameters:
traceData - The array to contain decompressed trace data.

unpackTrace16

public void unpackTrace16(float[] traceData)
Unpacks trace data from DataFormat.COMPRESSED_INT16 buffer.

Parameters:
traceData - The array to contain decompressed trace data.