3. Node

A new node is created with node_ftlget.

<<funcdefs>>=
int node_ftlget(gf_node *node, sp_ftlist *ftl);

This node is setup so as to require no destroy callback.

<<funcs>>=
int node_ftlget(gf_node *node, sp_ftlist *ftl)
{
    gf_node_cables_alloc(node, 2);
    gf_node_set_block(node, 1);
    gf_node_set_compute(node, compute);
    gf_node_set_data(node, ftl);
    return GF_OK;
}
<<static_funcdefs>>=
static void compute(gf_node *node);
<<funcs>>=
static void compute(gf_node *node)
{
    int blksize;
    int n;
    sp_ftlist *ftl;
    gf_cable *in;
    gf_cable *out;

    blksize = gf_node_blksize(node);
    ftl = gf_node_get_data(node);

    gf_node_get_cable(node, 0, &in);
    gf_node_get_cable(node, 1, &out);

    for (n = 0; n < blksize; n++) {
        int pos;
        sp_ftbl *t;
        GFFLT x;
        x = 0;
        pos = floor(gf_cable_get(in, n));
        t = sp_ftlist_target_sa(ftl, n);
        if (x < t->size) x = t->tbl[pos];
        gf_cable_set(out, n, x);
    }
}



prev | home | next