annotate sipr.c @ 10860:c9fb5b89e47a libavcodec

Replace variable length array with an allocated buffer in the context to increase compatibility.
author thilo.borgmann
date Tue, 12 Jan 2010 20:35:22 +0000
parents f20f9b76f4c8
children c06d95ce2db0
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
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
27 #include "avcodec.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
28 #define ALT_BITSTREAM_READER_LE
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
29 #include "get_bits.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
30 #include "dsputil.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
31
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
32 #include "lsp.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
33 #include "celp_math.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
34 #include "acelp_vectors.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
35 #include "acelp_pitch_delay.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
36 #include "acelp_filters.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
37 #include "celp_filters.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
38
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
39 #define LSFQ_DIFF_MIN (0.0125 * M_PI)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
40
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
41 #define LP_FILTER_ORDER 10
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
42
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
43 /** Number of past samples needed for excitation interpolation */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
44 #define L_INTERPOL (LP_FILTER_ORDER + 1)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
45
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
46 /** Subframe size for all modes except 16k */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
47 #define SUBFR_SIZE 48
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
48
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
49 #include "siprdata.h"
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
50
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
51 typedef enum {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
52 MODE_16k,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
53 MODE_8k5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
54 MODE_6k5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
55 MODE_5k0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
56 MODE_COUNT
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
57 } SiprMode;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
58
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
59 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
60 const char *mode_name;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
61 uint16_t bits_per_frame;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
62 uint8_t subframe_count;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
63 uint8_t frames_per_packet;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
64 float pitch_sharp_factor;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
65
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
66 /* bitstream parameters */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
67 uint8_t number_of_fc_indexes;
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 /** size in bits of the i-th stage vector of quantizer */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
70 uint8_t vq_indexes_bits[5];
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 adaptive-codebook index for every subframe */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
73 uint8_t pitch_delay_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 uint8_t gp_index_bits;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
76 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
77 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
78 } SiprModeParam;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
79
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
80 static const SiprModeParam modes[MODE_COUNT] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
81 [MODE_8k5] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
82 .mode_name = "8k5",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
83 .bits_per_frame = 152,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
84 .subframe_count = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
85 .frames_per_packet = 1,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
86 .pitch_sharp_factor = 0.8,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
87
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
88 .number_of_fc_indexes = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
89 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
90 .pitch_delay_bits = {8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
91 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
92 .fc_index_bits = {9, 9, 9},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
93 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
94 },
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
95
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
96 [MODE_6k5] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
97 .mode_name = "6k5",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
98 .bits_per_frame = 232,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
99 .subframe_count = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
100 .frames_per_packet = 2,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
101 .pitch_sharp_factor = 0.8,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
102
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
103 .number_of_fc_indexes = 3,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
104 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
105 .pitch_delay_bits = {8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
106 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
107 .fc_index_bits = {5, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
108 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
109 },
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
110
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
111 [MODE_5k0] = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
112 .mode_name = "5k0",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
113 .bits_per_frame = 296,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
114 .subframe_count = 5,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
115 .frames_per_packet = 2,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
116 .pitch_sharp_factor = 0.85,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
117
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
118 .number_of_fc_indexes = 1,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
119 .vq_indexes_bits = {6, 7, 7, 7, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
120 .pitch_delay_bits = {8, 5, 8, 5, 5},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
121 .gp_index_bits = 0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
122 .fc_index_bits = {10},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
123 .gc_index_bits = 7
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
124 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
125 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
126
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
127 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
128 AVCodecContext *avctx;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
129 DSPContext dsp;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
130
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
131 SiprModeParam m;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
132 SiprMode mode;
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 float past_pitch_gain;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
135 float lsf_history[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
136
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
137 float excitation[L_INTERPOL + PITCH_DELAY_MAX + 5*SUBFR_SIZE];
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 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
140
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
141 float lsp_history[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
142 float gain_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
143 float energy_history[4];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
144 float highpass_filt_mem[2];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
145 float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
146
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
147 /* 5k0 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
148 float tilt_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
149 float postfilter_agc;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
150 float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
151 float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
152 } SiprContext;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
153
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
154 typedef struct {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
155 int vq_indexes[5];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
156 int pitch_delay[5]; ///< pitch delay
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
157 int gp_index[5]; ///< adaptive-codebook gain indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
158 int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
159 int gc_index[5]; ///< fixed-codebook gain indexes
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
160 } SiprParameters;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
161
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
162
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
163 static void dequant(float *out, const int *idx, const float *cbs[])
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 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
166 int stride = 2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
167 int num_vec = 5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
168
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
169 for (i = 0; i < num_vec; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
170 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
171
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
172 }
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 static void lsf_decode_fp(float *lsfnew, float *lsf_history,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
175 const SiprParameters *parm)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
176 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
177 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
178 float lsf_tmp[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
179
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
180 dequant(lsf_tmp, parm->vq_indexes, lsf_codebooks);
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 for (i = 0; i < LP_FILTER_ORDER; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
183 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
184
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
185 ff_sort_nearly_sorted_floats(lsfnew, LP_FILTER_ORDER - 1);
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 /* 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
188 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
189 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
190 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
191
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
192 memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER * sizeof(*lsf_history));
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 for (i = 0; i < LP_FILTER_ORDER - 1; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
195 lsfnew[i] = cos(lsfnew[i]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
196 lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 / M_PI;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
197 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
198
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
199 /** 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
200 static void pitch_sharpening(int pitch_lag_int, float beta,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
201 float *fixed_vector)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
202 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
203 int i;
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 for (i = pitch_lag_int; i < SUBFR_SIZE; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
206 fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
207 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
208
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 * Extracts decoding parameters from the input bitstream.
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
211 * @param parms parameters structure
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
212 * @param pgb pointer to initialized GetBitContext structure
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
213 */
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
214 static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
215 const SiprModeParam *p)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
216 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
217 int i, j;
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 for (i = 0; i < 5; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
220 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
221
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
222 for (i = 0; i < p->subframe_count; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
223 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
224 parms->gp_index[i] = get_bits(pgb, p->gp_index_bits);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
225
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
226 for (j = 0; j < p->number_of_fc_indexes; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
227 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
228
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
229 parms->gc_index[i] = get_bits(pgb, p->gc_index_bits);
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 }
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 static void lsp2lpc_sipr(const double *lsp, float *Az)
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 int lp_half_order = LP_FILTER_ORDER >> 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
236 double buf[lp_half_order + 1];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
237 double pa[lp_half_order + 1];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
238 double *qa = buf + 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
239 int i,j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
240
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
241 qa[-1] = 0.0;
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 ff_lsp2polyf(lsp , pa, lp_half_order );
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
244 ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
245
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
246 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
247 double paf = pa[i] * (1 + lsp[LP_FILTER_ORDER - 1]);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
248 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
249 Az[i-1] = (paf + qaf) * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
250 Az[j-1] = (paf - qaf) * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
251 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
252
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
253 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
254 pa[lp_half_order] * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
255
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
256 Az[LP_FILTER_ORDER - 1] = lsp[LP_FILTER_ORDER - 1];
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
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
259 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
260 int num_subfr)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
261 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
262 double lsfint[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
263 int i,j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
264 float t, t0 = 1.0 / num_subfr;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
265
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
266 t = t0 * 0.5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
267 for (i = 0; i < num_subfr; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
268 for (j = 0; j < LP_FILTER_ORDER; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
269 lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
270
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
271 lsp2lpc_sipr(lsfint, Az);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
272 Az += LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
273 t += t0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
274 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
275 }
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 * Evaluates the adaptative impulse response.
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 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
281 float pitch_sharp_factor)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
282 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
283 float tmp1[SUBFR_SIZE+1], tmp2[LP_FILTER_ORDER+1];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
284 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
285
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
286 tmp1[0] = 1.;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
287 for (i = 0; i < LP_FILTER_ORDER; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
288 tmp1[i+1] = Az[i] * ff_pow_0_55[i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
289 tmp2[i ] = Az[i] * ff_pow_0_7 [i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
290 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
291 memset(tmp1 + 11, 0, 37 * sizeof(float));
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 ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
294 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
295
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
296 pitch_sharpening(pitch_lag, pitch_sharp_factor, freq);
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
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 * Evaluates the convolution of a vector with a sparse vector.
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 static void convolute_with_sparse(float *out, const AMRFixed *pulses,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
303 const float *shape, int length)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
304 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
305 int i, j;
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 memset(out, 0, length*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
308 for (i = 0; i < pulses->n; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
309 for (j = pulses->x[i]; j < length; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
310 out[j] += pulses->y[i] * shape[j - pulses->x[i]];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
311 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
312
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 * Apply postfilter, very similar to AMR one.
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 static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples)
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 float buf[SUBFR_SIZE + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
319 float *pole_out = buf + LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
320 float lpc_n[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
321 float lpc_d[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
322 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
323
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
324 for (i = 0; i < LP_FILTER_ORDER; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
325 lpc_d[i] = lpc[i] * ff_pow_0_75[i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
326 lpc_n[i] = lpc[i] * pow_0_5 [i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
327 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
328
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
329 memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
330 LP_FILTER_ORDER*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
331
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
332 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
333 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
334
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
335 memcpy(ctx->postfilter_mem, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
336 LP_FILTER_ORDER*sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
337
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
338 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
339
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
340 memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem5k0,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
341 LP_FILTER_ORDER*sizeof(*pole_out));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
342
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
343 memcpy(ctx->postfilter_mem5k0, pole_out + SUBFR_SIZE - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
344 LP_FILTER_ORDER*sizeof(*pole_out));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
345
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
346 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
347 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
348
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
349 }
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 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
352 SiprMode mode, int low_gain)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
353 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
354 int i;
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 switch (mode) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
357 case MODE_6k5:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
358 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
359 fixed_sparse->x[i] = 3 * (pulses[i] & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
360 fixed_sparse->y[i] = pulses[i] & 0x10 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
361 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
362 fixed_sparse->n = 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
363 break;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
364 case MODE_8k5:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
365 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
366 fixed_sparse->x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
367 fixed_sparse->x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
368
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
369 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
370
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
371 fixed_sparse->y[2*i + 1] =
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
372 (fixed_sparse->x[2*i + 1] < fixed_sparse->x[2*i]) ?
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
373 -fixed_sparse->y[2*i ] : fixed_sparse->y[2*i];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
374 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
375
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
376 fixed_sparse->n = 6;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
377 break;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
378 case MODE_5k0:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
379 default:
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
380 if (low_gain) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
381 int offset = (pulses[0] & 0x200) ? 2 : 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
382 int val = pulses[0];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
383
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
384 for (i = 0; i < 3; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
385 int index = (val & 0x7) * 6 + 4 - i*2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
386
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
387 fixed_sparse->y[i] = (offset + index) & 0x3 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
388 fixed_sparse->x[i] = index;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
389
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
390 val >>= 3;
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 fixed_sparse->n = 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
393 } else {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
394 int pulse_subset = (pulses[0] >> 8) & 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
395
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
396 fixed_sparse->x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
397 fixed_sparse->x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
398
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
399 fixed_sparse->y[0] = pulses[0] & 0x200 ? -1 : 1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
400 fixed_sparse->y[1] = -fixed_sparse->y[0];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
401 fixed_sparse->n = 2;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
402 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
403 break;
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 }
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 static void decode_frame(SiprContext *ctx, SiprParameters *params,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
408 float *out_data)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
409 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
410 int i, j;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
411 int frame_size = ctx->m.subframe_count * SUBFR_SIZE;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
412 float Az[LP_FILTER_ORDER * ctx->m.subframe_count];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
413 float *excitation;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
414 float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
415 float lsf_new[LP_FILTER_ORDER];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
416 float *impulse_response = ir_buf + LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
417 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
418 // memory alignment
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
419 int t0_first = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
420 AMRFixed fixed_cb;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
421
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
422 memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
423 lsf_decode_fp(lsf_new, ctx->lsf_history, params);
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 sipr_decode_lp(lsf_new, ctx->lsp_history, Az, ctx->m.subframe_count);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
426
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
427 memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float));
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
428
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
429 excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
430
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
431 for (i = 0; i < ctx->m.subframe_count; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
432 float *pAz = Az + i*LP_FILTER_ORDER;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
433 float fixed_vector[SUBFR_SIZE];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
434 int T0,T0_frac;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
435 float pitch_gain, gain_code, avg_energy;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
436
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
437 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
438 ctx->mode == MODE_5k0, 6);
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 if (i == 0 || (i == 2 && ctx->mode == MODE_5k0))
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
441 t0_first = T0;
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 ff_acelp_interpolatef(excitation, excitation - T0 + (T0_frac <= 0),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
444 ff_b60_sinc, 6,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
445 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
446 SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
447
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
448 decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
449 ctx->past_pitch_gain < 0.8);
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 eval_ir(pAz, T0, impulse_response, ctx->m.pitch_sharp_factor);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
452
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
453 convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
454 SUBFR_SIZE);
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 avg_energy =
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
457 (0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
458 SUBFR_SIZE;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
459
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
460 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
461
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
462 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
463 avg_energy, ctx->energy_history,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
464 34 - 15.0/(log2f(10.0) * 0.05),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
465 pred);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
466
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
467 ff_weighted_vector_sumf(excitation, excitation, fixed_vector,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
468 pitch_gain, gain_code, SUBFR_SIZE);
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 pitch_gain *= 0.5 * pitch_gain;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
471 pitch_gain = FFMIN(pitch_gain, 0.4);
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 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
474 ctx->gain_mem = FFMIN(ctx->gain_mem, pitch_gain);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
475 gain_code *= ctx->gain_mem;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
476
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
477 for (j = 0; j < SUBFR_SIZE; j++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
478 fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
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 if (ctx->mode == MODE_5k0) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
481 postfilter_5k0(ctx, pAz, fixed_vector);
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 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
484 pAz, excitation, SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
485 LP_FILTER_ORDER);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
486 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
487
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
488 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
489 SUBFR_SIZE, LP_FILTER_ORDER);
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 excitation += SUBFR_SIZE;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
492 }
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 memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
495 LP_FILTER_ORDER * sizeof(float));
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 if (ctx->mode == MODE_5k0) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
498 for (i = 0; i < ctx->m.subframe_count; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
499 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
500 ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
501 SUBFR_SIZE);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
502 ff_adaptative_gain_control(&synth[i * SUBFR_SIZE], energy,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
503 SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
504 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
505
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
506 memcpy(ctx->postfilter_syn5k0, ctx->postfilter_syn5k0 + frame_size,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
507 LP_FILTER_ORDER*sizeof(float));
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->excitation, excitation - PITCH_DELAY_MAX - L_INTERPOL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
510 (PITCH_DELAY_MAX + L_INTERPOL) * 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 ff_acelp_apply_order_2_transfer_function(synth,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
513 (const float[2]) {-1.99997 , 1.000000000},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
514 (const float[2]) {-1.93307352, 0.935891986},
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
515 0.939805806,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
516 ctx->highpass_filt_mem,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
517 frame_size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
518
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
519 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
520
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
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
523 static av_cold int sipr_decoder_init(AVCodecContext * avctx)
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 SiprContext *ctx = avctx->priv_data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
526 int i;
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 if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
529 else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
530 else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
531 else ctx->mode = MODE_5k0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
532
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
533 ctx->m = modes[ctx->mode];
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
534 av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", ctx->m.mode_name);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
535
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
536 for (i = 0; i < LP_FILTER_ORDER; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
537 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
538
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
539 for (i = 0; i < 4; i++)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
540 ctx->energy_history[i] = -14;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
541
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
542 avctx->sample_fmt = SAMPLE_FMT_FLT;
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 if (ctx->mode == MODE_16k) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
545 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
546 "supported yet.\n");
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
547 return -1;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
548 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
549
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
550 dsputil_init(&ctx->dsp, avctx);
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 return 0;
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
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
555 static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
556 int *data_size, AVPacket *avpkt)
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
557 {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
558 SiprContext *ctx = avctx->priv_data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
559 const uint8_t *buf=avpkt->data;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
560 SiprParameters parm;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
561 GetBitContext gb;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
562 float *data = datap;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
563 int i;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
564
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
565 ctx->avctx = avctx;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
566 if (avpkt->size < (ctx->m.bits_per_frame >> 3)) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
567 av_log(avctx, AV_LOG_ERROR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
568 "Error processing packet: packet size (%d) too small\n",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
569 avpkt->size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
570
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
571 *data_size = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
572 return -1;
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 if (*data_size < SUBFR_SIZE * ctx->m.subframe_count * sizeof(float)) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
575 av_log(avctx, AV_LOG_ERROR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
576 "Error processing packet: output buffer (%d) too small\n",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
577 *data_size);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
578
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
579 *data_size = 0;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
580 return -1;
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
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
583 init_get_bits(&gb, buf, ctx->m.bits_per_frame);
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 for (i = 0; i < ctx->m.frames_per_packet; i++) {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
586 decode_parameters(&parm, &gb, &ctx->m);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
587 decode_frame(ctx, &parm, data);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
588
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
589 data += SUBFR_SIZE * ctx->m.subframe_count;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
590 }
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
591
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
592 *data_size = ctx->m.frames_per_packet * SUBFR_SIZE *
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
593 ctx->m.subframe_count * sizeof(float);
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
594
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
595 return ctx->m.bits_per_frame >> 3;
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
596 };
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
597
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
598 AVCodec sipr_decoder = {
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
599 "sipr",
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
600 CODEC_TYPE_AUDIO,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
601 CODEC_ID_SIPR,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
602 sizeof(SiprContext),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
603 sipr_decoder_init,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
604 NULL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
605 NULL,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
606 sipr_decode_frame,
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
607 .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
f20f9b76f4c8 SIPR decoder for modes 8k5, 6k5 and 5k0.
vitor
parents:
diff changeset
608 };