OpenJPEG  1.5.1
Macros | Typedefs | Functions | Variables
rs.c File Reference

Functions used to compute the Reed-Solomon parity and check of byte arrays. More...

#include <stdio.h>
#include <stdlib.h>
#include "rs.h"

Macros

#define B0   0 /* Different from the default 1 */
 
#define A0   (NN)
 
#define CLEAR(a, n)
 
#define COPY(a, b, n)
 
#define COPYDOWN(a, b, n)
 

Typedefs

typedef int gf
 Reed-Solomon coding and decoding Phil Karn (karn@.nosp@m.ka9q.nosp@m..ampr.nosp@m..org) September 1996. More...
 

Functions

static gf modnn (int x)
 
void init_rs (int k)
 Initialization function. More...
 
void generate_gf (void)
 These two functions must be called in this order (e.g., by init_rs()) before any encoding/decoding. More...
 
void gen_poly (void)
 
int encode_rs (dtype *data, dtype *bb)
 
int eras_dec_rs (dtype *data, int *eras_pos, int no_eras)
 

Variables

static int KK
 
int Pp [MM+1] = { 1, 0, 1, 1, 1, 0, 0, 0, 1 }
 
gf Alpha_to [NN+1]
 
gf Index_of [NN+1]
 
gf Gg [NN-1]
 

Detailed Description

Functions used to compute the Reed-Solomon parity and check of byte arrays.

Macro Definition Documentation

#define A0   (NN)

Referenced by encode_rs(), eras_dec_rs(), and generate_gf().

#define B0   0 /* Different from the default 1 */

Referenced by eras_dec_rs(), and gen_poly().

#define CLEAR (   a,
 
)
Value:
{\
int ci;\
for(ci=(n)-1;ci >=0;ci--)\
(a)[ci] = 0;\
}

Referenced by encode_rs(), and eras_dec_rs().

#define COPY (   a,
  b,
 
)
Value:
{\
int ci;\
for(ci=(n)-1;ci >=0;ci--)\
(a)[ci] = (b)[ci];\
}

Referenced by eras_dec_rs().

#define COPYDOWN (   a,
  b,
 
)
Value:
{\
int ci;\
for(ci=(n)-1;ci >=0;ci--)\
(a)[ci] = (b)[ci];\
}

Referenced by eras_dec_rs().

Typedef Documentation

typedef int gf

Reed-Solomon coding and decoding Phil Karn (karn@.nosp@m.ka9q.nosp@m..ampr.nosp@m..org) September 1996.

This file is derived from the program "new_rs_erasures.c" by Robert Morelos-Zaragoza (rober.nosp@m.t@sp.nosp@m.ectra.nosp@m..eng.nosp@m..hawa.nosp@m.ii.e.nosp@m.du) and Hari Thirumoorthy (harit.nosp@m.@spe.nosp@m.ctra..nosp@m.eng..nosp@m.hawai.nosp@m.i.ed.nosp@m.u), Aug 1995

I've made changes to improve performance, clean up the code and make it easier to follow. Data is now passed to the encoding and decoding functions through arguments rather than in global arrays. The decode function returns the number of corrected symbols, or -1 if the word is uncorrectable.

This code supports a symbol size from 2 bits up to 16 bits, implying a block size of 3 2-bit symbols (6 bits) up to 65535 16-bit symbols (1,048,560 bits). The code parameters are set in rs.h.

Note that if symbols larger than 8 bits are used, the type of each data array element switches from unsigned char to unsigned int. The caller must ensure that elements larger than the symbol range are not passed to the encoder or decoder.

Function Documentation

int encode_rs ( dtype data,
dtype bb 
)

References A0, Alpha_to, CLEAR, Gg, Index_of, KK, modnn(), and NN.

Referenced by jpwl_epb_fill().

int eras_dec_rs ( dtype data,
int *  eras_pos,
int  no_eras 
)

References A0, Alpha_to, B0, CLEAR, COPY, COPYDOWN, Index_of, KK, min, modnn(), and NN.

Referenced by jpwl_epb_correct().

void gen_poly ( void  )

References Alpha_to, B0, Gg, Index_of, KK, modnn(), and NN.

Referenced by init_rs().

void generate_gf ( void  )

These two functions must be called in this order (e.g., by init_rs()) before any encoding/decoding.

References A0, Alpha_to, Index_of, MM, NN, and Pp.

Referenced by init_rs().

void init_rs ( int  k)

Initialization function.

References gen_poly(), generate_gf(), KK, and NN.

Referenced by jpwl_epb_correct(), and jpwl_epb_fill().

static gf modnn ( int  x)
static

References MM, and NN.

Referenced by encode_rs(), eras_dec_rs(), and gen_poly().

Variable Documentation

gf Alpha_to[NN+1]
gf Gg[NN-1]

Referenced by encode_rs(), and gen_poly().

gf Index_of[NN+1]
int KK
static
int Pp[MM+1] = { 1, 0, 1, 1, 1, 0, 0, 0, 1 }

Referenced by generate_gf().