From 41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Tue, 18 Jun 2013 21:30:41 +0000 Subject: lpc: use function pointers, in preparation for asm Signed-off-by: Luca Barbato --- libavutil/lls.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'libavutil/lls.c') diff --git a/libavutil/lls.c b/libavutil/lls.c index 2061e6a5a9..5a3e4485c8 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -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], -- cgit v1.2.3