mediaframe.mpeg1
Class Huffmann

java.lang.Object
  |
  +--mediaframe.mpeg1.Huffmann

public class Huffmann
extends java.lang.Object

The Huffmann class represents VLC (Hufmann) decoder. It's data base are some arrays which logically constitute a binary tree.


Field Summary
static int[] dct_coeff_len_tab1
          The huffman tree (length part) for the DCT coefficients (huffman index 1...1024).
static int[] dct_coeff_len_tab2
          The huffman tree (length part) for the DCT coefficients (huffman index 1024..65535).
static int[] dct_coeff_val_tab1
          The huffman tree (value part) for the DCT coefficients (huffman index 1...1024).
static int[] dct_coeff_val_tab2
          The huffman tree (length part) for the DCT coefficients (huffman index 1024..65535).
static int DCT_ESCAPE
          DCT_ESCAPE constanta (byte value) in a bit stream.
static int EOB
          End of block constanta (byte value) in a bit stream.
private  io_tool mpeg_stream
          The input movie's data bit stream.
static Tables tables
          The Huffman tables for decoding a bit stream.
 
Constructor Summary
(package private) Huffmann(io_tool stream)
          Constructs a VLC (Hufmann) decoder and loads Huffman tables.
 
Method Summary
 int[] decode(int max_length, int[][] tab)
          The method "decode" is the VLC (Hufmann) decoder.
 int decodeCoeff()
          Decodes one AC coefficient from a bit stream.
static Tables loadTables()
          Loads a Huffman tables from a resource file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mpeg_stream

private io_tool mpeg_stream
The input movie's data bit stream.


tables

public static final Tables tables
The Huffman tables for decoding a bit stream.


DCT_ESCAPE

public static final int DCT_ESCAPE
DCT_ESCAPE constanta (byte value) in a bit stream.

See Also:
Constant Field Values

EOB

public static final int EOB
End of block constanta (byte value) in a bit stream.

See Also:
Constant Field Values

dct_coeff_val_tab1

public static int[] dct_coeff_val_tab1
The huffman tree (value part) for the DCT coefficients (huffman index 1...1024).


dct_coeff_val_tab2

public static int[] dct_coeff_val_tab2
The huffman tree (length part) for the DCT coefficients (huffman index 1024..65535).


dct_coeff_len_tab1

public static int[] dct_coeff_len_tab1
The huffman tree (length part) for the DCT coefficients (huffman index 1...1024).


dct_coeff_len_tab2

public static int[] dct_coeff_len_tab2
The huffman tree (length part) for the DCT coefficients (huffman index 1024..65535).

Constructor Detail

Huffmann

Huffmann(io_tool stream)
Constructs a VLC (Hufmann) decoder and loads Huffman tables.

Parameters:
stream - the input movie's data bit stream.
Method Detail

decode

public final int[] decode(int max_length,
                          int[][] tab)
                   throws java.lang.InterruptedException,
                          java.io.EOFException
The method "decode" is the VLC (Hufmann) decoder. It traverses the "tree" given as parameter till a NIL(-1) index occurs. It returns the decoded value(s). The return type is an array because some VLCs refer to more than 1 result.

Parameters:
max_length - maximum amount of bits that could be readed from a stream to decode values.
tab - the huffman table for decoding bit stream.
Returns:
the decoded value(s).
Throws:
java.lang.InterruptedException - raises if another process interrupts the current process.
EOFException - raises if the end of the file has been reached.

decodeCoeff

public final int decodeCoeff()
                      throws java.lang.InterruptedException,
                             java.io.EOFException
Decodes one AC coefficient from a bit stream.

Returns:
the decoded value.
Throws:
java.lang.InterruptedException - raises if another process interrupts the current process.
EOFException - raises if the end of the file has been reached.

loadTables

public static Tables loadTables()
Loads a Huffman tables from a resource file.

Returns:
the Huffman tables which has been loaded.