sipr.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * SIPR / ACELP.NET decoder
  3. *
  4. * Copyright (c) 2008 Vladimir Voroshilov
  5. * Copyright (c) 2009 Vitor Sessak
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_SIPR_H
  24. #define AVCODEC_SIPR_H
  25. #include "avcodec.h"
  26. #include "acelp_pitch_delay.h"
  27. #include "libavutil/mem.h"
  28. #define LP_FILTER_ORDER_16k 16
  29. #define L_SUBFR_16k 80
  30. #define PITCH_MIN 30
  31. #define PITCH_MAX 281
  32. #define LSFQ_DIFF_MIN (0.0125 * M_PI)
  33. #define LP_FILTER_ORDER 10
  34. /** Number of past samples needed for excitation interpolation */
  35. #define L_INTERPOL (LP_FILTER_ORDER + 1)
  36. /** Subframe size for all modes except 16k */
  37. #define SUBFR_SIZE 48
  38. #define SUBFRAME_COUNT_16k 2
  39. typedef enum {
  40. MODE_16k,
  41. MODE_8k5,
  42. MODE_6k5,
  43. MODE_5k0,
  44. MODE_COUNT
  45. } SiprMode;
  46. typedef struct SiprParameters {
  47. int ma_pred_switch; ///< switched moving average predictor
  48. int vq_indexes[5];
  49. int pitch_delay[5]; ///< pitch delay
  50. int gp_index[5]; ///< adaptive-codebook gain indexes
  51. int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
  52. int gc_index[5]; ///< fixed-codebook gain indexes
  53. } SiprParameters;
  54. typedef struct SiprContext {
  55. AVCodecContext *avctx;
  56. SiprMode mode;
  57. float past_pitch_gain;
  58. float lsf_history[LP_FILTER_ORDER_16k];
  59. float excitation[L_INTERPOL + PITCH_MAX + 2 * L_SUBFR_16k];
  60. DECLARE_ALIGNED(16, float, synth_buf)[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6];
  61. float lsp_history[LP_FILTER_ORDER];
  62. float gain_mem;
  63. float energy_history[4];
  64. float highpass_filt_mem[2];
  65. float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
  66. /* 5k0 */
  67. float tilt_mem;
  68. float postfilter_agc;
  69. float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
  70. float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
  71. /* 16k */
  72. int pitch_lag_prev;
  73. float iir_mem[LP_FILTER_ORDER_16k+1];
  74. float filt_buf[2][LP_FILTER_ORDER_16k+1];
  75. float *filt_mem[2];
  76. float mem_preemph[LP_FILTER_ORDER_16k];
  77. float synth[LP_FILTER_ORDER_16k];
  78. double lsp_history_16k[16];
  79. void (*decode_frame)(struct SiprContext *ctx, SiprParameters *params,
  80. float *out_data);
  81. } SiprContext;
  82. extern const float ff_pow_0_5[16];
  83. void ff_sipr_init_16k(SiprContext *ctx);
  84. void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params,
  85. float *out_data);
  86. #endif /* AVCODEC_SIPR_H */