Skip to content

Commit 357072d

Browse files
committed
In MA1 mode, delay the P3 logical channel to match P1
1 parent 292e1dc commit 357072d

File tree

2 files changed

+41
-26
lines changed

2 files changed

+41
-26
lines changed

src/decode.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int bit_map(unsigned char matrix[PARTITION_WIDTH_AM * BLKSZ * 8], int b,
4343
static void interleaver_ma1(decode_t *st)
4444
{
4545
int b, k, p;
46-
for (int n = 0; n < 18000; n++)
46+
for (int n = 0; n < BL_LENGTH; n++)
4747
{
4848
b = n/2250;
4949
k = (n + n/750 + 1) % 750;
@@ -53,7 +53,7 @@ static void interleaver_ma1(decode_t *st)
5353
b = (3*n + 3) % 8;
5454
k = (n + n/3000 + 3) % 750;
5555
p = 3 + (n % 3);
56-
st->ml[DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_pl, b, k, p);
56+
st->ml[ML_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_pl, b, k, p);
5757

5858
b = n/2250;
5959
k = (n + n/750) % 750;
@@ -63,29 +63,29 @@ static void interleaver_ma1(decode_t *st)
6363
b = (3*n) % 8;
6464
k = (n + n/3000 + 2) % 750;
6565
p = 3 + (n % 3);
66-
st->mu[DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_pu, b, k, p);
66+
st->mu[MU_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_pu, b, k, p);
6767
}
6868

6969
if (st->input->sync.psmi != SERVICE_MODE_MA3)
7070
{
71-
for (int n = 0; n < 12000; n++)
71+
for (int n = 0; n < EL_LENGTH; n++)
7272
{
7373
b = (3*n + n/3000) % 8;
7474
k = (n + (n/6000)) % 750;
7575
p = n % 2;
76-
st->el[n] = bit_map(st->buffer_t, b, k, p);
76+
st->el[EL_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_t, b, k, p);
7777
}
78-
for (int n = 0; n < 24000; n++)
78+
for (int n = 0; n < EU_LENGTH; n++)
7979
{
8080
b = (3*n + n/3000 + 2*(n/12000)) % 8;
8181
k = (n + (n/6000)) % 750;
8282
p = n % 4;
83-
st->eu[n] = bit_map(st->buffer_s, b, k, p);
83+
st->eu[EU_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_s, b, k, p);
8484
}
8585
}
8686
else
8787
{
88-
for (int n = 0; n < 18000; n++)
88+
for (int n = 0; n < EBL_LENGTH; n++)
8989
{
9090
b = (3*n + 3) % 8;
9191
k = (n + n/3000 + 3) % 750;
@@ -95,7 +95,7 @@ static void interleaver_ma1(decode_t *st)
9595
b = (3*n + 3) % 8;
9696
k = (n + n/3000 + 3) % 750;
9797
p = 3 + (n % 3);
98-
st->eml[DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_t, b, k, p);
98+
st->eml[EML_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_t, b, k, p);
9999

100100
b = (3*n) % 8;
101101
k = (n + n/3000 + 2) % 750;
@@ -105,7 +105,7 @@ static void interleaver_ma1(decode_t *st)
105105
b = (3*n) % 8;
106106
k = (n + n/3000 + 2) % 750;
107107
p = 3 + (n % 3);
108-
st->emu[DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_s, b, k, p);
108+
st->emu[EMU_LENGTH * DIVERSITY_DELAY_AM + n] = bit_map(st->buffer_s, b, k, p);
109109
}
110110
}
111111

@@ -141,12 +141,17 @@ static void interleaver_ma1(decode_t *st)
141141
}
142142
}
143143

144-
memmove(st->ml, st->ml + 18000, DIVERSITY_DELAY_AM);
145-
memmove(st->mu, st->mu + 18000, DIVERSITY_DELAY_AM);
146-
if (st->input->sync.psmi == SERVICE_MODE_MA3)
144+
memmove(st->ml, st->ml + ML_LENGTH, ML_LENGTH * DIVERSITY_DELAY_AM);
145+
memmove(st->mu, st->mu + MU_LENGTH, MU_LENGTH * DIVERSITY_DELAY_AM);
146+
if (st->input->sync.psmi != SERVICE_MODE_MA3)
147+
{
148+
memmove(st->el, st->el + EL_LENGTH, EL_LENGTH * DIVERSITY_DELAY_AM);
149+
memmove(st->eu, st->eu + EU_LENGTH, EU_LENGTH * DIVERSITY_DELAY_AM);
150+
}
151+
else
147152
{
148-
memmove(st->eml, st->eml + 18000, DIVERSITY_DELAY_AM);
149-
memmove(st->emu, st->emu + 18000, DIVERSITY_DELAY_AM);
153+
memmove(st->eml, st->eml + EML_LENGTH, EML_LENGTH * DIVERSITY_DELAY_AM);
154+
memmove(st->emu, st->emu + EMU_LENGTH, EMU_LENGTH * DIVERSITY_DELAY_AM);
150155
}
151156

152157
int offset = 0;

src/decode.h

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
#include "defines.h"
55
#include "pids.h"
66

7-
#define DIVERSITY_DELAY_AM (18000 * 3)
7+
#define DIVERSITY_DELAY_AM 3
8+
#define BL_LENGTH 18000
9+
#define BU_LENGTH 18000
10+
#define ML_LENGTH 18000
11+
#define MU_LENGTH 18000
12+
#define EL_LENGTH 12000
13+
#define EU_LENGTH 24000
14+
#define EBL_LENGTH 18000
15+
#define EBU_LENGTH 18000
16+
#define EML_LENGTH 18000
17+
#define EMU_LENGTH 18000
818

919
typedef struct
1020
{
@@ -34,16 +44,16 @@ typedef struct
3444
unsigned int am_errors;
3545
unsigned int am_diversity_wait;
3646

37-
uint8_t bl[18000];
38-
uint8_t bu[18000];
39-
uint8_t ml[18000 + DIVERSITY_DELAY_AM];
40-
uint8_t mu[18000 + DIVERSITY_DELAY_AM];
41-
uint8_t el[12000];
42-
uint8_t eu[24000];
43-
uint8_t ebl[18000];
44-
uint8_t ebu[18000];
45-
uint8_t eml[18000 + DIVERSITY_DELAY_AM];
46-
uint8_t emu[18000 + DIVERSITY_DELAY_AM];
47+
uint8_t bl[BL_LENGTH];
48+
uint8_t bu[BU_LENGTH];
49+
uint8_t ml[ML_LENGTH * (1 + DIVERSITY_DELAY_AM)];
50+
uint8_t mu[MU_LENGTH * (1 + DIVERSITY_DELAY_AM)];
51+
uint8_t el[EL_LENGTH * (1 + DIVERSITY_DELAY_AM)];
52+
uint8_t eu[EU_LENGTH * (1 + DIVERSITY_DELAY_AM)];
53+
uint8_t ebl[EBL_LENGTH];
54+
uint8_t ebu[EBU_LENGTH];
55+
uint8_t eml[EML_LENGTH * (1 + DIVERSITY_DELAY_AM)];
56+
uint8_t emu[EMU_LENGTH * (1 + DIVERSITY_DELAY_AM)];
4757

4858
int8_t viterbi_p1[P1_FRAME_LEN_FM * 3];
4959
uint8_t scrambler_p1[P1_FRAME_LEN_FM];

0 commit comments

Comments
 (0)