avformat/mpeg: demux ivtv captions
[ffmpeg.git] / libavcodec / sipr.h
blobe7073987ed221e4685e620f46ec3380eb7472143
1 /*
2 * SIPR / ACELP.NET decoder
4 * Copyright (c) 2008 Vladimir Voroshilov
5 * Copyright (c) 2009 Vitor Sessak
7 * This file is part of FFmpeg.
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.
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.
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
24 #ifndef AVCODEC_SIPR_H
25 #define AVCODEC_SIPR_H
27 #include "acelp_pitch_delay.h"
28 #include "libavutil/mem_internal.h"
30 #define LP_FILTER_ORDER_16k 16
31 #define L_SUBFR_16k 80
32 #define PITCH_MIN 30
33 #define PITCH_MAX 281
35 #define LSFQ_DIFF_MIN (0.0125 * M_PI)
37 #define LP_FILTER_ORDER 10
39 /** Number of past samples needed for excitation interpolation */
40 #define L_INTERPOL (LP_FILTER_ORDER + 1)
42 /** Subframe size for all modes except 16k */
43 #define SUBFR_SIZE 48
45 #define SUBFRAME_COUNT_16k 2
47 typedef enum {
48 MODE_16k,
49 MODE_8k5,
50 MODE_6k5,
51 MODE_5k0,
52 MODE_COUNT
53 } SiprMode;
55 typedef struct SiprParameters {
56 int ma_pred_switch; ///< switched moving average predictor
57 int vq_indexes[5];
58 int pitch_delay[5]; ///< pitch delay
59 int gp_index[5]; ///< adaptive-codebook gain indexes
60 int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
61 int gc_index[5]; ///< fixed-codebook gain indexes
62 } SiprParameters;
64 typedef struct SiprContext {
65 SiprMode mode;
67 float past_pitch_gain;
68 float lsf_history[LP_FILTER_ORDER_16k];
70 float excitation[L_INTERPOL + PITCH_MAX + 2 * L_SUBFR_16k];
72 DECLARE_ALIGNED(16, float, synth_buf)[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6];
74 float lsp_history[LP_FILTER_ORDER];
75 float gain_mem;
76 float energy_history[4];
77 float highpass_filt_mem[2];
78 float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
80 /* 5k0 */
81 float tilt_mem;
82 float postfilter_agc;
83 float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
84 float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
86 /* 16k */
87 int pitch_lag_prev;
88 float iir_mem[LP_FILTER_ORDER_16k+1];
89 float filt_buf[2][LP_FILTER_ORDER_16k+1];
90 float *filt_mem[2];
91 float mem_preemph[LP_FILTER_ORDER_16k];
92 float synth[LP_FILTER_ORDER_16k];
93 double lsp_history_16k[16];
95 void (*decode_frame)(struct SiprContext *ctx, SiprParameters *params,
96 float *out_data);
97 } SiprContext;
99 extern const float ff_pow_0_5[16];
101 void ff_sipr_init_16k(SiprContext *ctx);
103 void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params,
104 float *out_data);
106 #endif /* AVCODEC_SIPR_H */