annotate libgsmefr/enc_wrap.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 269d341db403
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains our EFR_encode_frame() function, which is the primary
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * (most common, most useful) interface to our EFR encoder.
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "gsm_efr.h"
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 void EFR_encode_frame(struct EFR_encoder_state *st, const int16_t *pcm_in,
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 uint8_t *frame, int *sp_out, int *vad_out)
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 int16_t params[EFR_NUM_PARAMS];
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 int sp;
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 EFR_encode_params(st, pcm_in, params, &sp, vad_out);
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 EFR_params2frame(params, frame);
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (!sp)
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 EFR_insert_sid_codeword(frame);
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (sp_out)
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *sp_out = sp;
269d341db403 libgsmefr: implement main encoder wrapper
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }