FreeCalypso > hg > gsm-codec-lib
view libtwamr/tseq_out.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 | eced57698c03 |
children |
line wrap: on
line source
/* * In this module we implement encoder output conversion to 3GPP * test sequence format. */ #include <stdint.h> #include <string.h> #include "tw_amr.h" #include "namespace.h" #include "typedef.h" #include "cnst.h" #include "prm2bits.h" void amr_frame_to_tseq(const struct amr_param_frame *frame, uint16_t *cod) { enum Mode pack_mode; cod[0] = frame->type; memset(cod + 1, 0, (AMR_COD_WORDS-1) * sizeof(uint16_t)); switch (frame->type) { case TX_SPEECH_GOOD: pack_mode = frame->mode; cod[MAX_SERIAL_SIZE+1] = frame->mode; break; case TX_SID_FIRST: case TX_SID_UPDATE: pack_mode = MRDTX; cod[MAX_SERIAL_SIZE+1] = frame->mode; break; case TX_NO_DATA: pack_mode = MRDTX; cod[MAX_SERIAL_SIZE+1] = 0xFFFF; break; default: /* invalid usage, not allowed! */ return; } Prm2bits(pack_mode, frame->param, (Word16 *)(cod + 1)); }