# HG changeset patch # User Mychaela Falconia # Date 1714944863 0 # Node ID e4ce7972737f0229d798dd50439c3644e74a1984 # Parent b252d74da6c65f7992bc3ccefa83e06b4b5480e2 libtwamr: add DHF tables diff -r b252d74da6c6 -r e4ce7972737f libtwamr/Makefile --- a/libtwamr/Makefile Sun May 05 21:32:59 2024 +0000 +++ b/libtwamr/Makefile Sun May 05 21:34:23 2024 +0000 @@ -4,10 +4,10 @@ bitno.o bits2prm.o c1035pf.o c2_11pf.o c2_9pf.o c3_14pf.o c4_17pf.o \ c8_31pf.o c_g_aver.o calc_cor.o calc_en.o cbsearch.o convolve.o cor_h.o\ d1035pf.o d2_11pf.o d2_9pf.o d3_14pf.o d4_17pf.o d8_31pf.o d_gain_c.o \ - d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o gains_tab.o gc_pred.o \ - gmed_n.o graytab.o inv_sqrt.o log2.o lsp_lsf.o oper_32b.o pow2.o \ - prmno.o q_plsf3_tab.o q_plsf5_tab.o reorder.o s10_8pf.o set_sign.o \ - sqrt_l.o tls_flags.o window.o + d_gain_p.o d_plsf.o d_plsf_3.o d_plsf_5.o dhf_tables.o gains_tab.o \ + gc_pred.o gmed_n.o graytab.o inv_sqrt.o log2.o lsp_lsf.o oper_32b.o \ + pow2.o prmno.o q_plsf3_tab.o q_plsf5_tab.o reorder.o s10_8pf.o \ + set_sign.o sqrt_l.o tls_flags.o window.o HDRS= namespace.h LIB= libtwamr.a diff -r b252d74da6c6 -r e4ce7972737f libtwamr/dhf_tables.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libtwamr/dhf_tables.c Sun May 05 21:34:23 2024 +0000 @@ -0,0 +1,315 @@ +/* + * This module holds const data tables of all supported DHFs: + * 8 per-mode DHFs for AMR plus the different DHF for GSM-EFR. + */ + +#include "tw_amr.h" + +const int16_t amr_dhf_mr475[AMR_MAX_PRM] = +{ + 0x00F8, + 0x009D, + 0x001C, + 0x0066, + 0x0000, + 0x0003, + 0x0028, + 0x000F, + 0x0038, + 0x0001, + 0x000F, + 0x0031, + 0x0002, + 0x0008, + 0x000F, + 0x0026, + 0x0003 +}; + +const int16_t amr_dhf_mr515[AMR_MAX_PRM] = +{ + 0x00F8, + 0x009D, + 0x001C, + 0x0066, + 0x0000, + 0x0003, + 0x0037, + 0x000F, + 0x0000, + 0x0003, + 0x0005, + 0x000F, + 0x0037, + 0x0003, + 0x0037, + 0x000F, + 0x0023, + 0x0003, + 0x001F +}; + +const int16_t amr_dhf_mr59[AMR_MAX_PRM] = +{ + 0x00F8, + 0x00E3, + 0x002F, + 0x00BD, + 0x0000, + 0x0003, + 0x0037, + 0x000F, + 0x0001, + 0x0003, + 0x000F, + 0x0060, + 0x00F9, + 0x0003, + 0x0037, + 0x000F, + 0x0000, + 0x0003, + 0x0037 +}; + +const int16_t amr_dhf_mr67[AMR_MAX_PRM] = +{ + 0x00F8, + 0x00E3, + 0x002F, + 0x00BD, + 0x0002, + 0x0007, + 0x0000, + 0x000F, + 0x0098, + 0x0007, + 0x0061, + 0x0060, + 0x05C5, + 0x0007, + 0x0000, + 0x000F, + 0x0318, + 0x0007, + 0x0000 +}; + +const int16_t amr_dhf_mr74[AMR_MAX_PRM] = +{ + 0x00F8, + 0x00E3, + 0x002F, + 0x00BD, + 0x0006, + 0x000F, + 0x0000, + 0x001B, + 0x0208, + 0x000F, + 0x0062, + 0x0060, + 0x1BA6, + 0x000F, + 0x0000, + 0x001B, + 0x0006, + 0x000F, + 0x0000 +}; + +const int16_t amr_dhf_mr795[AMR_MAX_PRM] = +{ + 0x00C2, + 0x00E3, + 0x002F, + 0x00BD, + 0x0006, + 0x000F, + 0x000A, + 0x0000, + 0x0039, + 0x1C08, + 0x0007, + 0x000A, + 0x000B, + 0x0063, + 0x11A6, + 0x000F, + 0x0001, + 0x0000, + 0x0039, + 0x09A0, + 0x000F, + 0x0002, + 0x0001 +}; + +const int16_t amr_dhf_mr102[AMR_MAX_PRM] = +{ + 0x00F8, + 0x00E3, + 0x002F, + 0x0045, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x001B, + 0x0000, + 0x0001, + 0x0000, + 0x0001, + 0x0326, + 0x00CE, + 0x007E, + 0x0051, + 0x0062, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x015A, + 0x0359, + 0x0076, + 0x0000, + 0x001B, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x017C, + 0x0215, + 0x0038, + 0x0030 +}; + +const int16_t amr_dhf_mr122[AMR_MAX_PRM] = +{ + 0x0004, + 0x002A, + 0x00DB, + 0x0096, + 0x002A, + 0x0156, + 0x000B, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0036, + 0x000B, + 0x0000, + 0x000F, + 0x000E, + 0x000C, + 0x000D, + 0x0000, + 0x0001, + 0x0005, + 0x0007, + 0x0001, + 0x0008, + 0x0024, + 0x0000, + 0x0001, + 0x0000, + 0x0005, + 0x0006, + 0x0001, + 0x0002, + 0x0004, + 0x0007, + 0x0004, + 0x0002, + 0x0003, + 0x0036, + 0x000B, + 0x0000, + 0x0002, + 0x0004, + 0x0000, + 0x0003, + 0x0006, + 0x0001, + 0x0007, + 0x0006, + 0x0005, + 0x0000 +}; + +const int16_t amr_dhf_gsmefr[AMR_MAX_PRM] = +{ + 0x0004, /* LPC 1 */ + 0x002f, /* LPC 2 */ + 0x00b4, /* LPC 3 */ + 0x0090, /* LPC 4 */ + 0x003e, /* LPC 5 */ + + 0x0156, /* LTP-LAG 1 */ + 0x000b, /* LTP-GAIN 1 */ + 0x0000, /* PULSE 1_1 */ + 0x0001, /* PULSE 1_2 */ + 0x000f, /* PULSE 1_3 */ + 0x0001, /* PULSE 1_4 */ + 0x000d, /* PULSE 1_5 */ + 0x0000, /* PULSE 1_6 */ + 0x0003, /* PULSE 1_7 */ + 0x0000, /* PULSE 1_8 */ + 0x0003, /* PULSE 1_9 */ + 0x0000, /* PULSE 1_10 */ + 0x0003, /* FCB-GAIN 1 */ + + 0x0036, /* LTP-LAG 2 */ + 0x0001, /* LTP-GAIN 2 */ + 0x0008, /* PULSE 2_1 */ + 0x0008, /* PULSE 2_2 */ + 0x0005, /* PULSE 2_3 */ + 0x0008, /* PULSE 2_4 */ + 0x0001, /* PULSE 2_5 */ + 0x0000, /* PULSE 2_6 */ + 0x0000, /* PULSE 2_7 */ + 0x0001, /* PULSE 2_8 */ + 0x0001, /* PULSE 2_9 */ + 0x0000, /* PULSE 2_10 */ + 0x0000, /* FCB-GAIN 2 */ + + 0x0156, /* LTP-LAG 3 */ + 0x0000, /* LTP-GAIN 3 */ + 0x0000, /* PULSE 3_1 */ + 0x0000, /* PULSE 3_2 */ + 0x0000, /* PULSE 3_3 */ + 0x0000, /* PULSE 3_4 */ + 0x0000, /* PULSE 3_5 */ + 0x0000, /* PULSE 3_6 */ + 0x0000, /* PULSE 3_7 */ + 0x0000, /* PULSE 3_8 */ + 0x0000, /* PULSE 3_9 */ + 0x0000, /* PULSE 3_10 */ + 0x0000, /* FCB-GAIN 3 */ + + 0x0036, /* LTP-LAG 4 */ + 0x000b, /* LTP-GAIN 4 */ + 0x0000, /* PULSE 4_1 */ + 0x0000, /* PULSE 4_2 */ + 0x0000, /* PULSE 4_3 */ + 0x0000, /* PULSE 4_4 */ + 0x0000, /* PULSE 4_5 */ + 0x0000, /* PULSE 4_6 */ + 0x0000, /* PULSE 4_7 */ + 0x0000, /* PULSE 4_8 */ + 0x0000, /* PULSE 4_9 */ + 0x0000, /* PULSE 4_10 */ + 0x0000 /* FCB-GAIN 4 */ +}; diff -r b252d74da6c6 -r e4ce7972737f libtwamr/tw_amr.h --- a/libtwamr/tw_amr.h Sun May 05 21:32:59 2024 +0000 +++ b/libtwamr/tw_amr.h Sun May 05 21:34:23 2024 +0000 @@ -94,4 +94,20 @@ int amr_frame_from_tseq(const uint16_t *cod, int use_rxtype, struct amr_param_frame *frame); +/* stateless functions and const data for DHF detection */ + +int amr_check_dhf(const struct amr_param_frame *frame, int first_sub_only); + +void amr_dhf_subst_efr(struct amr_param_frame *frame); + +extern const int16_t amr_dhf_mr475[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr515[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr59[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr67[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr74[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr795[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr102[AMR_MAX_PRM]; +extern const int16_t amr_dhf_mr122[AMR_MAX_PRM]; +extern const int16_t amr_dhf_gsmefr[AMR_MAX_PRM]; + #endif /* include guard */