\doxysection{src/codec/gsm620.c File Reference}
\label{gsm620_8c}\index{src/codec/gsm620.c@{src/codec/gsm620.c}}


GSM 06.\+20 -\/ GSM HR codec.  


{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/codec/codec.\+h$>$}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
bool \textbf{ osmo\+\_\+hr\+\_\+check\+\_\+sid} (const uint8\+\_\+t $\ast$rtp\+\_\+payload, size\+\_\+t payload\+\_\+len)
\begin{DoxyCompactList}\small\item\em Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.\+2. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+hr\+\_\+sid\+\_\+reset} (uint8\+\_\+t $\ast$rtp\+\_\+payload)
\begin{DoxyCompactList}\small\item\em Reset the SID field of a potentially corrupted, but still valid GSM-\/\+HR SID frame in TS 101 318 format to its pristine state (full SID codeword). \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const uint16\+\_\+t \textbf{ gsm620\+\_\+unvoiced\+\_\+bitorder} [112]
\item 
const uint16\+\_\+t \textbf{ gsm620\+\_\+voiced\+\_\+bitorder} [112]
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
GSM 06.\+20 -\/ GSM HR codec. 



\doxysubsection{Function Documentation}
\mbox{\label{gsm620_8c_ad9b2ad0ca9540027568e398ca070f645}} 
\index{gsm620.c@{gsm620.c}!osmo\_hr\_check\_sid@{osmo\_hr\_check\_sid}}
\index{osmo\_hr\_check\_sid@{osmo\_hr\_check\_sid}!gsm620.c@{gsm620.c}}
\doxysubsubsection{osmo\_hr\_check\_sid()}
{\footnotesize\ttfamily bool osmo\+\_\+hr\+\_\+check\+\_\+sid (\begin{DoxyParamCaption}\item[{const uint8\+\_\+t $\ast$}]{rtp\+\_\+payload,  }\item[{size\+\_\+t}]{payload\+\_\+len }\end{DoxyParamCaption})}



Check whether RTP frame contains HR SID code word according to TS 101 318 §5.2.\+2. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rtp\+\_\+payload} & Buffer with RTP payload \\
\hline
\mbox{\texttt{ in}}  & {\em payload\+\_\+len} & Length of payload \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
true if code word is found, false otherwise
\end{DoxyReturn}
Note that this function checks only for a perfect, error-\/free SID. Unlike GSM 06.\+31 for FR or GSM 06.\+81 for EFR, GSM 06.\+41 spec for HR does not prescribe exact bit counting rules, hence detection of partially corrupted SID frames in downstream network elements without out-\/of-\/band indication is not possible. 

References \textbf{ GSM\+\_\+\+HR\+\_\+\+BYTES}.

\mbox{\label{gsm620_8c_aa688d31df81d12d01065c55b8d1b788a}} 
\index{gsm620.c@{gsm620.c}!osmo\_hr\_sid\_reset@{osmo\_hr\_sid\_reset}}
\index{osmo\_hr\_sid\_reset@{osmo\_hr\_sid\_reset}!gsm620.c@{gsm620.c}}
\doxysubsubsection{osmo\_hr\_sid\_reset()}
{\footnotesize\ttfamily void osmo\+\_\+hr\+\_\+sid\+\_\+reset (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rtp\+\_\+payload }\end{DoxyParamCaption})}



Reset the SID field of a potentially corrupted, but still valid GSM-\/\+HR SID frame in TS 101 318 format to its pristine state (full SID codeword). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rtp\+\_\+payload} & Buffer with RTP payload -\/ must be writable!\\
\hline
\end{DoxyParams}
Per GSM 06.\+22 section 5.\+3, a freshly minted SID frame consists of 33 bits of comfort noise parameters and 79 bits of SID codeword (all 1s). Network elements that receive SID frames from call leg A uplink and need to retransmit them on leg B downlink should \char`\"{}rejuvenate\char`\"{} received SID frames prior to retransmission by resetting the SID field to its pristine state of all 1s; this function does the job.

Important note\+: because of HR-\/specific quirks (lack of exact bit counting rules in GSM 06.\+41 spec compared to 06.\+31 \& 06.\+81, plus the fact that such bit counting can only be done efficiently in the GSM 05.\+03 channel decoder prior to bit reordering based on voiced or unvoiced mode), a generic (usable from any network element) SID classification function similar to osmo\+\_\+\{fr,efr\}\+\_\+sid\+\_\+classify() unfortunately cannot exist for HR. Therefore, the triggering condition for invoking this SID rejuvenation/reset function can only be an out-\/of-\/band SID indication, as in GSM 08.\+61 TRAU frames or RFC 5993 ToC octet. 

\doxysubsection{Variable Documentation}
\mbox{\label{gsm620_8c_a16456fc7f3ab196a607f56c3fbaf044e}} 
\index{gsm620.c@{gsm620.c}!gsm620\_unvoiced\_bitorder@{gsm620\_unvoiced\_bitorder}}
\index{gsm620\_unvoiced\_bitorder@{gsm620\_unvoiced\_bitorder}!gsm620.c@{gsm620.c}}
\doxysubsubsection{gsm620\_unvoiced\_bitorder}
{\footnotesize\ttfamily const uint16\+\_\+t gsm620\+\_\+unvoiced\+\_\+bitorder[112]}

\mbox{\label{gsm620_8c_a94918e4bdfdd28d502b03e8328ce9f00}} 
\index{gsm620.c@{gsm620.c}!gsm620\_voiced\_bitorder@{gsm620\_voiced\_bitorder}}
\index{gsm620\_voiced\_bitorder@{gsm620\_voiced\_bitorder}!gsm620.c@{gsm620.c}}
\doxysubsubsection{gsm620\_voiced\_bitorder}
{\footnotesize\ttfamily const uint16\+\_\+t gsm620\+\_\+voiced\+\_\+bitorder[112]}

