si: Fix range1024 encoding
f0 is currently set to arfcns[0] in range_enc_determine_range(), while GSM 04.08 requires f0 to be ARFCN 0 in range1024 encoding. This patch modifies range_enc_determine_range() to force f0 to be 0 if this encoding is used. This way the case distinction in range_enc_filter_arfcns() is not longer necessary. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
131406c86d
commit
45014a0cad
|
@ -16,7 +16,7 @@ enum {
|
||||||
int range_enc_determine_range(const int *arfcns, int size, int *f0_out);
|
int range_enc_determine_range(const int *arfcns, int size, int *f0_out);
|
||||||
int range_enc_arfcns(const int rng, const int *arfcns, int sze, int *out, int idx);
|
int range_enc_arfcns(const int rng, const int *arfcns, int sze, int *out, int idx);
|
||||||
int range_enc_find_index(const int rng, const int *arfcns, int size);
|
int range_enc_find_index(const int rng, const int *arfcns, int size);
|
||||||
int range_enc_filter_arfcns(const int rng, int *arfcns, const int sze, const int f0, int *f0_included);
|
int range_enc_filter_arfcns(int *arfcns, const int sze, const int f0, int *f0_included);
|
||||||
|
|
||||||
int range_enc_range128(uint8_t *chan_list, int f0, int *w);
|
int range_enc_range128(uint8_t *chan_list, int f0, int *w);
|
||||||
int range_enc_range256(uint8_t *chan_list, int f0, int *w);
|
int range_enc_range256(uint8_t *chan_list, int f0, int *w);
|
||||||
|
|
|
@ -144,7 +144,9 @@ int range_enc_arfcns(const int range,
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* This implements the range determination as described in GSM 04.08 J4. The
|
* This implements the range determination as described in GSM 04.08 J4. The
|
||||||
* result will be a base frequency f0 and the range to use.
|
* result will be a base frequency f0 and the range to use. Note that for range
|
||||||
|
* 1024 encoding f0 always refers to ARFCN 0 even if it is not an element of
|
||||||
|
* the arfcns list.
|
||||||
*
|
*
|
||||||
* \param[in] arfcns The input frequencies, they must be sorted, lowest number first
|
* \param[in] arfcns The input frequencies, they must be sorted, lowest number first
|
||||||
* \param[in] size The length of the array
|
* \param[in] size The length of the array
|
||||||
|
@ -166,8 +168,10 @@ int range_enc_determine_range(const int *arfcns, const int size, int *f0)
|
||||||
return ARFCN_RANGE_256;
|
return ARFCN_RANGE_256;
|
||||||
if (max < 512 && size <= 18)
|
if (max < 512 && size <= 18)
|
||||||
return ARFCN_RANGE_512;
|
return ARFCN_RANGE_512;
|
||||||
if (max < 1024 && size <= 17)
|
if (max < 1024 && size <= 17) {
|
||||||
|
*f0 = 0;
|
||||||
return ARFCN_RANGE_1024;
|
return ARFCN_RANGE_1024;
|
||||||
|
}
|
||||||
|
|
||||||
return ARFCN_RANGE_INVALID;
|
return ARFCN_RANGE_INVALID;
|
||||||
}
|
}
|
||||||
|
@ -271,34 +275,24 @@ int range_enc_range1024(uint8_t *chan_list, int f0, int f0_included, int *w)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int range_enc_filter_arfcns(const int range, int *arfcns,
|
int range_enc_filter_arfcns(int *arfcns,
|
||||||
const int size, const int f0, int *f0_included)
|
const int size, const int f0, int *f0_included)
|
||||||
{
|
{
|
||||||
int i, j = 0;
|
int i, j = 0;
|
||||||
*f0_included = 0;
|
*f0_included = 0;
|
||||||
|
|
||||||
if (range == ARFCN_RANGE_1024) {
|
for (i = 0; i < size; ++i) {
|
||||||
for (i = 0; i < size; ++i) {
|
/*
|
||||||
if (arfcns[i] == f0) {
|
* Appendix J.4 says the following:
|
||||||
*f0_included = 1;
|
* All frequencies except F(0), minus F(0) + 1.
|
||||||
continue;
|
* I assume we need to exclude it here.
|
||||||
}
|
*/
|
||||||
|
if (arfcns[i] == f0) {
|
||||||
/* copy and subtract */
|
*f0_included = 1;
|
||||||
arfcns[j++] = mod(arfcns[i] - 1, 1024);
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (i = 0; i < size; ++i) {
|
|
||||||
/*
|
|
||||||
* Appendix J.4 says the following:
|
|
||||||
* All frequencies except F(0), minus F(0) + 1.
|
|
||||||
* I assume we need to exclude it here.
|
|
||||||
*/
|
|
||||||
if (arfcns[i] == f0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
arfcns[j++] = mod(arfcns[i] - (f0 + 1), 1024);
|
arfcns[j++] = mod(arfcns[i] - (f0 + 1), 1024);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return j;
|
return j;
|
||||||
|
|
|
@ -197,7 +197,7 @@ static int enc_freq_lst_range(uint8_t *chan_list,
|
||||||
* Manipulate the ARFCN list according to the rules in J4 depending
|
* Manipulate the ARFCN list according to the rules in J4 depending
|
||||||
* on the selected range.
|
* on the selected range.
|
||||||
*/
|
*/
|
||||||
arfcns_used = range_enc_filter_arfcns(range, arfcns, arfcns_used,
|
arfcns_used = range_enc_filter_arfcns(arfcns, arfcns_used,
|
||||||
f0, &f0_included);
|
f0, &f0_included);
|
||||||
|
|
||||||
memset(w, 0, sizeof(w));
|
memset(w, 0, sizeof(w));
|
||||||
|
|
|
@ -152,12 +152,12 @@ static int test_single_range_encoding(int range, const int *orig_arfcns,
|
||||||
arfcns_used = arfcns_num;
|
arfcns_used = arfcns_num;
|
||||||
memmove(arfcns, orig_arfcns, sizeof(arfcns));
|
memmove(arfcns, orig_arfcns, sizeof(arfcns));
|
||||||
|
|
||||||
f0 = arfcns[0];
|
f0 = range == ARFCN_RANGE_1024 ? 0 : arfcns[0];
|
||||||
/*
|
/*
|
||||||
* Manipulate the ARFCN list according to the rules in J4 depending
|
* Manipulate the ARFCN list according to the rules in J4 depending
|
||||||
* on the selected range.
|
* on the selected range.
|
||||||
*/
|
*/
|
||||||
arfcns_used = range_enc_filter_arfcns(range, arfcns, arfcns_used,
|
arfcns_used = range_enc_filter_arfcns(arfcns, arfcns_used,
|
||||||
f0, &f0_included);
|
f0, &f0_included);
|
||||||
|
|
||||||
memset(w, 0, sizeof(w));
|
memset(w, 0, sizeof(w));
|
||||||
|
@ -354,28 +354,28 @@ static void test_arfcn_filter()
|
||||||
|
|
||||||
/* check that the arfcn is taken out. f0_included is only set for Range1024 */
|
/* check that the arfcn is taken out. f0_included is only set for Range1024 */
|
||||||
f0_included = 24;
|
f0_included = 24;
|
||||||
res = range_enc_filter_arfcns(ARFCN_RANGE_512, arfcns, ARRAY_SIZE(arfcns),
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
||||||
arfcns[0], &f0_included);
|
|
||||||
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
|
||||||
VERIFY(f0_included, ==, 0);
|
|
||||||
for (i = 0; i < res; ++i)
|
|
||||||
VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
|
|
||||||
|
|
||||||
/* check with range1024 */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
|
||||||
arfcns[i] = (i + 1) * 2;
|
|
||||||
res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
|
|
||||||
arfcns[0], &f0_included);
|
arfcns[0], &f0_included);
|
||||||
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
||||||
VERIFY(f0_included, ==, 1);
|
VERIFY(f0_included, ==, 1);
|
||||||
for (i = 0; i < res; ++i)
|
for (i = 0; i < res; ++i)
|
||||||
VERIFY(arfcns[i], ==, ((i + 2) * 2) - 1);
|
VERIFY(arfcns[i], ==, ((i+2) * 2) - (2+1));
|
||||||
|
|
||||||
/* check with range1024, not included */
|
/* check with range1024, ARFCN 0 is included */
|
||||||
|
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
||||||
|
arfcns[i] = i * 2;
|
||||||
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
||||||
|
0, &f0_included);
|
||||||
|
VERIFY(res, ==, ARRAY_SIZE(arfcns) - 1);
|
||||||
|
VERIFY(f0_included, ==, 1);
|
||||||
|
for (i = 0; i < res; ++i)
|
||||||
|
VERIFY(arfcns[i], ==, (i + 1) * 2 - 1);
|
||||||
|
|
||||||
|
/* check with range1024, ARFCN 0 not included */
|
||||||
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
for (i = 0; i < ARRAY_SIZE(arfcns); ++i)
|
||||||
arfcns[i] = (i + 1) * 2;
|
arfcns[i] = (i + 1) * 2;
|
||||||
res = range_enc_filter_arfcns(ARFCN_RANGE_1024, arfcns, ARRAY_SIZE(arfcns),
|
res = range_enc_filter_arfcns(arfcns, ARRAY_SIZE(arfcns),
|
||||||
11, &f0_included);
|
0, &f0_included);
|
||||||
VERIFY(res, ==, ARRAY_SIZE(arfcns));
|
VERIFY(res, ==, ARRAY_SIZE(arfcns));
|
||||||
VERIFY(f0_included, ==, 0);
|
VERIFY(f0_included, ==, 0);
|
||||||
for (i = 0; i < res; ++i)
|
for (i = 0; i < res; ++i)
|
||||||
|
|
Loading…
Reference in New Issue