# HG changeset patch # User Mychaela Falconia # Date 1669255077 0 # Node ID 88468d5b3590c435f19b7e2d7cb6a1704c73509a # Parent 9639a44ae2e7ae2fb60fe8b89766cf5dac8e3add libgsmefr: implement frame packing diff -r 9639a44ae2e7 -r 88468d5b3590 libgsmefr/Makefile --- a/libgsmefr/Makefile Thu Nov 24 01:41:49 2022 +0000 +++ b/libgsmefr/Makefile Thu Nov 24 01:57:57 2022 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -OBJS= sidclass.o +OBJS= params2frame.o sidclass.o LIB= libgsmefr.a INSTALL_PREFIX= /usr/local diff -r 9639a44ae2e7 -r 88468d5b3590 libgsmefr/gsm_efr.h --- a/libgsmefr/gsm_efr.h Thu Nov 24 01:41:49 2022 +0000 +++ b/libgsmefr/gsm_efr.h Thu Nov 24 01:57:57 2022 +0000 @@ -9,6 +9,9 @@ #include +#define EFR_RTP_FRAME_LEN 31 +#define EFR_NUM_PARAMS 57 + struct EFR_encoder_state; /* opaque to external users */ struct EFR_decoder_state; /* ditto */ @@ -41,6 +44,7 @@ extern int EFR_sid_classify(const uint8_t *frame); extern void EFR_frame2params(const uint8_t *frame, int16_t *params); -extern void EFR_params2frame(const int16_t *params, int sid, uint8_t *frame); +extern void EFR_params2frame(const int16_t *params, uint8_t *frame); +extern void EFR_insert_sid_codeword(uint8_t *frame); #endif /* include guard */ diff -r 9639a44ae2e7 -r 88468d5b3590 libgsmefr/params2frame.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmefr/params2frame.c Thu Nov 24 01:57:57 2022 +0000 @@ -0,0 +1,95 @@ +/* + * In this module we implement our EFR_params2frame() packing function. + */ + +#include "gsm_efr.h" + +#define EFR_MAGIC 0xC + +void EFR_params2frame(const int16_t *params, uint8_t *frame) +{ + uint8_t *c = frame; + + *c++ = ((EFR_MAGIC & 0xF) << 4) + | ((params[0] >> 3) & 0xF); + *c++ = ((params[0] & 0x7) << 5) + | ((params[1] >> 3) & 0x1F); + *c++ = ((params[1] & 0x7) << 5) + | ((params[2] >> 4) & 0x1F); + *c++ = ((params[2] & 0xF) << 4) + | ((params[3] >> 4) & 0xF); + *c++ = ((params[3] & 0xF) << 4) + | ((params[4] >> 2) & 0xF); + *c++ = ((params[4] & 0x3) << 6) + | ((params[5] >> 3) & 0x3F); + *c++ = ((params[5] & 0x7) << 5) + | ((params[6] & 0xF) << 1) + | ((params[7] >> 3) & 0x1); + *c++ = ((params[7] & 0x7) << 5) + | ((params[8] & 0xF) << 1) + | ((params[9] >> 3) & 0x1); + *c++ = ((params[9] & 0x7) << 5) + | ((params[10] & 0xF) << 1) + | ((params[11] >> 3) & 0x1); + *c++ = ((params[11] & 0x7) << 5) + | ((params[12] & 0x7) << 2) + | ((params[13] >> 1) & 0x3); + *c++ = ((params[13] & 0x1) << 7) + | ((params[14] & 0x7) << 4) + | ((params[15] & 0x7) << 1) + | ((params[16] >> 2) & 0x1); + *c++ = ((params[16] & 0x3) << 6) + | ((params[17] & 0x1F) << 1) + | ((params[18] >> 5) & 0x1); + *c++ = ((params[18] & 0x1F) << 3) + | ((params[19] >> 1) & 0x7); + *c++ = ((params[19] & 0x1) << 7) + | ((params[20] & 0xF) << 3) + | ((params[21] >> 1) & 0x7); + *c++ = ((params[21] & 0x1) << 7) + | ((params[22] & 0xF) << 3) + | ((params[23] >> 1) & 0x7); + *c++ = ((params[23] & 0x1) << 7) + | ((params[24] & 0xF) << 3) + | (params[25] & 0x7); + *c++ = ((params[26] & 0x7) << 5) + | ((params[27] & 0x7) << 2) + | ((params[28] >> 1) & 0x3); + *c++ = ((params[28] & 0x1) << 7) + | ((params[29] & 0x7) << 4) + | ((params[30] >> 1) & 0xF); + *c++ = ((params[30] & 0x1) << 7) + | ((params[31] >> 2) & 0x7F); + *c++ = ((params[31] & 0x3) << 6) + | ((params[32] & 0xF) << 2) + | ((params[33] >> 2) & 0x3); + *c++ = ((params[33] & 0x3) << 6) + | ((params[34] & 0xF) << 2) + | ((params[35] >> 2) & 0x3); + *c++ = ((params[35] & 0x3) << 6) + | ((params[36] & 0xF) << 2) + | ((params[37] >> 2) & 0x3); + *c++ = ((params[37] & 0x3) << 6) + | ((params[38] & 0x7) << 3) + | (params[39] & 0x7); + *c++ = ((params[40] & 0x7) << 5) + | ((params[41] & 0x7) << 2) + | ((params[42] >> 1) & 0x3); + *c++ = ((params[42] & 0x1) << 7) + | ((params[43] & 0x1F) << 2) + | ((params[44] >> 4) & 0x3); + *c++ = ((params[44] & 0xF) << 4) + | (params[45] & 0xF); + *c++ = ((params[46] & 0xF) << 4) + | (params[47] & 0xF); + *c++ = ((params[48] & 0xF) << 4) + | (params[49] & 0xF); + *c++ = ((params[50] & 0xF) << 4) + | ((params[51] & 0x7) << 1) + | ((params[52] >> 2) & 0x1); + *c++ = ((params[52] & 0x3) << 6) + | ((params[53] & 0x7) << 3) + | (params[54] & 0x7); + *c++ = ((params[55] & 0x7) << 5) + | (params[56] & 0x1F); +}