1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Encoding</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Reed-Solomon Library Programming Interface"><link rel="up" href="usage.html" title="Chapter&#160;3.&#160;Usage"><link rel="prev" href="usage.html" title="Chapter&#160;3.&#160;Usage"><link rel="next" href="ch03s03.html" title="Decoding"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Encoding</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="usage.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;3.&#160;Usage</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch03s03.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp1121068148"></a>Encoding</h2></div></div></div><p>
2			The encoder calculates the Reed-Solomon code over
3			the given data length and stores the result in 
4			the parity buffer. Note that the parity buffer must
5			be initialized before calling the encoder.
6		</p><p>
7			The expanded data can be inverted on the fly by
8			providing a non-zero inversion mask. The expanded data is
9			XOR'ed with the mask. This is used e.g. for FLASH
10			ECC, where the all 0xFF is inverted to an all 0x00.
11			The Reed-Solomon code for all 0x00 is all 0x00. The
12			code is inverted before storing to FLASH so it is 0xFF
13			too. This prevents that reading from an erased FLASH
14			results in ECC errors.
15		</p><p>
16			The databytes are expanded to the given symbol size
17			on the fly. There is no support for encoding continuous
18			bitstreams with a symbol size != 8 at the moment. If
19			it is necessary it should be not a big deal to implement
20			such functionality.
21		</p><pre class="programlisting">
22/* Parity buffer. Size = number of roots */
23uint16_t par[6];
24/* Initialize the parity buffer */
25memset(par, 0, sizeof(par));
26/* Encode 512 byte in data8. Store parity in buffer par */
27encode_rs8 (rs_decoder, data8, 512, par, 0);
28		</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="usage.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="usage.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch03s03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&#160;3.&#160;Usage&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Decoding</td></tr></table></div></body></html>
29