com.sun.j3d.utils.compression
Class CompressionStreamElement

java.lang.Object
  extended by com.sun.j3d.utils.compression.CompressionStreamElement
Direct Known Subclasses:
CompressionStream.ColorQuant, CompressionStream.MeshReference, CompressionStream.NormalQuant, CompressionStream.PositionQuant, CompressionStreamColor, CompressionStreamNormal, CompressionStreamVertex

abstract class CompressionStreamElement
extends java.lang.Object

Instances of this class are used as elements in a CompressionStream.

See Also:
CompressionStream

Field Summary
(package private)  boolean absolute
          If false, geometric component values are represented as differences from those of the preceding element in the stream.
(package private)  int length
          Bit length of quantized geometric components.
(package private) static long[] lengthMask
          Array with elements that can be used as masks to retain the number of trailing bits of data indicated by the referencing index [0..64].
(package private) static int[] quantizationMask
          Array with elements that can be used as masks to apply a quantization to the number of bits indicated by the referencing index [0..16].
(package private)  int shift
          Number of trailing zeros in quantized geometric components.
 
Constructor Summary
CompressionStreamElement()
           
 
Method Summary
(package private)  void computeLengthShift(int n0, int n1)
          Computes common length and shift of 2 numbers.
(package private)  void computeLengthShift(int n0, int n1, int n2)
          Computes common length and shift of 3 numbers.
(package private)  void computeLengthShift(int n0, int n1, int n2, int n3)
          Computes common length and shift of 4 numbers.
private static int getLength(int number)
          Finds the minimum bits needed to represent the given 16-bit signed 2's complement integer.
private static int getMaximum(int x, int y)
          Finds the maximum of two integers.
private static int getMaximum(int x, int y, int z)
          Finds the maximum of three integers.
private static int getMaximum(int x, int y, int z, int w)
          Finds the maximum of four integers.
private static int getShift(int number)
          Finds the rightmost 1 bit in the given 16-bit integer.
(package private)  void outputCommand(HuffmanTable table, CommandStream output)
          Outputs the compressed bits representing this stream element.
(package private) abstract  void quantize(CompressionStream stream, HuffmanTable table)
          Computes the quantized representation of this stream element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

int length
Bit length of quantized geometric components.


shift

int shift
Number of trailing zeros in quantized geometric components.


absolute

boolean absolute
If false, geometric component values are represented as differences from those of the preceding element in the stream.


quantizationMask

static final int[] quantizationMask
Array with elements that can be used as masks to apply a quantization to the number of bits indicated by the referencing index [0..16].


lengthMask

static final long[] lengthMask
Array with elements that can be used as masks to retain the number of trailing bits of data indicated by the referencing index [0..64]. Used to clear the leading sign bits of fixed-point 2's complement numbers and in building the compressed output stream.

Constructor Detail

CompressionStreamElement

CompressionStreamElement()
Method Detail

quantize

abstract void quantize(CompressionStream stream,
                       HuffmanTable table)
Computes the quantized representation of this stream element.

Parameters:
stream - CompressionStream associated with this element
table - HuffmanTable for collecting data about the quantized representation of this element

outputCommand

void outputCommand(HuffmanTable table,
                   CommandStream output)
Outputs the compressed bits representing this stream element. Some instances of CompressionStreamElement don't require an implementation and will inherit the stub provided here.

Parameters:
table - HuffmanTable mapping quantized representations to compressed encodings
output - CommandStream for collecting compressed output

getLength

private static final int getLength(int number)
Finds the minimum bits needed to represent the given 16-bit signed 2's complement integer. For positive integers, this include the first 1 starting from the left, plus a 0 sign bit; for negative integers, this includes the first 0 starting from the left, plus a 1 sign bit. 0 is a special case returning 0; however, 0-length components are valid ONLY for normals. The decompressor uses the data length to determine how many bits of sign extension to add to the data coming in from the compressed stream in order to create a 16-bit signed 2's complement integer. E.g., a data length of 12 indicates that 16-12=4 bits of sign are to be extended.

Parameters:
number - a signed 2's complement integer representable in 16 bits or less
Returns:
minimum number of bits to represent the number

getShift

private static final int getShift(int number)
Finds the rightmost 1 bit in the given 16-bit integer. This value is used by the decompressor to indicate the number of trailing zeros to be added to the end of the data coming in from the compressed stream, accomplished by left shifting the data by the indicated amount. 0 is a special case returning 0.

Parameters:
number - an integer representable in 16 bits or less
Returns:
number of trailing zeros

computeLengthShift

final void computeLengthShift(int n0,
                              int n1)
Computes common length and shift of 2 numbers.


computeLengthShift

final void computeLengthShift(int n0,
                              int n1,
                              int n2)
Computes common length and shift of 3 numbers.


computeLengthShift

final void computeLengthShift(int n0,
                              int n1,
                              int n2,
                              int n3)
Computes common length and shift of 4 numbers.


getMaximum

private static final int getMaximum(int x,
                                    int y)
Finds the maximum of two integers.


getMaximum

private static final int getMaximum(int x,
                                    int y,
                                    int z)
Finds the maximum of three integers.


getMaximum

private static final int getMaximum(int x,
                                    int y,
                                    int z,
                                    int w)
Finds the maximum of four integers.



Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.