Make sure sync header was fully received
The sync header consists of 16 zero-bits followed by 1 one-bit. Before, subchan_demux only tested for the 16 zero-bits. But if the previous frame ended in one or more zero-bits these were then already counted as belonging to the sync header, leading to a frame that was shifted by one or more bits.
This commit is contained in:
parent
d72c478b06
commit
08c103251c
|
@ -46,18 +46,18 @@ static inline void append_bit(struct demux_subch *sch, uint8_t bit)
|
|||
#define SYNC_HDR_BITS 16
|
||||
static const uint8_t nullbytes[SYNC_HDR_BITS];
|
||||
|
||||
/* check if we have just completed the 16 bit zero sync header,
|
||||
* in accordance with GSM TS 08.60 Chapter 4.8.1 */
|
||||
/* check if we have just completed the 16 bit zero + 1 bit one sync
|
||||
* header, in accordance with GSM TS 08.60 Chapter 4.8.1 */
|
||||
static int sync_hdr_complete(struct demux_subch *sch, uint8_t bit)
|
||||
{
|
||||
if (bit == 0)
|
||||
sch->consecutive_zeros++;
|
||||
else
|
||||
else {
|
||||
if (sch->consecutive_zeros >= SYNC_HDR_BITS) {
|
||||
sch->consecutive_zeros = 0;
|
||||
return 1;
|
||||
}
|
||||
sch->consecutive_zeros = 0;
|
||||
|
||||
if (sch->consecutive_zeros >= SYNC_HDR_BITS) {
|
||||
sch->consecutive_zeros = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -67,10 +67,11 @@ static int sync_hdr_complete(struct demux_subch *sch, uint8_t bit)
|
|||
static void resync_to_here(struct demux_subch *sch)
|
||||
{
|
||||
memset(sch->out_bitbuf, 0, SYNC_HDR_BITS);
|
||||
sch->out_bitbuf[SYNC_HDR_BITS] = 1;
|
||||
|
||||
/* set index in a way that we can continue receiving bits after
|
||||
* the end of the SYNC header */
|
||||
sch->out_idx = SYNC_HDR_BITS;
|
||||
sch->out_idx = SYNC_HDR_BITS + 1;
|
||||
sch->in_sync = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue