]> git.sesse.net Git - ffmpeg/blob - libavcodec/g722.h
5edb6c811901aa59bc1277a7a820b9606c49c7c2
[ffmpeg] / libavcodec / g722.h
1 /*
2  * Copyright (c) CMU 1993 Computer Science, Speech Group
3  *                        Chengxiang Lu and Alex Hauptmann
4  * Copyright (c) 2005 Steve Underwood <steveu at coppice.org>
5  * Copyright (c) 2009 Kenan Gillet
6  * Copyright (c) 2010 Martin Storsjo
7  *
8  * This file is part of Libav.
9  *
10  * Libav is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * Libav is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with Libav; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24
25 #ifndef AVCODEC_G722_H
26 #define AVCODEC_G722_H
27
28 #include <stdint.h>
29
30 #define PREV_SAMPLES_BUF_SIZE 1024
31
32 typedef struct {
33     int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples
34     int     prev_samples_pos;        ///< the number of values in prev_samples
35
36     /**
37      * The band[0] and band[1] correspond respectively to the lower band and higher band.
38      */
39     struct G722Band {
40         int16_t s_predictor;         ///< predictor output value
41         int32_t s_zero;              ///< previous output signal from zero predictor
42         int8_t  part_reconst_mem[2]; ///< signs of previous partially reconstructed signals
43         int16_t prev_qtzd_reconst;   ///< previous quantized reconstructed signal (internal value, using low_inv_quant4)
44         int16_t pole_mem[2];         ///< second-order pole section coefficient buffer
45         int32_t diff_mem[6];         ///< quantizer difference signal memory
46         int16_t zero_mem[6];         ///< Seventh-order zero section coefficient buffer
47         int16_t log_factor;          ///< delayed 2-logarithmic quantizer factor
48         int16_t scale_factor;        ///< delayed quantizer scale factor
49     } band[2];
50
51     struct TrellisNode {
52         struct G722Band state;
53         uint32_t ssd;
54         int path;
55     } *node_buf[2], **nodep_buf[2];
56
57     struct TrellisPath {
58         int value;
59         int prev;
60     } *paths[2];
61 } G722Context;
62
63 extern const int16_t ff_g722_high_inv_quant[4];
64 extern const int16_t ff_g722_low_inv_quant4[16];
65 extern const int16_t ff_g722_low_inv_quant6[64];
66
67 void ff_g722_update_low_predictor(struct G722Band *band, const int ilow);
68
69 void ff_g722_update_high_predictor(struct G722Band *band, const int dhigh,
70                                    const int ihigh);
71
72 void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2);
73
74 #endif /* AVCODEC_G722_H */