1 /*
2 *          File drm.h
3 *
4 *          M.Bos - PA0MBO
5 *          Date feb 21st 2009
6 */
7 
8 /*************************************************************************
9 *
10 *                           PA0MBO
11 *
12 *    COPYRIGHT (C)  2009  M.Bos
13 *
14 *    This file is part of the distribution package RXAMADRM
15 *
16 *    This package is free software and you can redistribute is
17 *    and/or modify it under the terms of the GNU General Public License
18 *
19 *    More details can be found in the accompanying file COPYING
20 *************************************************************************/
21 
22 
23 
24 #include "drm.h"
25 
26 //float acq_signal[2*DRMBUFSIZE]; //contains complex numbers
27 int input_samples_buffer_request;
28 int symbols_per_frame_list[4] = { 15, 15, 20, 24 };
29 int time_ref_cells_k_list[4][21] =
30 {
31   {6, 7, 11, 12, 15, 16, 23, 29, 30, 33, 34, 38, 39, 41, 45, 46, 0, 0, 0, 0, 0},
32   {6, 10, 11, 14, 17, 18, 27, 28, 30, 33, 34, 38, 40, 41, 44, 0, 0, 0, 0, 0, 0},
33   {7, 8, 13, 14, 21, 22, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
34   {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0, 0, 0, 0, 0}
35 };
36 int time_ref_cells_theta_1024_list[4][21] =
37   {
38   {973, 205, 717, 264, 357, 357, 952, 440, 856, 88,   88, 68, 836, 836, 836, 1008, 0, 0, 0, 0, 0},
39   {304, 331, 108, 620, 192, 704,  44, 432, 588, 844, 651,651, 651, 460, 950,    0, 0, 0, 0, 0, 0},
40   {432, 331, 108, 620, 192, 704,  44, 304,   0,   0,   0,  0,   0,   0,   0,    0, 0, 0, 0, 0, 0},
41   {1,     2,   3,   4,   5,   6,   7,   8,   9,  10,  11, 12,  13,  14,  15,   16, 0, 0, 0, 0, 0}
42 };
43 
44 int y_list[4] = { 5, 3, 4, 3 };
45 int symbols_per_2D_window_list[4] = { 10, 6, 8, 6 };
46 int symbols_to_delay_list[4] = { 5, 3, 4, 3 };
47 float cpsd[513], psd[513];
48 int N_symbols_frequency_pilot_search = 15;
49 int K_min_K_max_list[2][24] =
50   {
51     {2, 2, -102, -114, -98, -110, 1, 1, -91, -103, -87, -99, 1, 1, 0, -69, 0, -67, 0, 0, 0, -44, 0, -43},
52     {54, 58, 102, 114, 314, 350, 45, 51, 91,  103, 279, 311, 29,31, 0, 69, 0, 213, 0, 0, 0, 44, 0, 135}
53 };
54 float samplerate_offset_estimation;
55 float samplerate_offset;
56 int N_symbols_mode_detection;
57 int time_offset_log_last;
58 int transmission_frame_buffer_data_valid;
59 int fac_valid=0;
60 int no_of_unused_carriers_list[4] = { 2, 1, 1, 1 };
61 int freq_ref_cells_k_list[4][3] = { {9, 27, 36}, {8, 24, 32}, {5, 15, 20}, {5, 15, 20}};
62 int freq_ref_cells_theta_1024_list[4][3] = { {205, 836, 215}, {331, 651, 555}, {788, 1014, 332}, {788, 1014, 332}
63 };
64 int x_list[4] = { 4, 2, 1, 1 };
65 int k0_list[4] = { 2, 1, 1, 1 };
66 int dimw1024[4][2] = { {5, 3}, {3, 5}, {2, 10}, {3, 8} };      /* matrix[mode][n][m] */
67 int W_1024_list[4][5][10] =
68   { {{228, 341, 455, 0, 0, 0, 0, 0, 0, 0}, {455, 569, 683, 0, 0, 0, 0, 0, 0, 0}, {683, 796, 910, 0, 0, 0, 0, 0, 0, 0},
69      {910, 0, 114, 0, 0, 0, 0, 0, 0, 0}, {114, 228, 341, 0, 0, 0, 0, 0, 0, 0}},
70   {{512, 0, 512, 0, 512, 0, 0, 0, 0, 0}, {0, 512, 0, 512, 0, 0, 0, 0, 0, 0}, {512, 0, 512, 0, 512, 0, 0, 0, 0, 0},
71    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
72   {{512, 0, 512, 0, 512, 0, 0, 0, 0, 0}, {0, 512, 0, 512, 0, 0, 0, 0, 0, 0},
73    {512, 0, 512, 0, 512, 0, 0, 0, 0, 0}, {0, 512, 0, 512, 0, 0, 0, 0, 0, 0},
74    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
75   {{465, 372, 279, 186, 93, 0, 931, 838, 745, 652},
76    {931, 838, 745, 652, 559, 465, 372, 279, 186, 93},
77    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
78 };
79 int Z_256_list[4][5][10] =
80   { {{0, 81, 248, 0, 0, 0, 0, 0, 0, 0},
81      {18, 106, 106, 0, 0, 0, 0, 0, 0, 0},
82      {122, 116, 31, 0, 0, 0, 0, 0, 0, 0},
83      {129, 129, 39, 0, 0, 0, 0, 0, 0, 0},
84      {33, 32, 111, 0, 0, 0, 0, 0, 0, 0}},
85   {{0, 57, 164, 64, 12, 0, 0, 0, 0, 0},
86    {168, 255, 161, 106, 118, 0, 0, 0, 0, 0},
87    {25, 232, 132, 233, 38, 0, 0, 0, 0, 0},
88    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
89    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
90   {{0, 57, 164, 64, 12, 0, 0, 0, 0, 0}, {168, 255, 161, 106, 118, 0, 0, 0, 0, 0},
91    {25, 232, 132, 233, 38, 0, 0, 0, 0, 0}, {168, 255, 161, 106, 118, 0, 0, 0, 0, 0},
92    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
93   {{0, 240, 17, 60, 220, 38, 151, 101, 0, 0},
94    {110, 7, 78, 82, 175, 150, 106, 25, 0, 0},
95    {165, 7, 252, 124, 253, 177, 197, 142, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}
96 };
97 int Q_1024_list[4] = { 36, 12, 10, 14 };
98 int power_boost_list[4][6][4] =
99   { {{2, 6, 50, 54}, {2, 6, 54, 58}, {0, 0, 0, 0},
100      {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
101   {{1, 3, 43, 45}, {1, 3, 49, 51}, {0, 0, 0, 0},
102    {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
103   {{1, 29, 0, 0}, {1, 31, 0, 0}, {0, 0, 0, 0},
104    {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}},
105   {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
106 };
107 int mode_and_occupancy_code_table[14] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
108 int robustness_mode, spectrum_occupancy_estimation;
109 int spectrum_occupancy;
110 int symbols_per_frame;
111 int time_ref_cells_cnt_list[4] = { 16, 15, 8, 16 };
112 int K_modulo, K_dc;
113 float mean_energy_of_used_cells;
114 int FAC_cells_k[65];
115 float transmission_frame_buffer[82980];        /* complex */
116 float channel_transfer_function_buffer[82980]; /* complex */
117 int transmission_frame_buffer_wptr = 0;
118 int lFAC;
119 
120 //Display * display;
121 int runstate;
122 struct mplex_desc multiplex_description;
123 struct audio_info audio_information;
124 struct appl_info application_information;
125 struct stream_info stream_information;
126 struct time_info time_and_date;
127 struct dflttmsg default_text_message;
128 struct dfltdunitasmbly default_data_unit_assembly;
129 struct dfltMOTdirasmbly default_MOT_directory_assembly;
130 struct dfltMOTobjasmbly default_MOT_object_assembly;
131 struct dfltMOTobjasmblyinfo default_MOT_object_assembly_information;
132 struct dfltMOTobj default_MOT_object;
133 int channel_decoded_data_buffer_data_valid;
134 double channel_decoded_data_buffer[110000];
135 float WMERFAC;
136 
137 
138 
139 /* char text_message[1000]; */
140 int audio_data_flag;
141 int length_decoded_data;
142 int MSC_Demapper[6][2959];
143 long bufaucnt[2048];
144 
145 emscStatus msc_valid;
146 int bodyTotalSegments;
147 int rxSegments;
148 int currentSegmentNumber;
149 unsigned int rxTransportID;
150 QList<short unsigned int> drmBlockList;
151 sourceDecoder *srcDecoder;
152 uint txTransportID;
153 bool stopDRM;
154 float avgSNR;
155 float lastAvgSNR;
156 bool avgSNRAvailable;
157 QString drmCallsign;
158 bool drmBusy;
159 
160 
161