aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-06-30 11:22:15 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-06-30 11:23:43 +0200
commitc93a424718c38c6add273745f3792b531332ea88 (patch)
treeab6de6854680c0f8499dcaf4cad0d90c1c470920
parentd3bd320e63bfbc96d78a673a01d36f25dc6316e7 (diff)
parent41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2 (diff)
downloadffmpeg-c93a424718c38c6add273745f3792b531332ea88.tar.gz
Merge commit '41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2'
* commit '41578f70cf8aec8e7565fba1ca7e07f3dc46c3d2': lpc: use function pointers, in preparation for asm Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/lpc.c4
-rw-r--r--libavcodec/version.h2
-rw-r--r--libavutil/lls.c26
-rw-r--r--libavutil/lls.h15
-rw-r--r--libavutil/version.h2
5 files changed, 31 insertions, 18 deletions
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index eb7698bdfe..e2c0aacc43 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -216,7 +216,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);
@@ -226,7 +226,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);
}
diff --git a/libavcodec/version.h b/libavcodec/version.h
index b59cdd2be8..d0af912e26 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 55
#define LIBAVCODEC_VERSION_MINOR 17
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavutil/lls.c b/libavutil/lls.c
index 2abfedd552..678285416d 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],
diff --git a/libavutil/lls.h b/libavutil/lls.h
index 360be4e747..f5159f3f2f 100644
--- a/libavutil/lls.h
+++ b/libavutil/lls.h
@@ -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);
diff --git a/libavutil/version.h b/libavutil/version.h
index 5d4efd6953..72c5b117d4 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -76,7 +76,7 @@
#define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 37
-#define LIBAVUTIL_VERSION_MICRO 101
+#define LIBAVUTIL_VERSION_MICRO 102
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \