SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
audiog722.h
Go to the documentation of this file.
1 // Copyright (C) 2019 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef SDRBASE_AUDIO_AUDIOG722_H_
20 #define SDRBASE_AUDIO_AUDIOG722_H_
21 
22 #include <stdint.h>
23 #include "export.h"
24 
26 {
27 public:
28  AudioG722();
29  ~AudioG722();
30  void init(int rate, int options);
31  int encode(uint8_t g722_data[], const int16_t amp[], int len);
32 
33 private:
35  {
40  int packed;
42  int eight_k;
45 
47  int x[24];
48 
49  struct
50  {
51  int s;
52  int sp;
53  int sz;
54  int r[3];
55  int a[3];
56  int ap[3];
57  int p[3];
58  int d[7];
59  int b[7];
60  int bp[7];
61  int sg[7];
62  int nb;
63  int det;
64  } band[2];
65 
66  unsigned int in_buffer;
67  int in_bits;
68  unsigned int out_buffer;
69  int out_bits;
70 
72  void init(int rate, int options);
73  };
74 
76  {
77  int16_t amp16;
78 
79  /* Hopefully this is optimized for the common case - not clipping */
80  amp16 = (int16_t) amp;
81  if (amp == amp16) {
82  return amp16;
83  }
84 
85  if (amp > INT16_MAX) {
86  return INT16_MAX;
87  }
88 
89  return INT16_MIN;
90  }
91 
92  void block4(int band, int d);
93 
95 
96  static const int q6[32];
97  static const int iln[32];
98  static const int ilp[32];
99  static const int wl[8];
100  static const int rl42[16];
101  static const int ilb[32];
102  static const int qm4[16];
103  static const int qm2[4];
104  static const int qmf_coeffs[12];
105  static const int ihn[3];
106  static const int ihp[3];
107  static const int wh[3];
108  static const int rh2[4];
109 };
110 
111 
112 #endif /* SDRBASE_AUDIO_AUDIOG722_H_ */
short int16_t
Definition: rtptypes_win.h:43
unsigned char uint8_t
Definition: rtptypes_win.h:42
int int32_t
Definition: rtptypes_win.h:45
g722_encode_state state
Definition: audiog722.h:94
#define SDRBASE_API
Definition: export.h:40
int16_t saturate(int32_t amp)
Definition: audiog722.h:75