FFmpeg
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
Functions
Variables
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
c
d
g
h
i
o
q
r
s
v
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
Enumerator
a
d
e
f
h
i
j
l
m
n
p
r
s
v
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
l
m
o
p
q
r
s
t
u
v
w
x
y
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Examples
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
libavcodec
lpc_functions.h
Go to the documentation of this file.
1
/*
2
* LPC utility functions
3
* Copyright (c) 2006 Justin Ruggles <justin.ruggles@gmail.com>
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
#ifndef AVCODEC_LPC_FUNCTIONS_H
23
#define AVCODEC_LPC_FUNCTIONS_H
24
25
#include "
libavutil/avassert.h
"
26
27
#ifndef LPC_USE_FIXED
28
#define LPC_USE_FIXED 0
29
#endif
30
31
#if LPC_USE_FIXED
32
typedef
int
LPC_TYPE
;
33
typedef
unsigned
LPC_TYPE_U
;
34
#else
35
#ifndef LPC_SRA_R
36
#define LPC_SRA_R(x, y) (x)
37
#define LPC_MUL26(x, y) ((x) * (y))
38
#define LPC_FIXR(x) ((float)(x))
39
#endif
40
41
#ifdef LPC_USE_DOUBLE
42
typedef
double
LPC_TYPE
;
43
typedef
double
LPC_TYPE_U
;
44
#else
45
typedef
float
LPC_TYPE
;
46
typedef
float
LPC_TYPE_U
;
47
#endif
48
#endif // USE_FIXED
49
50
/**
51
* Levinson-Durbin recursion.
52
* Produce LPC coefficients from autocorrelation data.
53
*/
54
static
inline
int
compute_lpc_coefs
(
const
LPC_TYPE
*autoc,
int
i
,
int
max_order,
55
LPC_TYPE
*lpc,
int
lpc_stride,
int
fail
,
56
int
normalize
,
LPC_TYPE
*err_ptr)
57
{
58
LPC_TYPE
err = 0;
59
LPC_TYPE
*lpc_last = lpc;
60
61
av_assert2
(
normalize
|| !
fail
);
62
63
if
(
normalize
) {
64
if
(
i
== 0)
65
err = *autoc++;
66
else
{
67
err = *err_ptr;
68
}
69
}
70
71
if
(
fail
&& (autoc[max_order - 1] == 0 || err <= 0))
72
return
-1;
73
74
for
( ;
i
< max_order;
i
++) {
75
LPC_TYPE
r
=
LPC_SRA_R
(-autoc[
i
], 5);
76
77
if
(
normalize
) {
78
for
(
int
j = 0; j <
i
; j++)
79
r
-= lpc_last[j] * autoc[
i
-j-1];
80
81
if
(err)
82
r
/= err;
83
err *=
LPC_FIXR
(1.0) - (
r
*
r
);
84
}
85
86
lpc[
i
] =
r
;
87
88
for
(
int
j = 0; j < (
i
+ 1) >> 1; j++) {
89
LPC_TYPE
f
= lpc_last[ j];
90
LPC_TYPE
b
= lpc_last[
i
-1-j];
91
lpc[ j] =
f
+ (
LPC_TYPE_U
)
LPC_MUL26
(
r
,
b
);
92
lpc[
i
-1-j] =
b
+ (
LPC_TYPE_U
)
LPC_MUL26
(
r
,
f
);
93
}
94
95
if
(
fail
&& err < 0)
96
return
-1;
97
98
lpc_last = lpc;
99
lpc += lpc_stride;
100
}
101
102
if
(err_ptr)
103
*err_ptr = err;
104
105
return
0;
106
}
107
108
#endif
/* AVCODEC_LPC_FUNCTIONS_H */
r
const char * r
Definition:
vf_curves.c:127
b
#define b
Definition:
input.c:42
fail
#define fail()
Definition:
checkasm.h:196
avassert.h
LPC_MUL26
#define LPC_MUL26(x, y)
Definition:
lpc_functions.h:37
f
f
Definition:
af_crystalizer.c:122
normalize
Definition:
normalize.py:1
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition:
avassert.h:68
i
#define i(width, name, range_min, range_max)
Definition:
cbs_h2645.c:256
compute_lpc_coefs
static int compute_lpc_coefs(const LPC_TYPE *autoc, int i, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize, LPC_TYPE *err_ptr)
Levinson-Durbin recursion.
Definition:
lpc_functions.h:54
LPC_TYPE_U
float LPC_TYPE_U
Definition:
lpc_functions.h:46
LPC_TYPE
float LPC_TYPE
Definition:
lpc_functions.h:45
LPC_FIXR
#define LPC_FIXR(x)
Definition:
lpc_functions.h:38
LPC_SRA_R
#define LPC_SRA_R(x, y)
Definition:
lpc_functions.h:36
Generated on Mon Jun 23 2025 19:22:04 for FFmpeg by
1.8.17