# HG changeset patch # User Mychaela Falconia # Date 1718666059 0 # Node ID aaf4dec8bee0e4ed81e41a1ddd883fbb17b9c2bd # Parent dc7249923b3a9d76e4fbced280330534fd975ed7 libgsmhr1: implement perfect SID detection diff -r dc7249923b3a -r aaf4dec8bee0 libgsmhr1/Makefile --- a/libgsmhr1/Makefile Mon Jun 17 23:00:57 2024 +0000 +++ b/libgsmhr1/Makefile Mon Jun 17 23:14:19 2024 +0000 @@ -1,4 +1,5 @@ -OBJS= pack_frame.o rtp_in.o twts002_in.o twts002_out.o unpack_frame.o +OBJS= pack_frame.o rtp_in.o sid_detect.o twts002_in.o twts002_out.o \ + unpack_frame.o HDRS= tw_gsmhr.h LIB= libgsmhr1.a diff -r dc7249923b3a -r aaf4dec8bee0 libgsmhr1/sid_detect.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmhr1/sid_detect.c Mon Jun 17 23:14:19 2024 +0000 @@ -0,0 +1,22 @@ +/* + * The function in this module implements detection of perfect, error-free + * HRv1 SID frames in TS 101 318 raw packed format. If SID is detected, + * the return value is 2: the code for valid SID per GSM 06.41. + */ + +#include +#include +#include "tw_gsmhr.h" + +int gsmhr_ts101318_is_perfect_sid(const uint8_t *payload) +{ + static const uint8_t all_ff_bytes[9] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + + if ((payload[4] & 0x7F) != 0x7F) + return 0; + if (memcmp(payload + 5, all_ff_bytes, 9) == 0) + return 2; + else + return 0; +}