Class LDPCFecSession_JNI

java.lang.Object
  |
  +--LDPCFecSession_JNI

class LDPCFecSession_JNI
extends java.lang.Object

This is the FEC session class, where all the context information is kept for encoding/decoding this block. There must be one such FEC session instance per FEC block.

WARNING: the following class contains a lot of checking code that is only available in DEBUG mode (set -DDEBUG on the compiling line of native implementation code).
Whenever used with a new application, first validate your code in DEBUG mode, and switch to production code only in a second step...


Field Summary
static int FLAG_BOTH
          Flag for a coding and decoding session
static int FLAG_CODER
          Flag for a coding session
static int FLAG_DECODER
          Flag for a decoding session
static int LDPC_ERROR
          Ok statut retruned bu functions
static int LDPC_OK
          Error statut retruned bu functions
 int ptr_obj
          Pointer to an instance of native type LDPCFecSession Public for JNI.
static int TypeLDGM
          Codec of type Low Density-Generator Matrix
static int TypeLDPC
          Codec of type Low-Density Parity Check
static int TypeSTAIRS
          Codec of type Stairs
 
Constructor Summary
LDPCFecSession_JNI()
          LDPCFecSession_JNI Contructor.
 
Method Summary
(package private) static void ()
           
 void BuildFecPacket(byte[][] pkt_canvas, int fec_index, byte[] fec_pkt)
          BuildFecPacket: Build a new FEC packet.
 int DecodeFecStep(byte[][] pkt_canvas, byte[] new_packet, int pkt_seqno, boolean store_packet, int context_4_callback)
          DecodeFecStep: Perform a new decoding step with a new (given) packet.
 void EndSession()
          EndSession : Ends the LDPC session, and cleans up everything.
 int InitSession(int nbDataPkt, int nbFecPkt, int pktSize, int flags, int leftDegree, int seed, int codecType)
          InitSession: Initializes the LDPC session.
 boolean IsDecodingComplete(byte[][] pkt_canvas)
          IsDecodingComplete: Checks if all DATA packets have been received/rebuilt.
 boolean IsInitialized()
          IsInitialized: Check if the LDPC session has been initialized.
private  int LDPCFecSession()
           
 void SetVerbosity(int verb)
          Set the verbosity level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

LDPC_OK

public static final int LDPC_OK
Error statut retruned bu functions

LDPC_ERROR

public static final int LDPC_ERROR
Ok statut retruned bu functions

FLAG_CODER

public static final int FLAG_CODER
Flag for a coding session

FLAG_DECODER

public static final int FLAG_DECODER
Flag for a decoding session

FLAG_BOTH

public static final int FLAG_BOTH
Flag for a coding and decoding session

TypeLDPC

public static final int TypeLDPC
Codec of type Low-Density Parity Check

TypeLDGM

public static final int TypeLDGM
Codec of type Low Density-Generator Matrix

TypeSTAIRS

public static final int TypeSTAIRS
Codec of type Stairs

ptr_obj

public int ptr_obj
Pointer to an instance of native type LDPCFecSession Public for JNI.
Constructor Detail

LDPCFecSession_JNI

public LDPCFecSession_JNI()
LDPCFecSession_JNI Contructor.

=> Call native LDPCFecSession Constructor and affect an int pointeur to the member ptr_obj;

Method Detail

static void ()

LDPCFecSession

private int LDPCFecSession()

InitSession

public int InitSession(int nbDataPkt,
                       int nbFecPkt,
                       int pktSize,
                       int flags,
                       int leftDegree,
                       int seed,
                       int codecType)
InitSession: Initializes the LDPC session.
Parameters:
nbDataPkt - (IN) number of DATA packets (i.e. k).
nbFecPkt - (IN) number of FEC packets (i.e. n-k).
pktSize - (IN) packet size in bytes. MUST BE multiple of 4.
flags - (IN) session flags (FLAG_CODER, FLAG_DECODER, ...).
leftDegree - (IN) number of check edges per packet (FEC constraints).
seed - (IN) seed used to build the parity check matrix (H).
codecType - (IN) Type of codec algorithm and matrix to use. Can be on of TypeLDGM, TypeSTAIRS, TypeLDPC
Returns:
Completion status (LDPC_OK or LDPC_ERROR).

EndSession

public void EndSession()
EndSession : Ends the LDPC session, and cleans up everything.

IsInitialized

public boolean IsInitialized()
IsInitialized: Check if the LDPC session has been initialized.
Returns:
TRUE if the session is ready and initialized, FALSE if not.

SetVerbosity

public void SetVerbosity(int verb)
Set the verbosity level.
Parameters:
verb - (IN) new verbosity level (0: no trace, 1: few traces, 2: all traces)

BuildFecPacket

public void BuildFecPacket(byte[][] pkt_canvas,
                           int fec_index,
                           byte[] fec_pkt)
BuildFecPacket: Build a new FEC packet.
Parameters:
pkt_canvas - (IN) Array of source DATA packets. This is a table of n references to objects containing the source packets.
fec_index - (IN) Index of FEC packet to build in {0.. n-k-1} (!) range.
fec_pkt - (IN-OUT)Reference to the FEC packet buffer that will be built. This buffer MUST BE allocated before, but NOT cleared since this function will do it.

DecodeFecStep

public int DecodeFecStep(byte[][] pkt_canvas,
                         byte[] new_packet,
                         int pkt_seqno,
                         boolean store_packet,
                         int context_4_callback)
DecodeFecStep: Perform a new decoding step with a new (given) packet.

This function relies on the following simple algorithm:

Given a set of linear equations, if one of them has only one remaining unknown variable, then the value of this variable is that of the constant term. Replace this variable by its value in all remaining linear equations, and reiterate. The value of several variables can therefore be find by this recursive algorithm.

In practice, an incoming packet contains the value of the associated variable, so replace its value in all linear equations in which it is implicated. Then apply the above algorithm and see if decoding can progress by one or more steps.

For instance, if {s1, s2} are source symbols, and {f1} a FEC symbol:
{ s1 + s2 + f1 = 0 (eq. 1)
{ s2 + f1 = 0 (eq. 2)

Now if the node receives symbol s2, he replaces its value in the two equations, he then finds f1, he replaces its value in the first equation and finds s1.

Parameters:
pkt_canvas - (IN-OUT) Global array of received/rebuilt packets. This is a table of n references to objects. This array must be cleared upon the first call to this function. It will be automatically updated, with pointers to packets received or decoded, by this function.
new_packet - (IN) References to the buffer containing the new packet.
pkt_seqno - (IN) Packet's sequence number in {0.. n-1} range.
store_packet - (IN) true if the function needs to allocate memory, copy the packet content in it, and call any required callback. This is typically done when this function is called recursively, for newly decoded packets.
context_4_callback - (IN) Pointer to context that will be passed to the callback function (if any). This context is not interpreted by this function.
Returns:
Completion status (LDPC_OK or LDPC_ERROR).

IsDecodingComplete

public boolean IsDecodingComplete(byte[][] pkt_canvas)
IsDecodingComplete: Checks if all DATA packets have been received/rebuilt.
Parameters:
pkt_canvas - (IN) Array of received/rebuilt packets.
Returns:
TRUE if all DATA packets have been received or decoded.