FreeCalypso > hg > gsm-codec-lib
view libgsmfr2/sidclass.c @ 477:4c9222d95647
libtwamr encoder: always emit frame->mode = mode;
In the original implementation of amr_encode_frame(), the 'mode' member
of the output struct was set to 0xFF if the output frame type is TX_NO_DATA.
This design was made to mimic the mode field (16-bit word) being set to
0xFFFF (or -1) in 3GPP test sequence format - but nothing actually depends
on this struct member being set in any way, and amr_frame_to_tseq()
generates the needed 0xFFFF on its own, based on frame->type being equal
to TX_NO_DATA.
It is simpler and more efficient to always set frame->mode to the actual
encoding mode in amr_encode_frame(), and this new behavior has already
been documented in doc/AMR-library-API description in anticipation of
the present change.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 May 2024 22:30:42 +0000 |
parents | a33edf624061 |
children |
line wrap: on
line source
/* * gsmfr_preproc_sid_classify() utility function classifies * a GSM 06.10 frame in RTP encoding according to the rules * of GSM 06.31 (or 3GPP TS 46.031) section 6.1.1, judging it * as SID=0, SID=1 or SID=2. */ #include <stdint.h> #include "tw_gsmfr.h" static const unsigned short sid_field_bits[95] = { 57, 58, 60, 61, 63, 64, 66, 67, 69, 70, 72, 73, 75, 76, 78, 79, 81, 82, 84, 85, 87, 88, 90, 91, 93, 94, 113, 114, 116, 117, 119, 120, 122, 123, 125, 126, 128, 129, 131, 132, 134, 135, 137, 138, 140, 141, 143, 144, 146, 147, 149, 150, 169, 170, 172, 173, 175, 176, 178, 179, 181, 182, 184, 185, 187, 188, 190, 191, 193, 194, 196, 197, 199, 200, 202, 203, 205, 206, 225, 226, 228, 229, 231, 232, 234, 235, 237, 240, 243, 246, 249, 252, 255, 258, 261 }; static inline int get_bit(const uint8_t *frame, unsigned bitnum) { unsigned bytenum = bitnum >> 3; unsigned bit_in_byte = 7 - (bitnum & 7); unsigned bitmask = 1 << bit_in_byte; if (frame[bytenum] & bitmask) return 1; else return 0; } int gsmfr_preproc_sid_classify(const uint8_t *frame) { unsigned idx, n; n = 0; for (idx = 0; idx < 95; idx++) { if (get_bit(frame, sid_field_bits[idx])) n++; if (n >= 16) return 0; } if (n < 2) return 2; else return 1; }