com.brownsoft.codec
Class HuffmanMultiplexerBitInputStream

java.lang.Object
  extended bycom.brownsoft.codec.HuffmanMultiplexerBitInputStream

public class HuffmanMultiplexerBitInputStream
extends java.lang.Object

Title: Proyecto Codificacion de Imagenes y Video

Description:

Copyright: Copyright (c) 2004

Company:

Esta clase implementa un bitstream codificado por huffman Se definen 'canales' cada uno de los cuales puede tener su propia tabla de Huffman. Existe un canal especial 'UNENCODED' para el cual no se aplicó la codificación de huffman

Copyright: Copyright (c) 2004

Company:

Version:
1.0
Author:
Gustavo Brown (alegus@adinet.com.uy)

Nested Class Summary
(package private)  class HuffmanMultiplexerBitInputStream.FSMNode
           
 
Field Summary
private  int curByte
           
private  byte curPos
           
static boolean DEBUG
           
private  int elementsLeft
           
private static double LOG_2
           
private static int MAX_CHANNELS
           
private  int nextCurByte
           
private  int nextNextCurByte
           
private static java.lang.StringBuffer NO_DEBUG
           
private  HuffmanMultiplexerBitInputStream.FSMNode[] ROOTs
           
private  java.io.InputStream stream
           
private static int UNENCODED
           
 
Constructor Summary
HuffmanMultiplexerBitInputStream(java.io.InputStream inputStream)
          Construye una instancia a partir de un inputStream
 
Method Summary
private  void addFsmNode(HuffmanMultiplexerBitInputStream.FSMNode node, int symbol, int left)
          Agrega un nodo a la maquina de estados finitos
private  int decode(HuffmanMultiplexerBitInputStream.FSMNode ROOT)
          Ejecuta la maquina de estados para decodificar el próximo caracter
private  int getCantBitsNeeded(int size)
           
 int read(int channel)
          Decodifica un simbolo del stream
private  boolean readBit()
          Lee un bit del stream
private  long readBitStream(int size)
          Lee size bits del bitStream
private  void readDictionaries()
          Lee los diccionarios asociados a esta instancia
private  void readDictionary(HuffmanMultiplexerBitInputStream.FSMNode ROOT)
           
 int readUnencoded(int cantBits)
          Lee cantBits del stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curByte

private int curByte

curPos

private byte curPos

DEBUG

public static boolean DEBUG

elementsLeft

private int elementsLeft

LOG_2

private static final double LOG_2

MAX_CHANNELS

private static final int MAX_CHANNELS
See Also:
Constant Field Values

nextCurByte

private int nextCurByte

nextNextCurByte

private int nextNextCurByte

NO_DEBUG

private static final java.lang.StringBuffer NO_DEBUG

ROOTs

private HuffmanMultiplexerBitInputStream.FSMNode[] ROOTs

stream

private java.io.InputStream stream

UNENCODED

private static final int UNENCODED
See Also:
Constant Field Values
Constructor Detail

HuffmanMultiplexerBitInputStream

public HuffmanMultiplexerBitInputStream(java.io.InputStream inputStream)
                                 throws java.io.IOException
Construye una instancia a partir de un inputStream

Method Detail

addFsmNode

private void addFsmNode(HuffmanMultiplexerBitInputStream.FSMNode node,
                        int symbol,
                        int left)
                 throws java.io.IOException
Agrega un nodo a la maquina de estados finitos

Parameters:
node - el nodeo actual dentro de la FSM
left - cantidad de bits restantes del codeword
Throws:
java.io.IOException

decode

private int decode(HuffmanMultiplexerBitInputStream.FSMNode ROOT)
            throws java.io.IOException
Ejecuta la maquina de estados para decodificar el próximo caracter

Returns:
el caracter decodificado
Throws:
java.io.IOException

getCantBitsNeeded

private int getCantBitsNeeded(int size)

read

public int read(int channel)
         throws java.io.IOException
Decodifica un simbolo del stream

Throws:
java.io.IOException

readBit

private boolean readBit()
                 throws java.io.IOException
Lee un bit del stream

Returns:
boolean indiciando el valor del bit leído
Throws:
java.io.IOException

readBitStream

private long readBitStream(int size)
                    throws java.io.IOException
Lee size bits del bitStream

Parameters:
size - Cantidad de bits a leer
Throws:
java.io.IOException

readDictionaries

private void readDictionaries()
                       throws java.io.IOException
Lee los diccionarios asociados a esta instancia

Throws:
java.io.IOException

readDictionary

private void readDictionary(HuffmanMultiplexerBitInputStream.FSMNode ROOT)
                     throws java.io.IOException
Throws:
java.io.IOException

readUnencoded

public int readUnencoded(int cantBits)
                  throws java.io.IOException
Lee cantBits del stream

Throws:
java.io.IOException