summaryrefslogtreecommitdiff
path: root/source/fitz/function.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2013-06-19 15:29:44 +0200
committerTor Andersson <tor.andersson@artifex.com>2013-06-20 16:45:35 +0200
commit0a927854a10e1e6b9770a81e2e1d9f3093631757 (patch)
tree3d65d820d9fdba2d0d394d99c36290c851b78ca0 /source/fitz/function.c
parent1ae8f19179c5f0f8c6352b3c7855465325d5449a (diff)
downloadmupdf-0a927854a10e1e6b9770a81e2e1d9f3093631757.tar.xz
Rearrange source files.
Diffstat (limited to 'source/fitz/function.c')
-rw-r--r--source/fitz/function.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/fitz/function.c b/source/fitz/function.c
new file mode 100644
index 00000000..b5ba4815
--- /dev/null
+++ b/source/fitz/function.c
@@ -0,0 +1,48 @@
+#include "mupdf/fitz.h"
+
+void
+fz_eval_function(fz_context *ctx, fz_function *func, float *in_, int inlen, float *out_, int outlen)
+{
+ float fakein[FZ_FN_MAXM];
+ float fakeout[FZ_FN_MAXN];
+ float *in = in_;
+ float *out = out_;
+
+ if (inlen < func->m)
+ {
+ in = fakein;
+ memset(in, 0, sizeof(float) * func->m);
+ memcpy(in, in_, sizeof(float) * inlen);
+ }
+
+ if (outlen < func->n)
+ {
+ out = fakeout;
+ memset(out, 0, sizeof(float) * func->n);
+ }
+ else
+ memset(out, 0, sizeof(float) * outlen);
+
+ func->evaluate(ctx, func, in, out);
+
+ if (outlen < func->n)
+ memcpy(out_, out, sizeof(float) * outlen);
+}
+
+fz_function *
+fz_keep_function(fz_context *ctx, fz_function *func)
+{
+ return (fz_function *)fz_keep_storable(ctx, &func->storable);
+}
+
+void
+fz_drop_function(fz_context *ctx, fz_function *func)
+{
+ fz_drop_storable(ctx, &func->storable);
+}
+
+unsigned int
+fz_function_size(fz_function *func)
+{
+ return (func ? func->size : 0);
+}