\doxysection{conv.\+h}
\label{conv_8h_source}\index{include/osmocom/core/conv.h@{include/osmocom/core/conv.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 }
\DoxyCodeLine{3 \textcolor{comment}{/*}}
\DoxyCodeLine{4 \textcolor{comment}{ * Copyright (C) 2011  Sylvain Munaut <tnt@246tNt.com>}}
\DoxyCodeLine{5 \textcolor{comment}{ *}}
\DoxyCodeLine{6 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{7 \textcolor{comment}{ *}}
\DoxyCodeLine{8 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{9 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{10 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{11 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{14 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{15 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{16 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{17 \textcolor{comment}{ */}}
\DoxyCodeLine{18 }
\DoxyCodeLine{23 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{26 }
\DoxyCodeLine{27 \textcolor{preprocessor}{\#include <osmocom/core/bits.h>}}
\DoxyCodeLine{28 }
\DoxyCodeLine{36 \textcolor{keyword}{enum} osmo\_conv\_term \{}
\DoxyCodeLine{37         CONV\_TERM\_FLUSH = 0,     }
\DoxyCodeLine{38         CONV\_TERM\_TRUNCATION,       }
\DoxyCodeLine{39         CONV\_TERM\_TAIL\_BITING,     }
\DoxyCodeLine{40 \};}
\DoxyCodeLine{41 }
\DoxyCodeLine{48 \textcolor{keyword}{struct }osmo\_conv\_code \{}
\DoxyCodeLine{49         \textcolor{keywordtype}{int} N;                         }
\DoxyCodeLine{50         \textcolor{keywordtype}{int} K;                         }
\DoxyCodeLine{51         \textcolor{keywordtype}{int} len;                     }
\DoxyCodeLine{53         \textcolor{keyword}{enum} osmo\_conv\_term term;     }
\DoxyCodeLine{55         \textcolor{keyword}{const} uint8\_t (*next\_output)[2];}
\DoxyCodeLine{56         \textcolor{keyword}{const} uint8\_t (*next\_state)[2];       }
\DoxyCodeLine{58         \textcolor{keyword}{const} uint8\_t *next\_term\_output;}
\DoxyCodeLine{59         \textcolor{keyword}{const} uint8\_t *next\_term\_state;  }
\DoxyCodeLine{61         \textcolor{keyword}{const} \textcolor{keywordtype}{int} *puncture;            }
\DoxyCodeLine{62 \};}
\DoxyCodeLine{63 }
\DoxyCodeLine{64 }
\DoxyCodeLine{65 \textcolor{comment}{/* Common */}}
\DoxyCodeLine{66 }
\DoxyCodeLine{67 \textcolor{keywordtype}{int} osmo\_conv\_get\_input\_length(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code, \textcolor{keywordtype}{int} len);}
\DoxyCodeLine{68 \textcolor{keywordtype}{int} osmo\_conv\_get\_output\_length(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code, \textcolor{keywordtype}{int} len);}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 }
\DoxyCodeLine{71 \textcolor{comment}{/* Encoding */}}
\DoxyCodeLine{72 }
\DoxyCodeLine{73         \textcolor{comment}{/* Low level API */}}
\DoxyCodeLine{74 }
\DoxyCodeLine{76 \textcolor{keyword}{struct }osmo\_conv\_encoder \{}
\DoxyCodeLine{77         \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_conv\_code *code; }
\DoxyCodeLine{78         \textcolor{keywordtype}{int} i\_idx; }
\DoxyCodeLine{79         \textcolor{keywordtype}{int} p\_idx; }
\DoxyCodeLine{80         uint8\_t state;     }
\DoxyCodeLine{81 \};}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 \textcolor{keywordtype}{void} osmo\_conv\_encode\_init(\textcolor{keyword}{struct} osmo\_conv\_encoder *encoder,}
\DoxyCodeLine{84                            \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code);}
\DoxyCodeLine{85 \textcolor{keywordtype}{void} osmo\_conv\_encode\_load\_state(\textcolor{keyword}{struct} osmo\_conv\_encoder *encoder,}
\DoxyCodeLine{86                                  \textcolor{keyword}{const} ubit\_t *input);}
\DoxyCodeLine{87 \textcolor{keywordtype}{int}  osmo\_conv\_encode\_raw(\textcolor{keyword}{struct} osmo\_conv\_encoder *encoder,}
\DoxyCodeLine{88                           \textcolor{keyword}{const} ubit\_t *input, ubit\_t *output, \textcolor{keywordtype}{int} n);}
\DoxyCodeLine{89 \textcolor{keywordtype}{int}  osmo\_conv\_encode\_flush(\textcolor{keyword}{struct} osmo\_conv\_encoder *encoder, ubit\_t *output);}
\DoxyCodeLine{90 }
\DoxyCodeLine{91         \textcolor{comment}{/* All-\/in-\/one */}}
\DoxyCodeLine{92 \textcolor{keywordtype}{int}  osmo\_conv\_encode(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code,}
\DoxyCodeLine{93                       \textcolor{keyword}{const} ubit\_t *input, ubit\_t *output);}
\DoxyCodeLine{94 }
\DoxyCodeLine{95 }
\DoxyCodeLine{96 \textcolor{comment}{/* Decoding */}}
\DoxyCodeLine{97 }
\DoxyCodeLine{98         \textcolor{comment}{/* Low level API */}}
\DoxyCodeLine{99 }
\DoxyCodeLine{101 \textcolor{keyword}{struct }osmo\_conv\_decoder \{}
\DoxyCodeLine{102         \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_conv\_code *code; }
\DoxyCodeLine{104         \textcolor{keywordtype}{int} n\_states;           }
\DoxyCodeLine{106         \textcolor{keywordtype}{int} len;             }
\DoxyCodeLine{108         \textcolor{keywordtype}{int} o\_idx;         }
\DoxyCodeLine{109         \textcolor{keywordtype}{int} p\_idx;         }
\DoxyCodeLine{111         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} *ae;     }
\DoxyCodeLine{112         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} *ae\_next;   }
\DoxyCodeLine{113         uint8\_t *state\_history;    }
\DoxyCodeLine{114 \};}
\DoxyCodeLine{115 }
\DoxyCodeLine{116 \textcolor{keywordtype}{void} osmo\_conv\_decode\_init(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder,}
\DoxyCodeLine{117                            \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code,}
\DoxyCodeLine{118                            \textcolor{keywordtype}{int} len, \textcolor{keywordtype}{int} start\_state);}
\DoxyCodeLine{119 \textcolor{keywordtype}{void} osmo\_conv\_decode\_reset(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder, \textcolor{keywordtype}{int} start\_state);}
\DoxyCodeLine{120 \textcolor{keywordtype}{void} osmo\_conv\_decode\_rewind(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder);}
\DoxyCodeLine{121 \textcolor{keywordtype}{void} osmo\_conv\_decode\_deinit(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder);}
\DoxyCodeLine{122 }
\DoxyCodeLine{123 \textcolor{keywordtype}{int} osmo\_conv\_decode\_scan(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder,}
\DoxyCodeLine{124                           \textcolor{keyword}{const} sbit\_t *input, \textcolor{keywordtype}{int} n);}
\DoxyCodeLine{125 \textcolor{keywordtype}{int} osmo\_conv\_decode\_flush(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder,}
\DoxyCodeLine{126                            \textcolor{keyword}{const} sbit\_t *input);}
\DoxyCodeLine{127 \textcolor{keywordtype}{int} osmo\_conv\_decode\_get\_best\_end\_state(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder);}
\DoxyCodeLine{128 \textcolor{keywordtype}{int} osmo\_conv\_decode\_get\_output(\textcolor{keyword}{struct} osmo\_conv\_decoder *decoder,}
\DoxyCodeLine{129                                 ubit\_t *output, \textcolor{keywordtype}{int} has\_flush, \textcolor{keywordtype}{int} end\_state);}
\DoxyCodeLine{130 }
\DoxyCodeLine{131         \textcolor{comment}{/* All-\/in-\/one */}}
\DoxyCodeLine{132 \textcolor{keywordtype}{int} osmo\_conv\_decode(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_conv\_code *code,}
\DoxyCodeLine{133                      \textcolor{keyword}{const} sbit\_t *input, ubit\_t *output);}
\DoxyCodeLine{134 }
\DoxyCodeLine{135 }

\end{DoxyCode}
