CADI.Common.LogicalTarget.JPEG2000.Decode
Class RawDecoder

java.lang.Object
  extended by CADI.Common.LogicalTarget.JPEG2000.Decode.RawDecoder
All Implemented Interfaces:
Decoder

public class RawDecoder
extends java.lang.Object
implements Decoder

This class decodes bits from a compatible JPEG2000 codestream (without encoded with the MQ), i.e. when a byte 0xFF is found, the first bit of the following byte is skipped. This class could be used when encoding using the bypass mode of JPEG2000 or in other situations, for instance when decoding the packet headers. Usge example:
  construct
  decodeBit
  decodeBit
  swapInputByteStream
  restart
  decodeBit
  decodeBit
  ...

Version:
1.0
Author:
Group on Interactive Coding of Images (GICI)

Field Summary
private  boolean foundFF
          Flag used to know if a byte with a value of 0xFF has been found.
private  ByteStream inputByteStream
          Bytestream from which the MQ decoder reads data.
private  int L
          Byte position to be read from the inputByteStream.
private  int t
          Number of bits to transfer (down counter).
private  int Tr
          Byte to transfer.
 
Constructor Summary
RawDecoder()
          Constructor that does not initializes nothing.
RawDecoder(ByteStream inputByteStream)
          Constructor that initializes the internal registers and outputByteStream.
 
Method Summary
 boolean decodeBit()
          Decode a bit.
 boolean decodeBit(int context)
          Decode a bit using some context.
 void reset()
          For compatibility.
 void restart()
          Fills the Tr register.
 void swapInputByteStream(ByteStream inputByteStream)
          Swaps the current inputByteStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputByteStream

private ByteStream inputByteStream
Bytestream from which the MQ decoder reads data.

The content must be understood as a ByteStream.


t

private int t
Number of bits to transfer (down counter).

Usually it is initialized to 8, then count down until 0.


Tr

private int Tr
Byte to transfer.

Byte flushed to the outputByteStream.


L

private int L
Byte position to be read from the inputByteStream.

Only positive values allowed. The first byte is 0.


foundFF

private boolean foundFF
Flag used to know if a byte with a value of 0xFF has been found. In this case a new byte is readed from the bytestream although it does not be used.

True when a 0xFF byte is found.

Constructor Detail

RawDecoder

public RawDecoder()
Constructor that does not initializes nothing. Before to use this class you should call the swapInputByteStream function.


RawDecoder

public RawDecoder(ByteStream inputByteStream)
           throws ErrorException
Constructor that initializes the internal registers and outputByteStream.

Parameters:
inputByteStream - the input stream of bytes
Throws:
ErrorException - when end of ByteStream is reached
Method Detail

decodeBit

public boolean decodeBit()
                  throws ErrorException
Decode a bit.

Specified by:
decodeBit in interface Decoder
Returns:
a boolean indicating the bit decoded
Throws:
ErrorException - when end of ByteStream is reached

decodeBit

public boolean decodeBit(int context)
                  throws ErrorException
Decode a bit using some context. The context is not used (this function is only for compatibility).

Specified by:
decodeBit in interface Decoder
Parameters:
context - a byte that indicates the context of the decoded bit
Returns:
a boolean indicating the bit decoded
Throws:
ErrorException - when end of ByteStream is reached

swapInputByteStream

public void swapInputByteStream(ByteStream inputByteStream)
Swaps the current inputByteStream. After calling this function you should call the restart function.

Specified by:
swapInputByteStream in interface Decoder
Parameters:
inputByteStream - the input stream of bytes

restart

public void restart()
             throws ErrorException
Fills the Tr register. This function should be called every time a new ByteStream is passed to the decoder.

Specified by:
restart in interface Decoder
Throws:
ErrorException - for compatibility

reset

public void reset()
For compatibility.

Specified by:
reset in interface Decoder


CADI - Copyright (C) 2007
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Group on Interactive Coding of Images (GICI) (contact)