1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Decoding</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 3. Usage"><link rel="prev" href="ch03s02.html" title="Encoding"><link rel="next" href="ch03s04.html" title="Cleanup"></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">Decoding</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Usage</th><td width="20%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="idp1121070604"></a>Decoding</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="ch03s03.html#idp1121072492"> 2 Decoding with syndrome calculation, direct data correction 3 </a></span></dt><dt><span class="sect2"><a href="ch03s03.html#idp1121073572"> 4 Decoding with syndrome given by hardware decoder, direct data correction 5 </a></span></dt><dt><span class="sect2"><a href="ch03s03.html#idp1121074700"> 6 Decoding with syndrome given by hardware decoder, no direct data correction. 7 </a></span></dt></dl></div><p> 8 The decoder calculates the syndrome over 9 the given data length and the received parity symbols 10 and corrects errors in the data. 11 </p><p> 12 If a syndrome is available from a hardware decoder 13 then the syndrome calculation is skipped. 14 </p><p> 15 The correction of the data buffer can be suppressed 16 by providing a correction pattern buffer and an error 17 location buffer to the decoder. The decoder stores the 18 calculated error location and the correction bitmask 19 in the given buffers. This is useful for hardware 20 decoders which use a weird bit ordering scheme. 21 </p><p> 22 The databytes are expanded to the given symbol size 23 on the fly. There is no support for decoding continuous 24 bitstreams with a symbolsize != 8 at the moment. If 25 it is necessary it should be not a big deal to implement 26 such functionality. 27 </p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="idp1121072492"></a> 28 Decoding with syndrome calculation, direct data correction 29 </h3></div></div></div><pre class="programlisting"> 30/* Parity buffer. Size = number of roots */ 31uint16_t par[6]; 32uint8_t data[512]; 33int numerr; 34/* Receive data */ 35..... 36/* Receive parity */ 37..... 38/* Decode 512 byte in data8.*/ 39numerr = decode_rs8 (rs_decoder, data8, par, 512, NULL, 0, NULL, 0, NULL); 40 </pre></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="idp1121073572"></a> 41 Decoding with syndrome given by hardware decoder, direct data correction 42 </h3></div></div></div><pre class="programlisting"> 43/* Parity buffer. Size = number of roots */ 44uint16_t par[6], syn[6]; 45uint8_t data[512]; 46int numerr; 47/* Receive data */ 48..... 49/* Receive parity */ 50..... 51/* Get syndrome from hardware decoder */ 52..... 53/* Decode 512 byte in data8.*/ 54numerr = decode_rs8 (rs_decoder, data8, par, 512, syn, 0, NULL, 0, NULL); 55 </pre></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="idp1121074700"></a> 56 Decoding with syndrome given by hardware decoder, no direct data correction. 57 </h3></div></div></div><p> 58 Note: It's not necessary to give data and received parity to the decoder. 59 </p><pre class="programlisting"> 60/* Parity buffer. Size = number of roots */ 61uint16_t par[6], syn[6], corr[8]; 62uint8_t data[512]; 63int numerr, errpos[8]; 64/* Receive data */ 65..... 66/* Receive parity */ 67..... 68/* Get syndrome from hardware decoder */ 69..... 70/* Decode 512 byte in data8.*/ 71numerr = decode_rs8 (rs_decoder, NULL, NULL, 512, syn, 0, errpos, 0, corr); 72for (i = 0; i < numerr; i++) { 73 do_error_correction_in_your_buffer(errpos[i], corr[i]); 74} 75 </pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03s02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="usage.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Encoding </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Cleanup</td></tr></table></div></body></html> 76