---
name: "rq_decode"
section: "3"
platform: "linux"
package: "liblcrq0.0"
version: "0.2.3-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rq_decode"
---

# rq\_decode(3)

decode RaptorQ block

## NAME

rq\_decode - decode RaptorQ block

## SYNOPSIS

```
#include <lcrq.h>
```

**int rq\_decode(rq\_t \****rq***, uint8\_t \****dec***, uint8\_t \****enc***, uint32\_t** *ESI***\[\], uint32\_t** *nesi***);**

Compile and link with *-llcrq*.

## DESCRIPTION

Decodes a RaptorQ block using a variation of the method described in 5.4.2 of RFC6330.

*rq* must be a pointer to valid rq\_t context.

*dec* must be a pointer to a buffer of at least T x K bytes. The decoded data will be written to this buffer.

*enc* a pointer to the encoded block.

*ESI\[\]* ESI index. This is an array of ESIs in the same order as the encoding symbols in *enc*

*nesi* The Loch Ness Monster. Or the number of decoding symbols. Preferably the latter.

## RETURN VALUE

On success, 0 is returned. If decoding fails, the function returns -1.

## EXAMPLE

```
/* symbols are received into enc, with their respective ESIs written to ESI
 * OH is the number of extra (overhead) symbols in addition to the
 * required K' (KP) symbols.
 * Now we can decode the object into the pre-allocated buffer dec.
 */
for (uint8_t sbn = 0; sbn < rq_Z(rq); sbn++) {
	rq_decode(rq, dec, enc[sbn], ESI[sbn], KP + OH);
}
```

## SEE ALSO

[**rq\_init**(3)](/rq_init/3.md), [**rq\_free**(3)](/rq_free/3.md), [**rq\_encode**(3)](/rq_encode/3.md), [**rq\_symbol**(3)](/rq_symbol/3.md), [**lcrq**(7)](/lcrq/7.md)
