1 /*
2 * gsm 06.10 decoder
3 * Copyright (c) 2010 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * GSM decoder
25 */
26
30
32 {
36 for (
i = 0;
i < 13;
i++) {
39 }
40 }
41
43 {
44 return (
int)(
a * (
SUINT)
b + (1 << 14)) >> 15;
45 }
46
48 {
50 const int16_t *
src = dst - lag;
52 for (
i = 0;
i < 40;
i++)
54 }
55
57 {
58 coded <<= 10;
61 }
62
64 {
66 if (
abs < 11059)
abs <<= 1;
67 else if (
abs < 20070)
abs += 11059;
68 else abs = (
abs >> 2) + 26112;
69 return filtered < 0 ? -
abs :
abs;
70 }
71
73 {
75 for (
i = 7;
i >= 0;
i--) {
78 }
79 v[0] = in;
80 return in;
81 }
82
84 {
86 int rrp[8];
87 int *lar =
ctx->lar[
ctx->lar_idx];
88 int *lar_prev =
ctx->lar[
ctx->lar_idx ^ 1];
89 for (
i = 0;
i < 8;
i++)
90 rrp[
i] =
get_rrp((lar_prev[
i] >> 2) + (lar_prev[
i] >> 1) + (lar[
i] >> 2));
91 for (
i = 0;
i < 13;
i++)
93
94 for (
i = 0;
i < 8;
i++)
95 rrp[
i] =
get_rrp((lar_prev[
i] >> 1) + (lar [
i] >> 1));
96 for (
i = 13;
i < 27;
i++)
98
99 for (
i = 0;
i < 8;
i++)
100 rrp[
i] =
get_rrp((lar_prev[
i] >> 2) + (lar [
i] >> 1) + (lar[
i] >> 2));
101 for (
i = 27;
i < 40;
i++)
103
104 for (
i = 0;
i < 8;
i++)
106 for (
i = 40;
i < 160;
i++)
108
110 }
111
113 {
115 for (
i = 0;
i < 160;
i++) {
118 }
119 return msr;
120 }
121
124 {
127 int16_t *ref_dst =
ctx->ref_buf + 120;
128 int *lar =
ctx->lar[
ctx->lar_idx];
137
138 for (
i = 0;
i < 4;
i++) {
145 ref_dst += 40;
146 }
147 memcpy(
ctx->ref_buf,
ctx->ref_buf + 160, 120 *
sizeof(*
ctx->ref_buf));
149 // for optimal speed this could be merged with short_term_synth,
150 // not done yet because it is a bit ugly
152 return 0;
153 }