annotate sipr.c @ 10886:966a8afdd9aa libavcodec

AAC: optimise bitstream reading in decode_spectrum_and_dequant() Using the low-level macros directly avoids redundant open/update/close cycles. 2-3% faster on ARM, PPC, and Core i7.
author mru
date Fri, 15 Jan 2010 14:02:52 +0000
parents fb42dfc877cc
children de32bff741ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
1 /*
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
2 * SIPR / ACELP.NET decoder
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
3 *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
4 * Copyright (c) 2008 Vladimir Voroshilov
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
5 * Copyright (c) 2009 Vitor Sessak
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
6 *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
7 * This file is part of FFmpeg.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
8 *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
9 * FFmpeg is free software; you can redistribute it and/or
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
10 * modify it under the terms of the GNU Lesser General Public
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
11 * License as published by the Free Software Foundation; either
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
12 * version 2.1 of the License, or (at your option) any later version.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
13 *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
14 * FFmpeg is distributed in the hope that it will be useful,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
17 * Lesser General Public License for more details.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
18 *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
19 * You should have received a copy of the GNU Lesser General Public
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
20 * License along with FFmpeg; if not, write to the Free Software
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
22 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
23
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
24 #include <math.h>
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
25 #include <stdint.h>
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
26
10873
fb42dfc877cc Remove needless use of log2f()
vitor
parents: 10872
diff changeset
27 #include "libavutil/mathematics.h"
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
28 #include "avcodec.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
29 #define ALT_BITSTREAM_READER_LE
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
30 #include "get_bits.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
31 #include "dsputil.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
32
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
33 #include "lsp.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
34 #include "celp_math.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
35 #include "acelp_vectors.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
36 #include "acelp_pitch_delay.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
37 #include "acelp_filters.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
38 #include "celp_filters.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
39
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
40 #define LSFQ_DIFF_MIN (0.0125 * M_PI)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
41
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
42 #define LP_FILTER_ORDER 10
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
43
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
44 /** Number of past samples needed for excitation interpolation */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
45 #define L_INTERPOL (LP_FILTER_ORDER + 1)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
46
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
47 /** Subframe size for all modes except 16k */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
48 #define SUBFR_SIZE 48
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
49
10871
c06d95ce2db0 SIPR: kill variable-length arrays
mru
parents: 10836
diff changeset
50 #define MAX_SUBFRAME_COUNT 5
c06d95ce2db0 SIPR: kill variable-length arrays
mru
parents: 10836
diff changeset
51
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
52 #include "siprdata.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
53
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
54 typedef enum {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
55 MODE_16k,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
56 MODE_8k5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
57 MODE_6k5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
58 MODE_5k0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
59 MODE_COUNT
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
60 } SiprMode;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
61
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
62 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
63 const char *mode_name;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
64 uint16_t bits_per_frame;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
65 uint8_t subframe_count;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
66 uint8_t frames_per_packet;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
67 float pitch_sharp_factor;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
68
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
69 /* bitstream parameters */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
70 uint8_t number_of_fc_indexes;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
71
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
72 /** size in bits of the i-th stage vector of quantizer */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
73 uint8_t vq_indexes_bits[5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
74
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
75 /** size in bits of the adaptive-codebook index for every subframe */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
76 uint8_t pitch_delay_bits[5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
77
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
78 uint8_t gp_index_bits;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
79 uint8_t fc_index_bits[10]; ///< size in bits of the fixed codebook indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
80 uint8_t gc_index_bits; ///< size in bits of the gain codebook indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
81 } SiprModeParam;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
82
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
83 static const SiprModeParam modes[MODE_COUNT] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
84 [MODE_8k5] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
85 .mode_name = "8k5",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
86 .bits_per_frame = 152,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
87 .subframe_count = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
88 .frames_per_packet = 1,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
89 .pitch_sharp_factor = 0.8,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
90
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
91 .number_of_fc_indexes = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
92 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
93 .pitch_delay_bits = {8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
94 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
95 .fc_index_bits = {9, 9, 9},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
96 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
97 },
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
98
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
99 [MODE_6k5] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
100 .mode_name = "6k5",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
101 .bits_per_frame = 232,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
102 .subframe_count = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
103 .frames_per_packet = 2,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
104 .pitch_sharp_factor = 0.8,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
105
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
106 .number_of_fc_indexes = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
107 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
108 .pitch_delay_bits = {8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
109 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
110 .fc_index_bits = {5, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
111 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
112 },
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
113
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
114 [MODE_5k0] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
115 .mode_name = "5k0",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
116 .bits_per_frame = 296,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
117 .subframe_count = 5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
118 .frames_per_packet = 2,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
119 .pitch_sharp_factor = 0.85,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
120
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
121 .number_of_fc_indexes = 1,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
122 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
123 .pitch_delay_bits = {8, 5, 8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
124 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
125 .fc_index_bits = {10},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
126 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
127 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
128 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
129
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
130 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
131 AVCodecContext *avctx;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
132 DSPContext dsp;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
133
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
134 SiprMode mode;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
135
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
136 float past_pitch_gain;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
137 float lsf_history[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
138
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
139 float excitation[L_INTERPOL + PITCH_DELAY_MAX + 5*SUBFR_SIZE];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
140
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
141 DECLARE_ALIGNED_16(float, synth_buf[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
142
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
143 float lsp_history[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
144 float gain_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
145 float energy_history[4];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
146 float highpass_filt_mem[2];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
147 float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
148
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
149 /* 5k0 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
150 float tilt_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
151 float postfilter_agc;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
152 float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
153 float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
154 } SiprContext;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
155
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
156 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
157 int vq_indexes[5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
158 int pitch_delay[5]; ///< pitch delay
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
159 int gp_index[5]; ///< adaptive-codebook gain indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
160 int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
161 int gc_index[5]; ///< fixed-codebook gain indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
162 } SiprParameters;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
163
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
164
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
165 static void dequant(float *out, const int *idx, const float *cbs[])
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
166 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
167 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
168 int stride = 2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
169 int num_vec = 5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
170
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
171 for (i = 0; i < num_vec; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
172 memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
173
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
174 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
175
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
176 static void lsf_decode_fp(float *lsfnew, float *lsf_history,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
177 const SiprParameters *parm)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
178 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
179 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
180 float lsf_tmp[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
181
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
182 dequant(lsf_tmp, parm->vq_indexes, lsf_codebooks);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
183
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
184 for (i = 0; i < LP_FILTER_ORDER; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
185 lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] + mean_lsf[i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
186
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
187 ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER - 1);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
188
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
189 /* Note that a minimum distance is not enforced between the last value and
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
190 the previous one, contrary to what is done in ff_acelp_reorder_lsf() */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
191 ff_set_min_dist_lsf(lsfnew, LSFQ_DIFF_MIN, LP_FILTER_ORDER - 1);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
192 lsfnew[9] = FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 * M_PI);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
193
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
194 memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
195
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
196 for (i = 0; i < LP_FILTER_ORDER - 1; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
197 lsfnew[i] = cos(lsfnew[i]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
198 lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 / M_PI;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
199 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
200
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
201 /** Apply pitch lag to the fixed vector (AMR section 6.1.2). */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
202 static void pitch_sharpening(int pitch_lag_int, float beta,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
203 float *fixed_vector)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
204 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
205 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
206
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
207 for (i = pitch_lag_int; i < SUBFR_SIZE; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
208 fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
209 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
210
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
211 /**
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
212 * Extracts decoding parameters from the input bitstream.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
213 * @param parms parameters structure
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
214 * @param pgb pointer to initialized GetBitContext structure
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
215 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
216 static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
217 const SiprModeParam *p)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
218 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
219 int i, j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
220
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
221 for (i = 0; i < 5; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
222 parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
223
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
224 for (i = 0; i < p->subframe_count; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
225 parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
226 parms->gp_index[i] = get_bits(pgb, p->gp_index_bits);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
227
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
228 for (j = 0; j < p->number_of_fc_indexes; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
229 parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
230
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
231 parms->gc_index[i] = get_bits(pgb, p->gc_index_bits);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
232 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
233 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
234
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
235 static void lsp2lpc_sipr(const double *lsp, float *Az)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
236 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
237 int lp_half_order = LP_FILTER_ORDER >> 1;
10871
c06d95ce2db0 SIPR: kill variable-length arrays
mru
parents: 10836
diff changeset
238 double buf[(LP_FILTER_ORDER >> 1) + 1];
c06d95ce2db0 SIPR: kill variable-length arrays
mru
parents: 10836
diff changeset
239 double pa[(LP_FILTER_ORDER >> 1) + 1];
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
240 double *qa = buf + 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
241 int i,j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
242
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
243 qa[-1] = 0.0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
244
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
245 ff_lsp2polyf(lsp , pa, lp_half_order );
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
246 ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
247
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
248 for (i = 1, j = LP_FILTER_ORDER - 1; i < lp_half_order; i++, j--) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
249 double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
250 double qaf = (qa[i] - qa[i-2]) * (1 - lsp[LP_FILTER_ORDER - 1]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
251 Az[i-1] = (paf + qaf) * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
252 Az[j-1] = (paf - qaf) * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
253 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
254
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
255 Az[lp_half_order - 1] = (1.0 + lsp[LP_FILTER_ORDER - 1]) *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
256 pa[lp_half_order] * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
257
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
258 Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
259 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
260
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
261 static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
262 int num_subfr)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
263 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
264 double lsfint[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
265 int i,j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
266 float t, t0 = 1.0 / num_subfr;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
267
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
268 t = t0 * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
269 for (i = 0; i < num_subfr; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
270 for (j = 0; j < LP_FILTER_ORDER; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
271 lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
272
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
273 lsp2lpc_sipr(lsfint, Az);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
274 Az += LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
275 t += t0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
276 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
277 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
278
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
279 /**
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
280 * Evaluates the adaptative impulse response.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
281 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
282 static void eval_ir(const float *Az, int pitch_lag, float *freq,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
283 float pitch_sharp_factor)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
284 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
285 float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
286 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
287
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
288 tmp1[0] = 1.;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
289 for (i = 0; i < LP_FILTER_ORDER; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
290 tmp1[i+1] = Az[i] * ff_pow_0_55[i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
291 tmp2[i ] = Az[i] * ff_pow_0_7 [i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
292 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
293 memset(tmp1 + 11, 0, 37 * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
294
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
295 ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
296 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
297
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
298 pitch_sharpening(pitch_lag, pitch_sharp_factor, freq);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
299 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
300
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
301 /**
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
302 * Evaluates the convolution of a vector with a sparse vector.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
303 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
304 static void convolute_with_sparse(float *out, const AMRFixed *pulses,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
305 const float *shape, int length)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
306 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
307 int i, j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
308
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
309 memset(out, 0, length*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
310 for (i = 0; i < pulses->n; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
311 for (j = pulses->x[i]; j < length; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
312 out[j] += pulses->y[i] * shape[j - pulses->x[i]];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
313 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
314
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
315 /**
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
316 * Apply postfilter, very similar to AMR one.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
317 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
318 static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
319 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
320 float buf[SUBFR_SIZE + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
321 float *pole_out = buf + LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
322 float lpc_n[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
323 float lpc_d[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
324 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
325
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
326 for (i = 0; i < LP_FILTER_ORDER; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
327 lpc_d[i] = lpc[i] * ff_pow_0_75[i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
328 lpc_n[i] = lpc[i] * pow_0_5 [i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
329 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
330
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
331 memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
332 LP_FILTER_ORDER*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
333
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
334 ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
335 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
336
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
337 memcpy(ctx->postfilter_mem, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
338 LP_FILTER_ORDER*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
339
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
340 ff_tilt_compensation(&ctx->tilt_mem, 0.4, pole_out, SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
341
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
342 memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem5k0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
343 LP_FILTER_ORDER*sizeof(*pole_out));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
344
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
345 memcpy(ctx->postfilter_mem5k0, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
346 LP_FILTER_ORDER*sizeof(*pole_out));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
347
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
348 ff_celp_lp_zero_synthesis_filterf(samples, lpc_n, pole_out, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
349 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
350
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
351 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
352
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
353 static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
354 SiprMode mode, int low_gain)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
355 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
356 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
357
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
358 switch (mode) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
359 case MODE_6k5:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
360 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
361 fixed_sparse->x[i] = 3 * (pulses[i] & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
362 fixed_sparse->y[i] = pulses[i] & 0x10 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
363 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
364 fixed_sparse->n = 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
365 break;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
366 case MODE_8k5:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
367 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
368 fixed_sparse->x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
369 fixed_sparse->x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
370
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
371 fixed_sparse->y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
372
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
373 fixed_sparse->y[2*i + 1] =
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
374 (fixed_sparse->x[2*i + 1] < fixed_sparse->x[2*i]) ?
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
375 -fixed_sparse->y[2*i ] : fixed_sparse->y[2*i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
376 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
377
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
378 fixed_sparse->n = 6;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
379 break;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
380 case MODE_5k0:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
381 default:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
382 if (low_gain) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
383 int offset = (pulses[0] & 0x200) ? 2 : 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
384 int val = pulses[0];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
385
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
386 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
387 int index = (val & 0x7) * 6 + 4 - i*2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
388
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
389 fixed_sparse->y[i] = (offset + index) & 0x3 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
390 fixed_sparse->x[i] = index;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
391
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
392 val >>= 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
393 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
394 fixed_sparse->n = 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
395 } else {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
396 int pulse_subset = (pulses[0] >> 8) & 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
397
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
398 fixed_sparse->x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
399 fixed_sparse->x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
400
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
401 fixed_sparse->y[0] = pulses[0] & 0x200 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
402 fixed_sparse->y[1] = -fixed_sparse->y[0];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
403 fixed_sparse->n = 2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
404 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
405 break;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
406 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
407 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
408
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
409 static void decode_frame(SiprContext *ctx, SiprParameters *params,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
410 float *out_data)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
411 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
412 int i, j;
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
413 int subframe_count = modes[ctx->mode].subframe_count;
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
414 int frame_size = subframe_count * SUBFR_SIZE;
10871
c06d95ce2db0 SIPR: kill variable-length arrays
mru
parents: 10836
diff changeset
415 float Az[LP_FILTER_ORDER * MAX_SUBFRAME_COUNT];
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
416 float *excitation;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
417 float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
418 float lsf_new[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
419 float *impulse_response = ir_buf + LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
420 float *synth = ctx->synth_buf + 16; // 16 instead of LP_FILTER_ORDER for
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
421 // memory alignment
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
422 int t0_first = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
423 AMRFixed fixed_cb;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
424
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
425 memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
426 lsf_decode_fp(lsf_new, ctx->lsf_history, params);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
427
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
428 sipr_decode_lp(lsf_new, ctx->lsp_history, Az, subframe_count);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
429
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
430 memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
431
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
432 excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
433
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
434 for (i = 0; i < subframe_count; i++) {
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
435 float *pAz = Az + i*LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
436 float fixed_vector[SUBFR_SIZE];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
437 int T0,T0_frac;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
438 float pitch_gain, gain_code, avg_energy;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
439
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
440 ff_decode_pitch_lag(&T0, &T0_frac, params->pitch_delay[i], t0_first, i,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
441 ctx->mode == MODE_5k0, 6);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
442
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
443 if (i == 0 || (i == 2 && ctx->mode == MODE_5k0))
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
444 t0_first = T0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
445
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
446 ff_acelp_interpolatef(excitation, excitation - T0 + (T0_frac <= 0),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
447 ff_b60_sinc, 6,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
448 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
449 SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
450
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
451 decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
452 ctx->past_pitch_gain < 0.8);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
453
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
454 eval_ir(pAz, T0, impulse_response, modes[ctx->mode].pitch_sharp_factor);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
455
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
456 convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
457 SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
458
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
459 avg_energy =
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
460 (0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
461 SUBFR_SIZE;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
462
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
463 ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
464
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
465 gain_code = ff_amr_set_fixed_gain(gain_cb[params->gc_index[i]][1],
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
466 avg_energy, ctx->energy_history,
10873
fb42dfc877cc Remove needless use of log2f()
vitor
parents: 10872
diff changeset
467 34 - 15.0/(0.05*M_LN10/M_LN2),
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
468 pred);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
469
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
470 ff_weighted_vector_sumf(excitation, excitation, fixed_vector,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
471 pitch_gain, gain_code, SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
472
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
473 pitch_gain *= 0.5 * pitch_gain;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
474 pitch_gain = FFMIN(pitch_gain, 0.4);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
475
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
476 ctx->gain_mem = 0.7 * ctx->gain_mem + 0.3 * pitch_gain;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
477 ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
478 gain_code *= ctx->gain_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
479
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
480 for (j = 0; j < SUBFR_SIZE; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
481 fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
482
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
483 if (ctx->mode == MODE_5k0) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
484 postfilter_5k0(ctx, pAz, fixed_vector);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
485
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
486 ff_celp_lp_synthesis_filterf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
487 pAz, excitation, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
488 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
489 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
490
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
491 ff_celp_lp_synthesis_filterf(synth + i*SUBFR_SIZE, pAz, fixed_vector,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
492 SUBFR_SIZE, LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
493
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
494 excitation += SUBFR_SIZE;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
495 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
496
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
497 memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
498 LP_FILTER_ORDER * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
499
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
500 if (ctx->mode == MODE_5k0) {
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
501 for (i = 0; i < subframe_count; i++) {
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
502 float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
503 ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
504 SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
505 ff_adaptative_gain_control(&synth[i * SUBFR_SIZE], energy,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
506 SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
507 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
508
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
509 memcpy(ctx->postfilter_syn5k0, ctx->postfilter_syn5k0 + frame_size,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
510 LP_FILTER_ORDER*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
511 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
512 memcpy(ctx->excitation, excitation - PITCH_DELAY_MAX - L_INTERPOL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
513 (PITCH_DELAY_MAX + L_INTERPOL) * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
514
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
515 ff_acelp_apply_order_2_transfer_function(synth,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
516 (const float[2]) {-1.99997 , 1.000000000},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
517 (const float[2]) {-1.93307352, 0.935891986},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
518 0.939805806,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
519 ctx->highpass_filt_mem,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
520 frame_size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
521
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
522 ctx->dsp.vector_clipf(out_data, synth, -1, 32767./(1<<15), frame_size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
523
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
524 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
525
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
526 static av_cold int sipr_decoder_init(AVCodecContext * avctx)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
527 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
528 SiprContext *ctx = avctx->priv_data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
529 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
530
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
531 if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
532 else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
533 else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
534 else ctx->mode = MODE_5k0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
535
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
536 av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
537
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
538 for (i = 0; i < LP_FILTER_ORDER; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
539 ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
540
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
541 for (i = 0; i < 4; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
542 ctx->energy_history[i] = -14;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
543
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
544 avctx->sample_fmt = SAMPLE_FMT_FLT;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
545
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
546 if (ctx->mode == MODE_16k) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
547 av_log(avctx, AV_LOG_ERROR, "decoding 16kbps SIPR files is not "
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
548 "supported yet.\n");
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
549 return -1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
550 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
551
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
552 dsputil_init(&ctx->dsp, avctx);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
553
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
554 return 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
555 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
556
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
557 static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
558 int *data_size, AVPacket *avpkt)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
559 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
560 SiprContext *ctx = avctx->priv_data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
561 const uint8_t *buf=avpkt->data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
562 SiprParameters parm;
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
563 const SiprModeParam *mode_par = &modes[ctx->mode];
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
564 GetBitContext gb;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
565 float *data = datap;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
566 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
567
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
568 ctx->avctx = avctx;
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
569 if (avpkt->size < (mode_par->bits_per_frame >> 3)) {
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
570 av_log(avctx, AV_LOG_ERROR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
571 "Error processing packet: packet size (%d) too small\n",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
572 avpkt->size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
573
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
574 *data_size = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
575 return -1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
576 }
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
577 if (*data_size < SUBFR_SIZE * mode_par->subframe_count * sizeof(float)) {
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
578 av_log(avctx, AV_LOG_ERROR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
579 "Error processing packet: output buffer (%d) too small\n",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
580 *data_size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
581
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
582 *data_size = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
583 return -1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
584 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
585
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
586 init_get_bits(&gb, buf, mode_par->bits_per_frame);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
587
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
588 for (i = 0; i < mode_par->frames_per_packet; i++) {
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
589 decode_parameters(&parm, &gb, mode_par);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
590 decode_frame(ctx, &parm, data);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
591
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
592 data += SUBFR_SIZE * mode_par->subframe_count;
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
593 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
594
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
595 *data_size = mode_par->frames_per_packet * SUBFR_SIZE *
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
596 mode_par->subframe_count * sizeof(float);
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
597
10872
a4fbfc917c2e Remove the struct SiprModeParam of the context. This will simplify splitting
vitor
parents: 10871
diff changeset
598 return mode_par->bits_per_frame >> 3;
10836
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
599 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
600
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
601 AVCodec sipr_decoder = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
602 "sipr",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
603 CODEC_TYPE_AUDIO,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
604 CODEC_ID_SIPR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
605 sizeof(SiprContext),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
606 sipr_decoder_init,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
607 NULL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
608 NULL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
609 sipr_decode_frame,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
610 .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
611 };