\doxysection{codec.\+h} \label{codec_8h_source}\index{include/osmocom/codec/codec.h@{include/osmocom/codec/codec.h}} \textbf{ Go to the documentation of this file.} \begin{DoxyCode}{0} \DoxyCodeLine{1 } \DoxyCodeLine{3 \textcolor{preprocessor}{\#pragma once}} \DoxyCodeLine{4 } \DoxyCodeLine{5 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{6 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{7 } \DoxyCodeLine{8 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{9 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{10 } \DoxyCodeLine{11 \textcolor{comment}{/* TS 101318 Chapter 5.1: 260 bits + 4bit sig */}} \DoxyCodeLine{12 \textcolor{preprocessor}{\#define GSM\_FR\_BYTES 33}} \DoxyCodeLine{13 \textcolor{comment}{/* TS 101318 Chapter 5.2: 112 bits, no sig */}} \DoxyCodeLine{14 \textcolor{preprocessor}{\#define GSM\_HR\_BYTES 14}} \DoxyCodeLine{15 \textcolor{comment}{/* TS 101318 Chapter 5.3: 244 bits + 4bit sig */}} \DoxyCodeLine{16 \textcolor{preprocessor}{\#define GSM\_EFR\_BYTES 31}} \DoxyCodeLine{17 } \DoxyCodeLine{18 \textcolor{comment}{/* Number of bytes of an GSM\_HR RTP payload */}} \DoxyCodeLine{19 \textcolor{preprocessor}{\#define GSM\_HR\_BYTES\_RTP\_RFC5993 (GSM\_HR\_BYTES + 1)}} \DoxyCodeLine{20 \textcolor{preprocessor}{\#define GSM\_HR\_BYTES\_RTP\_TS101318 (GSM\_HR\_BYTES)}} \DoxyCodeLine{21 } \DoxyCodeLine{22 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm610\_bitorder[]; \textcolor{comment}{/* FR */}} \DoxyCodeLine{23 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm620\_unvoiced\_bitorder[]; \textcolor{comment}{/* HR unvoiced */}} \DoxyCodeLine{24 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm620\_voiced\_bitorder[]; \textcolor{comment}{/* HR voiced */}} \DoxyCodeLine{25 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm660\_bitorder[]; \textcolor{comment}{/* EFR */}} \DoxyCodeLine{26 } \DoxyCodeLine{27 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_12\_2\_bitorder[]; \textcolor{comment}{/* AMR 12.2 kbits */}} \DoxyCodeLine{28 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_10\_2\_bitorder[]; \textcolor{comment}{/* AMR 10.2 kbits */}} \DoxyCodeLine{29 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_7\_95\_bitorder[]; \textcolor{comment}{/* AMR 7.95 kbits */}} \DoxyCodeLine{30 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_7\_4\_bitorder[]; \textcolor{comment}{/* AMR 7.4 kbits */}} \DoxyCodeLine{31 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_6\_7\_bitorder[]; \textcolor{comment}{/* AMR 6.7 kbits */}} \DoxyCodeLine{32 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_5\_9\_bitorder[]; \textcolor{comment}{/* AMR 5.9 kbits */}} \DoxyCodeLine{33 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_5\_15\_bitorder[]; \textcolor{comment}{/* AMR 5.15 kbits */}} \DoxyCodeLine{34 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint16\_t gsm690\_4\_75\_bitorder[]; \textcolor{comment}{/* AMR 4.75 kbits */}} \DoxyCodeLine{35 } \DoxyCodeLine{36 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint8\_t osmo\_gsm611\_silence\_frame[GSM\_FR\_BYTES];} \DoxyCodeLine{37 } \DoxyCodeLine{38 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }value\_string osmo\_amr\_type\_names[];} \DoxyCodeLine{39 } \DoxyCodeLine{40 \textcolor{keyword}{enum} osmo\_amr\_type \{} \DoxyCodeLine{41 AMR\_4\_75 = 0,} \DoxyCodeLine{42 AMR\_5\_15 = 1,} \DoxyCodeLine{43 AMR\_5\_90 = 2,} \DoxyCodeLine{44 AMR\_6\_70 = 3,} \DoxyCodeLine{45 AMR\_7\_40 = 4,} \DoxyCodeLine{46 AMR\_7\_95 = 5,} \DoxyCodeLine{47 AMR\_10\_2 = 6,} \DoxyCodeLine{48 AMR\_12\_2 = 7,} \DoxyCodeLine{49 AMR\_SID = 8,} \DoxyCodeLine{50 AMR\_GSM\_EFR\_SID = 9,} \DoxyCodeLine{51 AMR\_TDMA\_EFR\_SID = 10,} \DoxyCodeLine{52 AMR\_PDC\_EFR\_SID = 11,} \DoxyCodeLine{53 AMR\_NO\_DATA = 15,} \DoxyCodeLine{54 \};} \DoxyCodeLine{55 } \DoxyCodeLine{56 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_amr\_type\_name(\textcolor{keyword}{enum} osmo\_amr\_type type)} \DoxyCodeLine{57 \{ \textcolor{keywordflow}{return} get\_value\_string(osmo\_amr\_type\_names, type); \}} \DoxyCodeLine{58 } \DoxyCodeLine{59 \textcolor{keyword}{enum} osmo\_amr\_quality \{} \DoxyCodeLine{60 AMR\_BAD = 0,} \DoxyCodeLine{61 AMR\_GOOD = 1} \DoxyCodeLine{62 \};} \DoxyCodeLine{63 } \DoxyCodeLine{64 \textcolor{keyword}{extern} \textcolor{keyword}{const} uint8\_t gsm690\_bitlength[AMR\_NO\_DATA+1];} \DoxyCodeLine{65 } \DoxyCodeLine{66 \textcolor{keywordtype}{int} osmo\_amr\_s\_to\_d(ubit\_t *out, \textcolor{keyword}{const} ubit\_t *in, uint16\_t n\_bits, \textcolor{keyword}{enum} osmo\_amr\_type amr\_mode);} \DoxyCodeLine{67 \textcolor{keywordtype}{int} osmo\_amr\_d\_to\_s(ubit\_t *out, \textcolor{keyword}{const} ubit\_t *in, uint16\_t n\_bits, \textcolor{keyword}{enum} osmo\_amr\_type amr\_mode);} \DoxyCodeLine{68 } \DoxyCodeLine{73 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} osmo\_amr\_is\_speech(\textcolor{keyword}{enum} osmo\_amr\_type ft)} \DoxyCodeLine{74 \{} \DoxyCodeLine{75 \textcolor{keywordflow}{switch} (ft) \{} \DoxyCodeLine{76 \textcolor{keywordflow}{case} AMR\_4\_75:} \DoxyCodeLine{77 \textcolor{keywordflow}{case} AMR\_5\_15:} \DoxyCodeLine{78 \textcolor{keywordflow}{case} AMR\_5\_90:} \DoxyCodeLine{79 \textcolor{keywordflow}{case} AMR\_6\_70:} \DoxyCodeLine{80 \textcolor{keywordflow}{case} AMR\_7\_40:} \DoxyCodeLine{81 \textcolor{keywordflow}{case} AMR\_7\_95:} \DoxyCodeLine{82 \textcolor{keywordflow}{case} AMR\_10\_2:} \DoxyCodeLine{83 \textcolor{keywordflow}{case} AMR\_12\_2:} \DoxyCodeLine{84 \textcolor{keywordflow}{return} \textcolor{keyword}{true};} \DoxyCodeLine{85 \textcolor{keywordflow}{default}:} \DoxyCodeLine{86 \textcolor{keywordflow}{return} \textcolor{keyword}{false};} \DoxyCodeLine{87 \}} \DoxyCodeLine{88 \}} \DoxyCodeLine{89 } \DoxyCodeLine{90 \textcolor{comment}{/* SID ternary classification per GSM 06.31 \& 06.81 section 6.1.1 */}} \DoxyCodeLine{91 \textcolor{keyword}{enum} osmo\_gsm631\_sid\_class \{} \DoxyCodeLine{92 OSMO\_GSM631\_SID\_CLASS\_SPEECH = 0,} \DoxyCodeLine{93 OSMO\_GSM631\_SID\_CLASS\_INVALID = 1,} \DoxyCodeLine{94 OSMO\_GSM631\_SID\_CLASS\_VALID = 2,} \DoxyCodeLine{95 \};} \DoxyCodeLine{96 } \DoxyCodeLine{97 \textcolor{keywordtype}{bool} osmo\_fr\_check\_sid(\textcolor{keyword}{const} uint8\_t *rtp\_payload, \textcolor{keywordtype}{size\_t} payload\_len);} \DoxyCodeLine{98 \textcolor{keywordtype}{bool} osmo\_hr\_check\_sid(\textcolor{keyword}{const} uint8\_t *rtp\_payload, \textcolor{keywordtype}{size\_t} payload\_len);} \DoxyCodeLine{99 \textcolor{keywordtype}{bool} osmo\_efr\_check\_sid(\textcolor{keyword}{const} uint8\_t *rtp\_payload, \textcolor{keywordtype}{size\_t} payload\_len);} \DoxyCodeLine{100 } \DoxyCodeLine{101 \textcolor{keyword}{enum} osmo\_gsm631\_sid\_class osmo\_fr\_sid\_classify(\textcolor{keyword}{const} uint8\_t *rtp\_payload);} \DoxyCodeLine{102 \textcolor{keyword}{enum} osmo\_gsm631\_sid\_class osmo\_efr\_sid\_classify(\textcolor{keyword}{const} uint8\_t *rtp\_payload);} \DoxyCodeLine{103 } \DoxyCodeLine{109 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} osmo\_fr\_is\_any\_sid(\textcolor{keyword}{const} uint8\_t *rtp\_payload)} \DoxyCodeLine{110 \{} \DoxyCodeLine{111 \textcolor{keyword}{enum} osmo\_gsm631\_sid\_class sidc;} \DoxyCodeLine{112 } \DoxyCodeLine{113 sidc = osmo\_fr\_sid\_classify(rtp\_payload);} \DoxyCodeLine{114 \textcolor{keywordflow}{return} sidc != OSMO\_GSM631\_SID\_CLASS\_SPEECH;} \DoxyCodeLine{115 \}} \DoxyCodeLine{116 } \DoxyCodeLine{122 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{bool} osmo\_efr\_is\_any\_sid(\textcolor{keyword}{const} uint8\_t *rtp\_payload)} \DoxyCodeLine{123 \{} \DoxyCodeLine{124 \textcolor{keyword}{enum} osmo\_gsm631\_sid\_class sidc;} \DoxyCodeLine{125 } \DoxyCodeLine{126 sidc = osmo\_efr\_sid\_classify(rtp\_payload);} \DoxyCodeLine{127 \textcolor{keywordflow}{return} sidc != OSMO\_GSM631\_SID\_CLASS\_SPEECH;} \DoxyCodeLine{128 \}} \DoxyCodeLine{129 } \DoxyCodeLine{130 \textcolor{keywordtype}{bool} osmo\_fr\_sid\_preen(uint8\_t *rtp\_payload);} \DoxyCodeLine{131 \textcolor{keywordtype}{bool} osmo\_efr\_sid\_preen(uint8\_t *rtp\_payload);} \DoxyCodeLine{132 } \DoxyCodeLine{133 \textcolor{keywordtype}{void} osmo\_fr\_sid\_reset(uint8\_t *rtp\_payload);} \DoxyCodeLine{134 \textcolor{keywordtype}{void} osmo\_hr\_sid\_reset(uint8\_t *rtp\_payload);} \DoxyCodeLine{135 \textcolor{keywordtype}{void} osmo\_efr\_sid\_reset(uint8\_t *rtp\_payload);} \DoxyCodeLine{136 } \DoxyCodeLine{137 \textcolor{keywordtype}{int} osmo\_amr\_rtp\_enc(uint8\_t *payload, uint8\_t cmr, \textcolor{keyword}{enum} osmo\_amr\_type ft,} \DoxyCodeLine{138 \textcolor{keyword}{enum} osmo\_amr\_quality bfi);} \DoxyCodeLine{139 \textcolor{keywordtype}{int} osmo\_amr\_rtp\_dec(\textcolor{keyword}{const} uint8\_t *payload, \textcolor{keywordtype}{int} payload\_len, uint8\_t *cmr,} \DoxyCodeLine{140 int8\_t *cmi, \textcolor{keyword}{enum} osmo\_amr\_type *ft,} \DoxyCodeLine{141 \textcolor{keyword}{enum} osmo\_amr\_quality *bfi, int8\_t *sti);} \end{DoxyCode}