# HG changeset patch # User Mychaela Falconia # Date 1724612403 0 # Node ID 03a40ac2e931a9bf956175b0c86993673448f360 # Parent 4f0ab833bec0a7aad4309f0c9fcd64d8ebb68ed4 libgsmhr1: implement validation for *.cod frames diff -r 4f0ab833bec0 -r 03a40ac2e931 libgsmhr1/Makefile --- a/libgsmhr1/Makefile Sun Aug 25 18:42:27 2024 +0000 +++ b/libgsmhr1/Makefile Sun Aug 25 19:00:03 2024 +0000 @@ -1,6 +1,7 @@ OBJS= dhf_packed.o dhf_params.o enc_out_order.o mathdp31.o mathhalf.o \ - pack_frame.o paramval_common.o rtp_in.o rtp_in_direct.o sid_detect.o \ - sid_reset.o sp_rom.o twts002_in.o twts002_out.o unpack_frame.o + pack_frame.o paramval_cod.o paramval_common.o rtp_in.o rtp_in_direct.o \ + sid_detect.o sid_reset.o sp_rom.o twts002_in.o twts002_out.o \ + unpack_frame.o HDRS= enc_out_order.h mathdp31.h mathhalf.h namespace.h sp_rom.h tw_gsmhr.h \ typedefs.h LIB= libgsmhr1.a diff -r 4f0ab833bec0 -r 03a40ac2e931 libgsmhr1/paramval_cod.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmhr1/paramval_cod.c Sun Aug 25 19:00:03 2024 +0000 @@ -0,0 +1,19 @@ +/* + * The function implemented in this module examines a frame of 20 int16_t words + * that corresponds to GSM-HR encoder output format, and checks if the unused + * upper bits of each int16_t word are cleared as they should be. + * This function should be used when reading from ETSI-format *.cod files, + * to guard against reading garbage or wrong endian. + */ + +#include +#include "tw_gsmhr.h" + +int gsmhr_check_encoder_params(const int16_t *params) +{ + if (params[18] & 0xFFFE) + return -1; + if (params[19] & 0xFFFE) + return -1; + return gsmhr_check_common_params(params); +}