Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
41578f70
Commit
41578f70
authored
11 years ago
by
Loren Merritt
Committed by
Luca Barbato
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
lpc: use function pointers, in preparation for asm
Signed-off-by:
Luca Barbato
<
lu_zero@gentoo.org
>
parent
cc6714bb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
libavcodec/lpc.c
+2
-2
2 additions, 2 deletions
libavcodec/lpc.c
libavutil/lls.c
+14
-12
14 additions, 12 deletions
libavutil/lls.c
libavutil/lls.h
+13
-2
13 additions, 2 deletions
libavutil/lls.h
with
29 additions
and
16 deletions
libavcodec/lpc.c
+
2
−
2
View file @
41578f70
...
...
@@ -212,7 +212,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
if
(
pass
){
double
eval
,
inv
,
rinv
;
eval
=
avpriv_
evaluate_lls
(
&
m
[(
pass
-
1
)
&
1
],
var
+
1
,
max_order
-
1
);
eval
=
m
[(
pass
-
1
)
&
1
].
evaluate_lls
(
&
m
[(
pass
-
1
)
&
1
],
var
+
1
,
max_order
-
1
);
eval
=
(
512
>>
pass
)
+
fabs
(
eval
-
var
[
0
]);
inv
=
1
/
eval
;
rinv
=
sqrt
(
inv
);
...
...
@@ -222,7 +222,7 @@ int ff_lpc_calc_coefs(LPCContext *s,
}
else
weight
++
;
avpriv_
update_lls
(
&
m
[
pass
&
1
],
var
);
m
[
pass
&
1
].
update_lls
(
&
m
[
pass
&
1
],
var
);
}
avpriv_solve_lls
(
&
m
[
pass
&
1
],
0
.
001
,
0
);
}
...
...
This diff is collapsed.
Click to expand it.
libavutil/lls.c
+
14
−
12
View file @
41578f70
...
...
@@ -32,13 +32,7 @@
#include
"version.h"
#include
"lls.h"
av_cold
void
avpriv_init_lls
(
LLSModel
*
m
,
int
indep_count
)
{
memset
(
m
,
0
,
sizeof
(
LLSModel
));
m
->
indep_count
=
indep_count
;
}
void
avpriv_update_lls
(
LLSModel
*
m
,
double
*
var
)
static
void
update_lls
(
LLSModel
*
m
,
double
*
var
)
{
int
i
,
j
;
...
...
@@ -106,7 +100,7 @@ void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order)
}
}
double
avpriv_
evaluate_lls
(
LLSModel
*
m
,
double
*
param
,
int
order
)
static
double
evaluate_lls
(
LLSModel
*
m
,
double
*
param
,
int
order
)
{
int
i
;
double
out
=
0
;
...
...
@@ -117,6 +111,14 @@ double avpriv_evaluate_lls(LLSModel *m, double *param, int order)
return
out
;
}
av_cold
void
avpriv_init_lls
(
LLSModel
*
m
,
int
indep_count
)
{
memset
(
m
,
0
,
sizeof
(
LLSModel
));
m
->
indep_count
=
indep_count
;
m
->
update_lls
=
update_lls
;
m
->
evaluate_lls
=
evaluate_lls
;
}
#if FF_API_LLS_PRIVATE
av_cold
void
av_init_lls
(
LLSModel
*
m
,
int
indep_count
)
{
...
...
@@ -124,7 +126,7 @@ av_cold void av_init_lls(LLSModel *m, int indep_count)
}
void
av_update_lls
(
LLSModel
*
m
,
double
*
param
,
double
decay
)
{
avpriv_
update_lls
(
m
,
param
);
m
->
update_lls
(
m
,
param
);
}
void
av_solve_lls
(
LLSModel
*
m
,
double
threshold
,
int
min_order
)
{
...
...
@@ -132,7 +134,7 @@ void av_solve_lls(LLSModel *m, double threshold, int min_order)
}
double
av_evaluate_lls
(
LLSModel
*
m
,
double
*
param
,
int
order
)
{
return
avpriv_
evaluate_lls
(
m
,
param
,
order
);
return
m
->
evaluate_lls
(
m
,
param
,
order
);
}
#endif
/* FF_API_LLS_PRIVATE */
...
...
@@ -159,10 +161,10 @@ int main(void)
var
[
1
]
=
var
[
0
]
+
av_lfg_get
(
&
lfg
)
/
(
double
)
UINT_MAX
-
0
.
5
;
var
[
2
]
=
var
[
1
]
+
av_lfg_get
(
&
lfg
)
/
(
double
)
UINT_MAX
-
0
.
5
;
var
[
3
]
=
var
[
2
]
+
av_lfg_get
(
&
lfg
)
/
(
double
)
UINT_MAX
-
0
.
5
;
avpriv_
update_lls
(
&
m
,
var
);
m
.
update_lls
(
&
m
,
var
);
avpriv_solve_lls
(
&
m
,
0
.
001
,
0
);
for
(
order
=
0
;
order
<
3
;
order
++
)
{
eval
=
avpriv_
evaluate_lls
(
&
m
,
var
+
1
,
order
);
eval
=
m
.
evaluate_lls
(
&
m
,
var
+
1
,
order
);
printf
(
"real:%9f order:%d pred:%9f var:%f coeffs:%f %9f %9f
\n
"
,
var
[
0
],
order
,
eval
,
sqrt
(
m
.
variance
[
order
]
/
(
i
+
1
)),
m
.
coeff
[
order
][
0
],
m
.
coeff
[
order
][
1
],
...
...
This diff is collapsed.
Click to expand it.
libavutil/lls.h
+
13
−
2
View file @
41578f70
...
...
@@ -37,12 +37,23 @@ typedef struct LLSModel {
double
coeff
[
MAX_VARS
][
MAX_VARS
];
double
variance
[
MAX_VARS
];
int
indep_count
;
/**
* Take the outer-product of var[] with itself, and add to the covariance matrix.
* @param m this context
* @param var training samples, starting with the value to be predicted
*/
void
(
*
update_lls
)(
struct
LLSModel
*
m
,
double
*
var
);
/**
* Inner product of var[] and the LPC coefs.
* @param m this context
* @param var training samples, excluding the value to be predicted
* @param order lpc order
*/
double
(
*
evaluate_lls
)(
struct
LLSModel
*
m
,
double
*
var
,
int
order
);
}
LLSModel
;
void
avpriv_init_lls
(
LLSModel
*
m
,
int
indep_count
);
void
avpriv_update_lls
(
LLSModel
*
m
,
double
*
param
);
void
avpriv_solve_lls
(
LLSModel
*
m
,
double
threshold
,
unsigned
short
min_order
);
double
avpriv_evaluate_lls
(
LLSModel
*
m
,
double
*
param
,
int
order
);
#if FF_API_LLS_PRIVATE
void
av_init_lls
(
LLSModel
*
m
,
int
indep_count
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment