FreeCalypso > hg > gsm-codec-lib
changeset 265:a7b593e68ac3
libgsmfr2: integrate encoder main function from libgsm
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 00:24:21 +0000 |
parents | 8b21a6b7a3bf |
children | 8821ffaa93a5 |
files | libgsmfr2/Makefile libgsmfr2/add.c libgsmfr2/enc_main.c |
diffstat | 3 files changed, 67 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libgsmfr2/Makefile Sun Apr 14 00:06:50 2024 +0000 +++ b/libgsmfr2/Makefile Sun Apr 14 00:24:21 2024 +0000 @@ -1,8 +1,8 @@ CC= gcc CFLAGS= -O2 -OBJS= add.o comfort_noise.o ed_state.o pack_frame.o pack_frame2.o pp_bad.o \ - pp_good.o pp_state.o prng.o sidclass.o silence_frame.o unpack_frame.o \ - unpack_frame2.o xmaxc_mean.o +OBJS= add.o comfort_noise.o ed_state.o enc_main.o pack_frame.o pack_frame2.o \ + pp_bad.o pp_good.o pp_state.o prng.o sidclass.o silence_frame.o \ + unpack_frame.o unpack_frame2.o xmaxc_mean.o HDRS= ed_internal.h ed_state.h pp_internal.h pp_state.h tw_gsmfr.h typedef.h LIB= libgsmfr2.a
--- a/libgsmfr2/add.c Sun Apr 14 00:06:50 2024 +0000 +++ b/libgsmfr2/add.c Sun Apr 14 00:24:21 2024 +0000 @@ -9,7 +9,6 @@ #include <stdint.h> #include <assert.h> -#include <string.h> #include "tw_gsmfr.h" #include "typedef.h" #include "ed_state.h"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgsmfr2/enc_main.c Sun Apr 14 00:24:21 2024 +0000 @@ -0,0 +1,64 @@ +/* + * This C source file has been adapted from TU-Berlin libgsm source + * (src/code.c), original notice follows: + * + * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische + * Universitaet Berlin. See the accompanying file "COPYRIGHT" for + * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. + */ + +#include <stdint.h> +#include <string.h> +#include "tw_gsmfr.h" +#include "typedef.h" +#include "ed_state.h" +#include "ed_internal.h" + +/* + * 4.2 FIXED POINT IMPLEMENTATION OF THE RPE-LTP CODER + */ + +void gsmfr_0610_encode_params(struct gsmfr_0610_state *S, const int16_t *s, + struct gsmfr_param_frame *outp) +{ + int k; + word * dp = S->dp0 + 120; /* [ -120...-1 ] */ + word * dpp = dp; /* [ 0...39 ] */ + + word so[160]; + + Gsm_Preprocess (S, s, so); + Gsm_LPC_Analysis (S, so, outp->LARc); + Gsm_Short_Term_Analysis_Filter (S, outp->LARc, so); + + for (k = 0; k <= 3; k++) { + + Gsm_Long_Term_Predictor ( S, + so+k*40, /* d [0..39] IN */ + dp, /* dp [-120..-1] IN */ + S->e + 5, /* e [0..39] OUT */ + dpp, /* dpp [0..39] OUT */ + &outp->Nc[k], + &outp->bc[k]); + + Gsm_RPE_Encoding ( S, + S->e + 5,/* e ][0..39][ IN/OUT */ + &outp->xmaxc[k], &outp->Mc[k], + outp->xMc[k] ); + /* + * Gsm_Update_of_reconstructed_short_time_residual_signal + * ( dpp, S->e + 5, dp ); + */ + + { register int i; + register longword ltmp; + for (i = 0; i <= 39; i++) + dp[ i ] = GSM_ADD( S->e[5 + i], dpp[i] ); + } + dp += 40; + dpp += 40; + + } + (void)memcpy( (char *)S->dp0, (char *)(S->dp0 + 160), + 120 * sizeof(*S->dp0) ); +}