From 7355b55ad1cb8b3bc1830fcffd4ef6392bbadd7e Mon Sep 17 00:00:00 2001 From: Laurent THOMAS Date: Thu, 5 Jun 2025 16:15:17 +0200 Subject: [PATCH] this MR replaces constants INT16_MIN by -INT16_MAX (so -32767) in places where it used for mathematical operations --- openair1/PHY/CODING/3gpplte_turbo_decoder.c | 3 --- .../LTE_ESTIMATION/lte_ul_channel_estimation.c | 6 +----- openair1/PHY/LTE_TRANSPORT/pucch.c | 2 +- openair1/PHY/LTE_TRANSPORT/pucch_common.c | 6 +++--- .../PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c | 16 ++++++++-------- openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c | 4 ++-- openair1/PHY/TOOLS/signal_energy.c | 2 -- openair1/SCHED/sched_common_extern.h | 11 ++++++----- 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/openair1/PHY/CODING/3gpplte_turbo_decoder.c b/openair1/PHY/CODING/3gpplte_turbo_decoder.c index 52860e096f..3cc54ab0d4 100644 --- a/openair1/PHY/CODING/3gpplte_turbo_decoder.c +++ b/openair1/PHY/CODING/3gpplte_turbo_decoder.c @@ -123,9 +123,6 @@ typedef char Binary; typedef short llr_t; // internal decoder data is 16-bit fixed typedef short channel_t; -#define LLR_MAX 32767 -#define LLR_MIN -32768 -#define LLRTOT 16 #define MAX 32767//16383 #define FRAME_LENGTH_MAX 6144 #define STATES 8 diff --git a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c index 591c589b49..b7ad400ff1 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_ul_channel_estimation.c @@ -526,11 +526,7 @@ int32_t lte_srs_channel_estimation(LTE_DL_FRAME_PARMS *frame_parms, //if ((1<<(sub_frame_number%T_SFC))&transmission_offset_tdd[Ssrs]) { - if (generate_srs(frame_parms, - soundingrs_ul_config_dedicated, - &srs_vars->srs[eNB_id], - 0x7FFF, - subframe)==-1) { + if (generate_srs(frame_parms, soundingrs_ul_config_dedicated, &srs_vars->srs[eNB_id], INT16_MAX, subframe) == -1) { LOG_E(PHY,"lte_srs_channel_estimation: Error in generate_srs\n"); return(-1); } diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index c8adb38f7c..c777313df0 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -764,7 +764,7 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB, uint8_t m,l; uint8_t n_cs,alpha_ind; int16_t tmp_re,tmp_im,W_re=0,W_im=0; - int16_t W4_nouse[4]={32767,32767,-32768,-32768}; + int16_t W4_nouse[4] = {32767, 32767, -32767, -32767}; int32_t n0_IQ[2]; double interference_power; int16_t *rxptr; diff --git a/openair1/PHY/LTE_TRANSPORT/pucch_common.c b/openair1/PHY/LTE_TRANSPORT/pucch_common.c index 932d30ed70..1722f9a22d 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch_common.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch_common.c @@ -72,7 +72,7 @@ void init_ncs_cell(LTE_DL_FRAME_PARMS *frame_parms,uint8_t ncs_cell[20][7]) } } -const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32768, 32767, -32768}, {32767, -32768, -32768, 32767}}; +const int16_t W4[3][4] = {{32767, 32767, 32767, 32767}, {32767, -32767, 32767, -32767}, {32767, -32767, -32767, 32767}}; const int16_t W3_re[3][6] = {{32767, 32767, 32767}, {32767, -16384, -16384}, {32767, -16384, -16384}}; const int16_t W3_im[3][6] = {{0, 0, 0}, {0, 28377, -28378}, {0, -28378, 28377}}; @@ -334,8 +334,8 @@ const uint8_t chcod_tbl[128][48] = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 {0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1}}; -const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384, -1, 16383, 28377}; -const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32768, -28378, -16384}; +const int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377}; +const int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384}; // W5_TBL const int16_t W5_fmt3_re[5][5] = {{32767, 32767, 32767, 32767, 32767}, diff --git a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c index ac045480da..9aa520c585 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/dlsch_demodulation.c @@ -2867,16 +2867,16 @@ void float_to_chan_est(int32_t **dl_ch_estimates_ext, for (aarx=0; aarx=1) - imag = 0x7FFF; + imag = INT16_MAX; else imag = cimag(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768; if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])<-1) - real = 0x8000; + real = -INT16_MAX; else if (creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])>=1) - real = 0x7FFF; + real = INT16_MAX; else real = creal(dl_ch_estimates_ext_f[aatx*n_rx + aarx][re])*32768; @@ -2910,16 +2910,16 @@ void float_to_rxdataF(int32_t **rxdataF_ext, for (aarx=0; aarx=1) - imag = 0x7FFF; + imag = INT16_MAX; else imag = cimag(rxdataF_f[aarx][re])*32768; if (creal(rxdataF_f[aarx][re])<-1) - real = 0x8000; + real = -INT16_MAX; else if (creal(rxdataF_f[aarx][re])>=1) - real = 0x7FFF; + real = INT16_MAX; else real = creal(rxdataF_f[aarx][re])*32768; diff --git a/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c index eb029aa429..929c3ba7c0 100644 --- a/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c +++ b/openair1/PHY/LTE_UE_TRANSPORT/drs_modulation.c @@ -56,8 +56,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue, //uint32_t phase_shift; // phase shift for cyclic delay in DM RS //uint8_t alpha_ind; - int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; - int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; + int16_t alpha_re[12] = {32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384, -1, 16383, 28377}; + int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0, -16384, -28378, -32767, -28378, -16384}; uint8_t cyclic_shift,cyclic_shift0=0,cyclic_shift1=0; LTE_DL_FRAME_PARMS *fp = (ue==NULL) ? frame_parms : &ue->frame_parms; diff --git a/openair1/PHY/TOOLS/signal_energy.c b/openair1/PHY/TOOLS/signal_energy.c index 93544da758..a7c314dd44 100644 --- a/openair1/PHY/TOOLS/signal_energy.c +++ b/openair1/PHY/TOOLS/signal_energy.c @@ -27,8 +27,6 @@ // length : length of vector in complex samples #define shift 4 -//#define shift_DC 0 -//#define SHRT_MIN -32768 //----------------------------------------------------------------- // Average Power calculation with DC removing diff --git a/openair1/SCHED/sched_common_extern.h b/openair1/SCHED/sched_common_extern.h index 57d70f7d1e..f413ba683c 100644 --- a/openair1/SCHED/sched_common_extern.h +++ b/openair1/SCHED/sched_common_extern.h @@ -27,11 +27,12 @@ #include "sched_eNB.h" // This is the formula from Section 5.1.1.1 in 36.213 100*10*log10((2^(MPR*Ks)-1)), where MPR is in the range [0,6] and Ks=1.25 -static const int16_t hundred_times_delta_TF[100] = {-32768, -1268, -956, -768, -631, -523, -431, -352, -282, -219, -161, -107, -57, -9, 36, 79, 120, 159, 197, 234, - 269, 304, 337, 370, 402, 434, 465, 495, 525, 555, 583, 612, 640, 668, 696, 723, 750, 777, 803, 829, - 856, 881, 907, 933, 958, 983, 1008, 1033, 1058, 1083, 1108, 1132, 1157, 1181, 1205, 1229, 1254, 1278, 1302, 1325, - 1349, 1373, 1397, 1421, 1444, 1468, 1491, 1515, 1538, 1562, 1585, 1609, 1632, 1655, 1679, 1702, 1725, 1748, 1772, 1795, - 1818, 1841, 1864, 1887, 1910, 1933, 1956, 1980, 2003, 2026, 2049, 2072, 2095, 2118, 2141, 2164, 2186, 2209, 2232, 2255}; +static const int16_t hundred_times_delta_TF[100] = { + -32767, -1268, -956, -768, -631, -523, -431, -352, -282, -219, -161, -107, -57, -9, 36, 79, 120, 159, 197, 234, + 269, 304, 337, 370, 402, 434, 465, 495, 525, 555, 583, 612, 640, 668, 696, 723, 750, 777, 803, 829, + 856, 881, 907, 933, 958, 983, 1008, 1033, 1058, 1083, 1108, 1132, 1157, 1181, 1205, 1229, 1254, 1278, 1302, 1325, + 1349, 1373, 1397, 1421, 1444, 1468, 1491, 1515, 1538, 1562, 1585, 1609, 1632, 1655, 1679, 1702, 1725, 1748, 1772, 1795, + 1818, 1841, 1864, 1887, 1910, 1933, 1956, 1980, 2003, 2026, 2049, 2072, 2095, 2118, 2141, 2164, 2186, 2209, 2232, 2255}; static const uint16_t hundred_times_log10_NPRB[100] = {0, 301, 477, 602, 698, 778, 845, 903, 954, 1000, 1041, 1079, 1113, 1146, 1176, 1204, 1230, 1255, 1278, 1301, 1322, 1342, 1361, 1380, 1397, 1414, 1431, 1447, 1462, 1477, 1491, 1505, 1518, 1531, 1544, 1556, 1568, 1579, 1591, 1602, 1612, 1623, 1633, 1643, 1653, 1662, 1672, 1681, 1690, 1698, 1707, 1716, 1724, 1732, 1740, 1748, 1755, 1763, 1770, 1778,