FreeCalypso > hg > gsm-codec-lib
view amrtest/mode_file.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 | 1ceda5586d01 |
children |
line wrap: on
line source
/* * The functions in this module implement reading per-frame encoder mode * instructions from a file, as in 3GPP test sequences and code. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include "../libtwamr/tw_amr.h" static FILE *mode_file; static int lineno; static char *filename_for_errs; void open_mode_file(filename) char *filename; { mode_file = fopen(filename, "r"); if (!mode_file) { perror(filename); exit(1); } } void read_mode_file_line(mode_out) enum Mode *mode_out; { char linebuf[16], *cp; int rc; if (!fgets(linebuf, sizeof linebuf, mode_file)) { fprintf(stderr, "error: %s ends before speech input\n", filename_for_errs); exit(1); } lineno++; cp = index(linebuf, '\n'); if (!cp) { fprintf(stderr, "%s line %d: too long or missing newline\n", filename_for_errs, lineno); exit(1); } if (cp > linebuf && cp[-1] == '\r') cp--; *cp = '\0'; rc = grok_mode_name(linebuf, mode_out); if (rc < 0) { fprintf(stderr, "%s line %d: invalid mode setting\n", filename_for_errs, lineno); exit(1); } }