mirror of
https://github.com/game-stop/veejay.git
synced 2025-12-19 22:30:06 +01:00
merged with libvevo from veejay-current
git-svn-id: svn://code.dyne.org/veejay/trunk@636 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Process with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = src include test examples
|
||||
SUBDIRS = src include test
|
||||
|
||||
bin_SCRIPTS = vevo-config
|
||||
|
||||
|
||||
7081
vevo-current/aclocal.m4
vendored
7081
vevo-current/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
30
vevo-current/config.guess
vendored
30
vevo-current/config.guess
vendored
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2004-09-07'
|
||||
timestamp='2005-04-22'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@@ -53,7 +53,7 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@@ -319,6 +319,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:OS/390:*:*)
|
||||
echo i370-ibm-openedition
|
||||
exit 0 ;;
|
||||
*:z/VM:*:*)
|
||||
echo s390-ibm-zvmoe
|
||||
exit 0 ;;
|
||||
*:OS400:*:*)
|
||||
echo powerpc-ibm-os400
|
||||
exit 0 ;;
|
||||
@@ -342,7 +345,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
DRS?6000:unix:4.0:6*)
|
||||
echo sparc-icl-nx6
|
||||
exit 0 ;;
|
||||
DRS?6000:UNIX_SV:4.2*:7*)
|
||||
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7 && exit 0 ;;
|
||||
esac ;;
|
||||
@@ -801,6 +804,9 @@ EOF
|
||||
i*:UWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-uwin
|
||||
exit 0 ;;
|
||||
amd64:CYGWIN*:*:*)
|
||||
echo x86_64-unknown-cygwin
|
||||
exit 0 ;;
|
||||
p*:CYGWIN*:*)
|
||||
echo powerpcle-unknown-cygwin
|
||||
exit 0 ;;
|
||||
@@ -1134,6 +1140,10 @@ EOF
|
||||
# From seanf@swdc.stratus.com.
|
||||
echo i860-stratus-sysv4
|
||||
exit 0 ;;
|
||||
i*86:VOS:*:*)
|
||||
# From Paul.Green@stratus.com.
|
||||
echo ${UNAME_MACHINE}-stratus-vos
|
||||
exit 0 ;;
|
||||
*:VOS:*:*)
|
||||
# From Paul.Green@stratus.com.
|
||||
echo hppa1.1-stratus-vos
|
||||
@@ -1194,6 +1204,9 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit 0 ;;
|
||||
NSE-?:NONSTOP_KERNEL:*:*)
|
||||
echo nse-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
NSR-?:NONSTOP_KERNEL:*:*)
|
||||
echo nsr-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@@ -1247,7 +1260,10 @@ EOF
|
||||
A*) echo alpha-dec-vms && exit 0 ;;
|
||||
I*) echo ia64-dec-vms && exit 0 ;;
|
||||
V*) echo vax-dec-vms && exit 0 ;;
|
||||
esac
|
||||
esac ;;
|
||||
*:XENIX:*:SysV)
|
||||
echo i386-pc-xenix
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
@@ -1407,7 +1423,9 @@ This script, last modified $timestamp, has failed to recognize
|
||||
the operating system you are using. It is advised that you
|
||||
download the most up to date version of the config scripts from
|
||||
|
||||
ftp://ftp.gnu.org/pub/gnu/config/
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
|
||||
and
|
||||
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
|
||||
|
||||
If the version you run ($0) is already up to date, please
|
||||
send the following data and any information you think might be
|
||||
|
||||
36
vevo-current/config.sub
vendored
36
vevo-current/config.sub
vendored
@@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2004-08-29'
|
||||
timestamp='2005-04-22'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@@ -70,7 +70,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@@ -231,13 +231,14 @@ case $basic_machine in
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
|
||||
| bfin \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| fr30 | frv \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| m32r | m32rle | m68000 | m68k | m88k | mcore \
|
||||
| m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@@ -262,12 +263,13 @@ case $basic_machine in
|
||||
| pyramid \
|
||||
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
|
||||
| sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
|
||||
| sparcv8 | sparcv9 | sparcv9b \
|
||||
| strongarm \
|
||||
| tahoe | thumb | tic4x | tic80 | tron \
|
||||
| v850 | v850e \
|
||||
| we32k \
|
||||
| x86 | xscale | xstormy16 | xtensa \
|
||||
| x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
|
||||
| z8k)
|
||||
basic_machine=$basic_machine-unknown
|
||||
;;
|
||||
@@ -298,7 +300,7 @@ case $basic_machine in
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| avr-* \
|
||||
| bs2000-* \
|
||||
| bfin-* | bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
@@ -310,7 +312,7 @@ case $basic_machine in
|
||||
| ip2k-* | iq2000-* \
|
||||
| m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | mcore-* \
|
||||
| m88110-* | m88k-* | maxq-* | mcore-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
| mips16-* \
|
||||
| mips64-* | mips64el-* \
|
||||
@@ -336,15 +338,16 @@ case $basic_machine in
|
||||
| romp-* | rs6000-* \
|
||||
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
|
||||
| sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
|
||||
| sparclite-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* \
|
||||
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
|
||||
| tron-* \
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
|
||||
| xtensa-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
|
||||
| xstormy16-* | xtensa-* \
|
||||
| ymp-* \
|
||||
| z8k-*)
|
||||
;;
|
||||
@@ -489,6 +492,10 @@ case $basic_machine in
|
||||
basic_machine=m88k-motorola
|
||||
os=-sysv3
|
||||
;;
|
||||
djgpp)
|
||||
basic_machine=i586-pc
|
||||
os=-msdosdjgpp
|
||||
;;
|
||||
dpx20 | dpx20-*)
|
||||
basic_machine=rs6000-bull
|
||||
os=-bosx
|
||||
@@ -1029,6 +1036,10 @@ case $basic_machine in
|
||||
basic_machine=hppa1.1-winbond
|
||||
os=-proelf
|
||||
;;
|
||||
xbox)
|
||||
basic_machine=i686-pc
|
||||
os=-mingw32
|
||||
;;
|
||||
xps | xps100)
|
||||
basic_machine=xps100-honeywell
|
||||
;;
|
||||
@@ -1297,6 +1308,9 @@ case $os in
|
||||
-kaos*)
|
||||
os=-kaos
|
||||
;;
|
||||
-zvmoe)
|
||||
os=-zvmoe
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
|
||||
@@ -37,6 +37,8 @@ AC_SUBST(LT_AGE)
|
||||
|
||||
dnl **********************************************************************
|
||||
dnl Options
|
||||
AC_ARG_ENABLE(assertions,
|
||||
[ --enable-mpool, Use memory pool])
|
||||
AC_ARG_ENABLE(assertions,
|
||||
[ --enable-assertions, Turn on runtime assertion checking.])
|
||||
AC_ARG_ENABLE(compile-warnings,
|
||||
@@ -129,6 +131,10 @@ if test "x$enable_assertions" != "xno"; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "x$enable_mpool" != "xno"; then
|
||||
AC_DEFINE(HAVE_MEMPOOL,,[memory pool])
|
||||
fi
|
||||
|
||||
AC_MSG_RESULT($warnCFLAGS)
|
||||
if test "x$cflags_set" != "xyes" ; then
|
||||
CFLAGS="$CFLAGS $warnCFLAGS"
|
||||
@@ -139,7 +145,6 @@ AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
include/Makefile
|
||||
examples/Makefile
|
||||
test/Makefile
|
||||
vevo-config
|
||||
])
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
INCLUDES = -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir) -I$(includedir) \
|
||||
-DG_LOG_DOMAIN=\"libvido\" -DLIBVIDO_VERSION=\"$(VERSION)\"
|
||||
|
||||
LIBVEVO = $(top_builddir)/src/libvevo.la
|
||||
|
||||
# *********************************************************************
|
||||
# The tools themselves
|
||||
EXAMPLES_BIN = hosttest
|
||||
|
||||
bin_PROGRAMS = $(EXAMPLES_BIN)
|
||||
|
||||
hosttest_SOURCES = testhost.c
|
||||
hosttest_LDADD = -lvevo -ldl
|
||||
hosttest_LDFLAGS = -export-dynamic
|
||||
@@ -1,432 +0,0 @@
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../include/vevo.h"
|
||||
#include "../include/livido.h"
|
||||
#include "../src/livido-utils.c"
|
||||
|
||||
int verbose = 1;
|
||||
|
||||
int errorcount = 0;
|
||||
int warningcount = 0;
|
||||
|
||||
typedef int (deepcheck_f)(livido_port_t *, char *);
|
||||
typedef struct {
|
||||
int ver; // -1 - end sentinel, 1 for specification 100
|
||||
int sets; // 1 - host, 2 - plugin, 3 - both
|
||||
int mand; // 0 - optional, 1 - mandatory
|
||||
char *name; // name of the property
|
||||
int atomtype; // atom type of the property, -1 - don't check - should be checked by func()
|
||||
int minc; // minimum number of elements, -1 - no limit
|
||||
int maxc; // maximum number of elements, -1 - no limit
|
||||
deepcheck_f *func; // deep check function to be called
|
||||
} property_desc_t;
|
||||
|
||||
deepcheck_f deep_plugininfo_filters;
|
||||
deepcheck_f deep_channel_templates;
|
||||
deepcheck_f deep_parameter_templates;
|
||||
deepcheck_f deep_filter_api_version;
|
||||
int test_port (livido_port_t *port, property_desc_t *properties, int porttype, char *portdesc);
|
||||
|
||||
|
||||
#define DESC_END {-1, 0, 0, "", 0, 0, 0 , NULL}
|
||||
|
||||
|
||||
property_desc_t port_plugininfo_desc[] = {
|
||||
{1, 2, 1, "type", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "filters", LIVIDO_ATOM_TYPE_PORTPTR, 1, -1 , &deep_plugininfo_filters},
|
||||
{1, 2, 1, "maintainer", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "version", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 0, "url", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_filterclass_desc[] = {
|
||||
{1, 2, 1, "type", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "name", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "description", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "version", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "api_version", LIVIDO_ATOM_TYPE_INT, 1, 1 , &deep_filter_api_version},
|
||||
{1, 2, 1, "license", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "flags", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "init_func", LIVIDO_ATOM_TYPE_VOIDPTR, 1, 1 , NULL},
|
||||
{1, 2, 1, "process_func", LIVIDO_ATOM_TYPE_VOIDPTR, 1, 1 , NULL},
|
||||
{1, 2, 1, "deinit_func", LIVIDO_ATOM_TYPE_VOIDPTR, 1, 1 , NULL},
|
||||
{1, 2, 1, "in_channel_templates", LIVIDO_ATOM_TYPE_PORTPTR, 0, -1 , &deep_channel_templates},
|
||||
{1, 2, 1, "out_channel_templates", LIVIDO_ATOM_TYPE_PORTPTR, 0, -1 , &deep_channel_templates},
|
||||
{1, 2, 1, "in_parameter_templates", LIVIDO_ATOM_TYPE_PORTPTR, 0, -1 , &deep_parameter_templates},
|
||||
{1, 2, 1, "out_parameter_templates", LIVIDO_ATOM_TYPE_PORTPTR, 0, -1 , &deep_parameter_templates},
|
||||
{1, 2, 0, "url", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_chantemplate_desc[] = {
|
||||
{1, 2, 1, "type", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "name", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "flags", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "palette_list", LIVIDO_ATOM_TYPE_INT, 1, -1 , NULL},
|
||||
{1, 2, 0, "description", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 0, "width", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 0, "height", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 0, "same_as_size", LIVIDO_ATOM_TYPE_PORTPTR, 1, 1 , NULL},
|
||||
{1, 2, 0, "same_as_palette", LIVIDO_ATOM_TYPE_PORTPTR, 1, 1 , NULL},
|
||||
{1, 2, 0, "optional", LIVIDO_ATOM_TYPE_BOOLEAN, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_desc[] = {
|
||||
{1, 2, 1, "type", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "name", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "kind", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
{1, 2, 1, "flags", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 0, "description", LIVIDO_ATOM_TYPE_STRING, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_number_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_DOUBLE, 1, 1 , NULL},
|
||||
{1, 2, 1, "min", LIVIDO_ATOM_TYPE_DOUBLE, 1, 1 , NULL},
|
||||
{1, 2, 1, "max", LIVIDO_ATOM_TYPE_DOUBLE, 1, 1 , NULL},
|
||||
{1, 2, 0, "wrap", LIVIDO_ATOM_TYPE_BOOLEAN, 1, 1 , NULL},
|
||||
{1, 2, 0, "transition", LIVIDO_ATOM_TYPE_BOOLEAN, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_index_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "min", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 1, "max", LIVIDO_ATOM_TYPE_INT, 1, 1 , NULL},
|
||||
{1, 2, 0, "wrap", LIVIDO_ATOM_TYPE_BOOLEAN, 1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
property_desc_t port_paramtemplate_text_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_STRING,1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_switch_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_BOOLEAN,1, 1 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_colorrgba_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_DOUBLE,3, 4 , NULL},
|
||||
{1, 2, 1, "min", LIVIDO_ATOM_TYPE_DOUBLE,3, 4 , NULL},
|
||||
{1, 2, 1, "max", LIVIDO_ATOM_TYPE_DOUBLE,3, 4 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
property_desc_t port_paramtemplate_coordinate_desc[] = {
|
||||
{1, 2, 1, "default", LIVIDO_ATOM_TYPE_DOUBLE,2, 2 , NULL},
|
||||
{1, 2, 1, "min", LIVIDO_ATOM_TYPE_DOUBLE,2, 2 , NULL},
|
||||
{1, 2, 1, "max", LIVIDO_ATOM_TYPE_DOUBLE,2, 2 , NULL},
|
||||
DESC_END
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
property_desc_t *property_desc;
|
||||
} kind_parameter_desc_t;
|
||||
|
||||
kind_parameter_desc_t kind_descs[] = {
|
||||
{"INDEX", port_paramtemplate_index_desc},
|
||||
{"NUMBER", port_paramtemplate_number_desc},
|
||||
{"TEXT", port_paramtemplate_text_desc},
|
||||
{"SWITCH", port_paramtemplate_switch_desc},
|
||||
{"COLOR_RGBA", port_paramtemplate_colorrgba_desc},
|
||||
{"COORDINATE", port_paramtemplate_coordinate_desc},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
||||
property_desc_t *create_joint(property_desc_t *p1, property_desc_t *p2)
|
||||
{
|
||||
int p1num, p2num;
|
||||
property_desc_t *joint;
|
||||
|
||||
for (p1num = 0; p1[p1num].ver != -1; p1num++);
|
||||
for (p2num = 0; p2[p2num].ver != -1; p2num++);
|
||||
|
||||
joint = malloc(sizeof(property_desc_t) * (p1num + p2num + 1));
|
||||
memcpy (joint, p1, sizeof(property_desc_t) * p1num);
|
||||
memcpy (joint + p1num, p2, sizeof(property_desc_t) * (p2num + 1));
|
||||
|
||||
return joint;
|
||||
}
|
||||
|
||||
|
||||
int deep_filter_api_version(livido_port_t *port, char *propname)
|
||||
{
|
||||
int error;
|
||||
int api_version = livido_get_int_value(port, propname, &error);
|
||||
if (api_version != 100)
|
||||
{
|
||||
printf("WARNING: Filter's api_version is %i, this host has 100\n", api_version );
|
||||
warningcount++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deep_channel_templates(livido_port_t *port, char *propname)
|
||||
{
|
||||
int numtemplates = livido_property_num_elements(port, propname);
|
||||
int error;
|
||||
livido_port_t **ports = (livido_port_t **) livido_get_portptr_array (port, propname, &error);
|
||||
for (int i = 0; i < numtemplates; i++)
|
||||
{
|
||||
char tmp[1024];
|
||||
sprintf(tmp, "%s number %i inside PLUGIN_INFO", propname, i);
|
||||
test_port(ports[i], port_chantemplate_desc, LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE, tmp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deep_parameter_templates(livido_port_t *port, char *propname)
|
||||
{
|
||||
int numtemplates = livido_property_num_elements(port, propname);
|
||||
int error;
|
||||
livido_port_t **ports = (livido_port_t **) livido_get_portptr_array (port, propname, &error);
|
||||
for (int i = 0; i < numtemplates; i++)
|
||||
{
|
||||
char tmp[1024];
|
||||
sprintf(tmp, "%s number %i inside PLUGIN_INFO", propname, i);
|
||||
property_desc_t *curport;
|
||||
char *kindstr = livido_get_string_value(ports[i], "kind", &error);
|
||||
if (error || kindstr == NULL)
|
||||
{
|
||||
printf("ERROR: Parameter template port (%i) does not have '''kind''' property", i);
|
||||
errorcount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Find the kind desc and join it with general parameter template desc
|
||||
kind_parameter_desc_t *kinds;
|
||||
for (kinds = kind_descs; (kinds->name != NULL) && strcmp(kindstr, kinds->name); kinds++);
|
||||
|
||||
if (kinds->name == NULL)
|
||||
{
|
||||
printf("ERROR: Uknown '''kind''' %s of parameter template port %i\n", kindstr, i);
|
||||
errorcount++;
|
||||
continue; // since we didn't do the join skip the check;
|
||||
|
||||
} else
|
||||
{
|
||||
curport = create_joint(port_paramtemplate_desc, kinds->property_desc);
|
||||
};
|
||||
|
||||
test_port(ports[i], curport, LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE, tmp);
|
||||
free(curport);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int deep_plugininfo_filters(livido_port_t *port, char *propname)
|
||||
{
|
||||
int numfilters = livido_property_num_elements(port, propname);
|
||||
int error;
|
||||
livido_port_t **ports = (livido_port_t **) livido_get_portptr_array (port, propname, &error);
|
||||
for (int i = 0; i < numfilters; i++)
|
||||
{
|
||||
char tmp[1024];
|
||||
sprintf(tmp, "FILTER_CLASS number %i inside PLUGIN_INFO", i);
|
||||
test_port(ports[i], port_filterclass_desc, LIVIDO_PORT_TYPE_FILTER_CLASS, tmp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Implementation of default malloc/free/memset/memcpy
|
||||
void *livido_malloc_f (size_t size) { return malloc(size); }
|
||||
void livido_free_f (void *ptr) { free(ptr); }
|
||||
void *livido_memset_f (void *s, int c, size_t n) { return memset(s, c, n); }
|
||||
void *livido_memcpy_f (void *dest, const void *src, size_t n) { return memcpy( dest, src, n); }
|
||||
|
||||
|
||||
|
||||
|
||||
int check_property_mandatory (livido_port_t *port, char *propname, char *propdesc)
|
||||
{
|
||||
int error = livido_property_get(port, propname, 0, NULL);
|
||||
if (error)
|
||||
{
|
||||
printf("ERROR: Missing mandatory property \'\'%s\'\' of port %s, code: %i\n", propname, propdesc, error);
|
||||
errorcount ++;
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int check_property_type (livido_port_t *port, char *propname, int atom_type, char *propdesc)
|
||||
{
|
||||
int error = livido_property_get(port, propname, 0, NULL);
|
||||
if (!error)
|
||||
{
|
||||
int real_atomtype = livido_property_atom_type(port, propname);
|
||||
if (real_atomtype != atom_type)
|
||||
{
|
||||
printf("ERROR: Type of property %s is %i, must be: %i\n", propdesc, real_atomtype, atom_type);
|
||||
errorcount ++;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0; // returning ok when no type defined
|
||||
}
|
||||
int check_property_type_mandatory (livido_port_t *port, char *propname, int atom_type, char *propdesc)
|
||||
{
|
||||
int retval = check_property_mandatory(port, propname, propdesc);
|
||||
if (retval)
|
||||
return retval;
|
||||
return check_property_type(port, propname, atom_type, propdesc);
|
||||
}
|
||||
|
||||
int check_property_type_mandatory_one (livido_port_t *port, char *propname, int atom_type, char *propdesc)
|
||||
{
|
||||
int retval = check_property_type_mandatory(port, propname, atom_type, propdesc);
|
||||
if (retval)
|
||||
return retval;
|
||||
if (livido_property_num_elements(port, propname) != 1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// checks if "type" property of the port exists and is of correct atom type, and then check if the value matches porttype
|
||||
void check_port_type (livido_port_t *port, int porttype, char *portdesc)
|
||||
{
|
||||
char tmp[1024];
|
||||
sprintf(tmp, "type property of port %s\n", portdesc);
|
||||
int retval = check_property_type_mandatory(port, "type", LIVIDO_ATOM_TYPE_INT, tmp);
|
||||
if (retval)
|
||||
{
|
||||
printf("FATAL: Last error was fatal\n");
|
||||
exit(1);
|
||||
} else
|
||||
{
|
||||
int error;
|
||||
int real_type = livido_get_int_value(port, "type", &error);
|
||||
// error cannot happen at this point, since we already checked mandatority and atom type
|
||||
if (real_type != porttype)
|
||||
{
|
||||
printf("FATAL: Type of port %s must be %i, but is %i\n", portdesc, porttype, real_type);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int test_port (livido_port_t *port, property_desc_t *properties, int porttype, char *portdesc)
|
||||
{
|
||||
// First test the port type
|
||||
check_port_type(port, porttype, portdesc);
|
||||
|
||||
// Now check for properties not in standard
|
||||
char **property_names = livido_list_properties(port); // FIXME: Who frees this memory?
|
||||
for (char **lookup_key = property_names; *lookup_key != 0; lookup_key++ )
|
||||
{
|
||||
int property_in_standard = 0;
|
||||
for (property_desc_t *standard_property = properties; standard_property->ver != -1; standard_property++)
|
||||
{
|
||||
if (!strcmp(standard_property->name, *lookup_key))
|
||||
property_in_standard = 1;
|
||||
}
|
||||
if (!strncmp(*lookup_key, "PLUGIN_", 7))
|
||||
property_in_standard = 1;
|
||||
|
||||
if (!strncmp(*lookup_key, "HOST_", 5))
|
||||
property_in_standard = 1;
|
||||
|
||||
if (!property_in_standard)
|
||||
{
|
||||
printf("WARNING: Property \'%s\' of port %s is not defined in standard\n", *lookup_key, portdesc);
|
||||
warningcount++;
|
||||
}
|
||||
}
|
||||
|
||||
// now go trough a list of port's properties defined by standard and check them
|
||||
for (property_desc_t *standard_property = properties; standard_property->ver != -1; standard_property++)
|
||||
{
|
||||
char *propname = standard_property->name;
|
||||
// check existence
|
||||
int error = livido_property_get(port, propname, 0, NULL);
|
||||
if (error == LIVIDO_ERROR_NOSUCH_PROPERTY) // we ignore no such element property here, we deal with that later!
|
||||
{
|
||||
// property does not exist
|
||||
if (standard_property->mand)
|
||||
{
|
||||
printf("ERROR: Missing mandatory property \'\'%s\'\' of port %s\n", propname, portdesc);
|
||||
errorcount ++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Property exists, check type
|
||||
int atomtype = livido_property_atom_type(port, propname);
|
||||
if (standard_property->atomtype >= 0 && standard_property->atomtype != atomtype)
|
||||
{
|
||||
printf("ERROR: Type of property \'\'%s\'\' (of port %s) is %i, must be: %i\n", propname, portdesc, atomtype, standard_property->atomtype);
|
||||
errorcount ++;
|
||||
continue;
|
||||
}
|
||||
// Property exists and has right type, check if array is properly laid out
|
||||
int numelements = livido_property_num_elements(port, propname);
|
||||
if (standard_property->minc >= 0 && standard_property->minc > numelements)
|
||||
{
|
||||
printf("ERROR: Property \'\'%s\'\' (of port %s) has %i elements, which is less than minimum of %i\n", propname, portdesc, numelements, standard_property->minc);
|
||||
errorcount ++;
|
||||
continue;
|
||||
}
|
||||
if (standard_property->maxc >= 0 && standard_property->maxc < numelements)
|
||||
{
|
||||
printf("ERROR: Property \'\'%s\'\' (of port %s) has %i elements, which is more than maximum of %i\n", propname, portdesc, numelements, standard_property->minc);
|
||||
errorcount ++;
|
||||
continue;
|
||||
}
|
||||
// FIXME: We might want to call deep check functions when we already checked _all_ properties
|
||||
if (standard_property->func)
|
||||
{
|
||||
standard_property->func(port, propname);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
char *name;
|
||||
void *handle;
|
||||
livido_setup_f livido_setup;
|
||||
livido_port_t *plugin_info;
|
||||
|
||||
|
||||
if (argc != 2) {
|
||||
printf("Livido conformance testing host 0.1\n");
|
||||
printf("Usage: testhost plugin_name.so\n");
|
||||
return 0;
|
||||
}
|
||||
name = argv[1];
|
||||
|
||||
handle = dlopen(name, RTLD_NOW); // We want the whole load _now_
|
||||
if (!handle) { printf("FATAL: dlopen failed on %s because of %s\n", name, dlerror()); return 1; };
|
||||
|
||||
livido_setup = (livido_setup_f) dlsym(handle, "livido_setup");
|
||||
if (!livido_setup) { printf("FATAL: function livido_setup not found in %s\n", name); return 1; };
|
||||
|
||||
plugin_info = livido_setup();
|
||||
if (!plugin_info) { printf("FATAL: livido_setup() did not return a pointer to livido port, finishing\n"); return 1; };
|
||||
printf("CHECKPOINT: Loading of plugin and running livido_setup() successeful\n");
|
||||
|
||||
|
||||
test_port(plugin_info, port_plugininfo_desc, LIVIDO_PORT_TYPE_PLUGIN_INFO, "returned by livido_setup()");
|
||||
|
||||
|
||||
dlclose(handle);
|
||||
|
||||
printf("\nPlugin %s has produced %i errors and %i warnings\n", name, errorcount, warningcount);
|
||||
|
||||
// FIXME: Do the freeing of the all template ports
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -16,23 +16,14 @@
|
||||
LiViDO is developed by:
|
||||
|
||||
Niels Elburg - http://veejay.sf.net
|
||||
|
||||
Gabriel "Salsaman" Finch - http://lives.sourceforge.net
|
||||
|
||||
Denis "Jaromil" Rojo - http://freej.dyne.org
|
||||
|
||||
Tom Schouten - http://zwizwa.fartit.com
|
||||
|
||||
Andraz Tori - http://cvs.cinelerra.org
|
||||
|
||||
reviewed with suggestions and contributions from:
|
||||
|
||||
Silvano "Kysucix" Galliani - http://freej.dyne.org
|
||||
|
||||
Kentaro Fukuchi - http://megaui.net/fukuchi
|
||||
|
||||
Jun Iio - http://www.malib.net
|
||||
|
||||
Carlo Prelz - http://www2.fluido.as:8080/
|
||||
|
||||
*/
|
||||
@@ -40,18 +31,24 @@
|
||||
#define __LIVIDO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#define LIVIDO_BEGIN_DECLS extern "C" {
|
||||
#define LIVIDO_END_DECLS }
|
||||
#else
|
||||
#define LIVIDO_BEGIN_DECLS
|
||||
#define LIVIDO_END_DECLS
|
||||
#endif
|
||||
|
||||
/* for size_t */
|
||||
#ifndef FALSE
|
||||
#define FALSE (0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (!FALSE)
|
||||
#endif
|
||||
|
||||
LIVIDO_BEGIN_DECLS
|
||||
#include <sys/types.h>
|
||||
|
||||
/* API version * 100 */
|
||||
#define LIVIDO_API_VERSION 100
|
||||
|
||||
/* Palette types */
|
||||
#
|
||||
/* RGB palettes */
|
||||
#define LIVIDO_PALETTE_RGB888 1
|
||||
#define LIVIDO_PALETTE_RGB24 1
|
||||
#define LIVIDO_PALETTE_BGR888 2
|
||||
@@ -63,150 +60,54 @@ extern "C" {
|
||||
#define LIVIDO_PALETTE_RGBFLOAT 5
|
||||
#define LIVIDO_PALETTE_ARGBFLOAT 6
|
||||
#define LIVIDO_PALETTE_RGB565 7
|
||||
|
||||
/* YUV palettes */
|
||||
#define LIVIDO_PALETTE_YUV422P 513
|
||||
#define LIVIDO_PALETTE_YV16 513
|
||||
|
||||
/*
|
||||
LIVIDO_PALETTE_YUV422P LIVIDO_PALETTE_YV16
|
||||
[Official name 'YV16', 8 bit Y plane followed by 8
|
||||
bit 2x1 subsampled V and U planes. Planar.]
|
||||
*/
|
||||
/*
|
||||
LIVIDO_PALETTE_YUV420P LIVIDO_PALETTE_YV12
|
||||
[8 bit Y plane followed by 8 bit 2x2 subsampled V and U planes. Planar
|
||||
(Official name YV12)]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YUV420P 514
|
||||
#define LIVIDO_PALETTE_YV12 514
|
||||
/*
|
||||
LIVIDO_PALETTE_YVU420P LIVIDO_PALETTE_I420
|
||||
[Same as YUV420P , but U and V are swapped. Planar.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YVU420P 515
|
||||
#define LIVIDO_PALETTE_I420 515
|
||||
|
||||
/*
|
||||
LIVIDO_PALETTE_YUV444P
|
||||
[Unofficial , 8 bit Y plane followed by 8 bit U and V planes, no
|
||||
subsampling. Planar.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YUV444P 516
|
||||
/*
|
||||
LIVIDO_PALETTE_YUVA4444P LIVIDO_PALETTE_YUV4444P
|
||||
[Unofficial, like YUV444P but with Alpha. Planar.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YUV4444P 517
|
||||
/*
|
||||
LIVIDO_PALETTE_YUYV8888
|
||||
[Like YUV 4:2:2 but with different component ordering within the
|
||||
u_int32 macropixel. Packed.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YUYV8888 518
|
||||
/*
|
||||
LIVIDO_PALETTE_YUYV8888
|
||||
[Like YUV 4:2:2 but with different component ordering within the
|
||||
u_int32 macropixel. Packed.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_UYVY8888 519
|
||||
/*
|
||||
LIVIDO_PALETTE_UYVY8888
|
||||
[YUV 4:2:2 (Y sample at every pixel, U and V sampled at every second
|
||||
pixel horizontally on each line). A macropixel contains 2 pixels in 1
|
||||
u_int32. Packed.]
|
||||
*/
|
||||
#define LIVIDO_PALETTE_YUV411 520
|
||||
/*
|
||||
LIVIDO_PALETTE_YUV411
|
||||
[IEEE 1394 Digital Camera 1.04 spec. Is packed YUV format
|
||||
with a 6 pixel macroblock structure containing 4 pixels.
|
||||
Ordering is U2 Y0 Y1 V2 Y2 Y3. Uses same bandwith as YUV420P
|
||||
Only used for SMPTE DV NTSC.]
|
||||
*/
|
||||
|
||||
|
||||
/* Pending: PALETTE YUV888, YUVA888 needed in cinerella */
|
||||
#define LIVIDO_PALETTE_YUV888 521
|
||||
#define LIVIDO_PALETTE_YUVA8888 522
|
||||
|
||||
/* Alpha palettes */
|
||||
/*
|
||||
Alpha palettes have two uses: 1) for masks, 2) to split colour inputs into single colour channels, or to combine single colour channels into a combined channel. The order of colour channels is the same as the order in the combined channel. For example if an input in RGB24 palette is split into 3 non-mask alpha channels, then the alpha channels will be in the order: Red, Green, Blue. A single non-mask alpha channel would represent the luminance.
|
||||
|
||||
*/
|
||||
#define LIVIDO_PALETTE_A1 1025
|
||||
#define LIVIDO_PALETTE_A8 1026
|
||||
#define LIVIDO_PALETTE_AFLOAT 1027
|
||||
|
||||
/* Filter flags */
|
||||
#define LIVIDO_FILTER_NON_REALTIME (1<<0)
|
||||
#define LIVIDO_FILTER_CAN_DO_INPLACE (1<<1)
|
||||
#define LIVIDO_FILTER_STATELESS (1<<2)
|
||||
#define LIVIDO_FILTER_NON_STATELESS (1<<2)
|
||||
#define LIVIDO_FILTER_IS_CONVERTOR (1<<3)
|
||||
|
||||
/* Channel flags */
|
||||
#define LIVIDO_CHANNEL_CHANGE_UNADVISED (1<<0)
|
||||
/*
|
||||
LIVIDO_CHANNEL_CHANGE_UNADVISED
|
||||
plugin MAY use this flag to tell the host, that changing of channel size causes possibly unwanted behaviour of the filter. Unwanted behaviour can for example be reseting the accumulated values which causes the visual result of filter to change in unexpected way or maybe the next call to process function will take disproportional amount of time due to reinitialization. Host is safe to ignore the flag and plugin MUST still be useful, though functionality may suffer.
|
||||
*/
|
||||
#define LIVIDO_CHANNEL_PALETTE_UNADVISED (1<<1)
|
||||
/*
|
||||
LIVIDO_CHANNEL_PALETTE_UNADVISED
|
||||
plugin MAY use this flag to tell the host, that changing of channel palette causes possibly unwanted behaviour of the filter. Unwanted behaviour can for example be reseting the accumulated values which causes the visual result of filter to change in unexpected way or maybe the next call to process function will take disproportional amount of time due to reinitialization. Host is safe to ignore the flag and plugin MUST still be useful, though functionality may suffer.
|
||||
*/
|
||||
|
||||
/* Parameter flags */
|
||||
#define LIVIDO_PARAMETER_CHANGE_UNADVISED (1<<0)
|
||||
/*
|
||||
plugin MAY use this flag to tell the host, that changing of this parameter causes possibly unwanted behaviour of the filter. Unwanted behaviour can for example be reseting the accumulated values which causes the visual result of filter to change in unexpected way or maybe the next call to process function will take disproportional amount of time due to reinitialization. Host is safe to ignore the flag and plugin MUST still be useful, though functionality may suffer.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/* Property flags */
|
||||
#define LIVIDO_PROPERTY_READONLY (1<<0)
|
||||
|
||||
/* YUV sampling types */
|
||||
#define LIVIDO_YUV_SAMPLING_NONE 0
|
||||
#define LIVIDO_YUV_SAMPLING_SMPTE 1
|
||||
#define LIVIDO_YUV_SAMPLING_JPEG 2
|
||||
#define LIVIDO_YUV_SAMPLING_MPEG2 3
|
||||
#define LIVIDO_YUV_SAMPLING_DVPAL 4
|
||||
#define LIVIDO_YUV_SAMPLING_DVNTSC 5
|
||||
|
||||
/* Interlace types */
|
||||
#define LIVIDO_INTERLACE_NONE 0
|
||||
#define LIVIDO_INTERLACE_TOPFIRST 1
|
||||
#define LIVIDO_INTERLACE_BOTTOMFIRST 2
|
||||
#define LIVIDO_INTERLACE_PROGRESSIVE 3
|
||||
|
||||
/* Livido errors */
|
||||
/* Core errors */
|
||||
#define LIVIDO_NO_ERROR 0
|
||||
#define LIVIDO_ERROR_MEMORY_ALLOCATION 1
|
||||
#define LIVIDO_ERROR_PROPERTY_READONLY 2
|
||||
#define LIVIDO_ERROR_NOSUCH_ELEMENT 3
|
||||
#define LIVIDO_ERROR_NOSUCH_PROPERTY 4
|
||||
#define LIVIDO_ERROR_WRONG_ATOM_TYPE 5
|
||||
|
||||
/* Plugin errors */
|
||||
#define LIVIDO_ERROR_TOO_MANY_INSTANCES 6
|
||||
#define LIVIDO_ERROR_HARDWARE 7
|
||||
|
||||
/* Atom types */
|
||||
/* Fundamental atoms */
|
||||
#define LIVIDO_ATOM_TYPE_INT 1
|
||||
#define LIVIDO_ATOM_TYPE_DOUBLE 2
|
||||
#define LIVIDO_ATOM_TYPE_BOOLEAN 3
|
||||
#define LIVIDO_ATOM_TYPE_STRING 4
|
||||
|
||||
/* Pointer atoms */
|
||||
#define LIVIDO_ATOM_TYPE_VOIDPTR 65
|
||||
#define LIVIDO_ATOM_TYPE_PORTPTR 66
|
||||
|
||||
/* Port types */
|
||||
#define LIVIDO_PORT_TYPE_PLUGIN_INFO 1
|
||||
#define LIVIDO_PORT_TYPE_FILTER_CLASS 2
|
||||
#define LIVIDO_PORT_TYPE_FILTER_INSTANCE 3
|
||||
@@ -216,65 +117,70 @@ plugin MAY use this flag to tell the host, that changing of this parameter cause
|
||||
#define LIVIDO_PORT_TYPE_PARAMETER 7
|
||||
#define LIVIDO_PORT_TYPE_GUI 8
|
||||
|
||||
//#define FUNCSTRUCT
|
||||
/*
|
||||
Uncomment the #define above and recompile all
|
||||
*/
|
||||
|
||||
A port is a set of one or more properties
|
||||
|
||||
Each port has a mandatory property called "type" (see below), depending upon "type" property port has other mandatory and optional properties.
|
||||
typedef int (*livido_init_f) (livido_port_t * filter_instance);
|
||||
typedef int (*livido_process_f) (livido_port_t * filter_instance,
|
||||
double timestamp);
|
||||
typedef int (*livido_deinit_f) (livido_port_t * filter_instance);
|
||||
|
||||
"type" can be one of:
|
||||
|
||||
* LIVIDO_PORT_TYPE_PLUGIN_INFO : Information about plugin and list of filter classes it includes
|
||||
* LIVIDO_PORT_TYPE_FILTER_CLASS : Descriptive information about single filter class
|
||||
* LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE : Information about what kinds of channels filter accepts
|
||||
* LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE : Information about what kinds of parameters filter has
|
||||
* LIVIDO_PORT_TYPE_FILTER_INSTANCE : All data about an instance
|
||||
* LIVIDO_PORT_TYPE_CHANNEL : Instantination of a channel
|
||||
* LIVIDO_PORT_TYPE_PARAMETER : Instantination of a parameter
|
||||
typedef void *(*livido_malloc_f) (size_t size);
|
||||
typedef void (*livido_free_f) (void *ptr);
|
||||
typedef void *(*livido_memset_f) (void *s, int c, size_t n);
|
||||
typedef void *(*livido_memcpy_f) (void *dest, const void *src, size_t n);
|
||||
typedef livido_port_t *(*livido_port_new_f) (int);
|
||||
typedef void (*livido_port_free_f) (livido_port_t * port);
|
||||
typedef int (*livido_property_set_f) (livido_port_t *, const char *, int, int, void *);
|
||||
typedef int (*livido_property_get_f) (livido_port_t *, const char *, int, void *);
|
||||
typedef int (*livido_property_num_elements_f) (livido_port_t *, const char *);
|
||||
typedef size_t(*livido_property_element_size_f) (livido_port_t *, const char *, const int);
|
||||
typedef int (*livido_property_atom_type_f) (livido_port_t *, const char *);
|
||||
typedef char **(*livido_list_properties_f) (livido_port_t *);
|
||||
|
||||
* LIVIDO_PORT_TYPE_GUI : described in the separate livido GUI extension (TODO)
|
||||
typedef struct
|
||||
{
|
||||
void (*f)();
|
||||
// void *f;
|
||||
} livido_setup_t;
|
||||
typedef livido_port_t *(*livido_setup_f) (const livido_setup_t list[], int );
|
||||
|
||||
"type" is a single valued property with atom_type LIVIDO_ATOM_TYPE_INT.
|
||||
#define LIVIDO_PLUGIN \
|
||||
static livido_port_t *(*livido_port_new) (int) = 0;\
|
||||
static void (*livido_port_free) (livido_port_t * port) = 0;\
|
||||
static int (*livido_property_set) (livido_port_t * port,const char *key, int atom_type, int num_elems, void *value) = 0;\
|
||||
static int (*livido_property_get) (livido_port_t * port,const char *key, int idx, void *value) = 0;\
|
||||
static int (*livido_property_num_elements) (livido_port_t * port,const char *key) = 0;\
|
||||
static int (*livido_property_atom_type) (livido_port_t * port,const char *key) = 0;\
|
||||
static size_t(*livido_property_element_size) (livido_port_t * port,const char *key, const int idx) = 0;\
|
||||
static char **(*livido_list_properties) (livido_port_t * port) = 0;\
|
||||
static void *(*livido_malloc) (size_t size) = 0;\
|
||||
static void (*livido_free) (void *ptr) = 0;\
|
||||
static void *(*livido_memset) (void *s, int c, size_t n) = 0;\
|
||||
static void *(*livido_memcpy) (void *dest, const void *src, size_t n) = 0;\
|
||||
|
||||
The host should provide its own mediation layer for providing a datacontainer for its port.
|
||||
This host uses the mediation layer, where a new port is defined.
|
||||
|
||||
*/
|
||||
#ifndef HAVE_LIVIDO_PORT_T
|
||||
#define HAVE_LIVIDO_PORT_T
|
||||
typedef void livido_port_t;
|
||||
#endif
|
||||
|
||||
extern void livido_port_free(livido_port_t * port);
|
||||
extern livido_port_t *livido_port_new(int port_type);
|
||||
|
||||
extern int livido_property_set(livido_port_t * port, const char *key,
|
||||
int atom_type, int num_elems,
|
||||
void *value);
|
||||
extern int livido_property_get(livido_port_t * port, const char *key,
|
||||
int idx, void *value);
|
||||
|
||||
extern int livido_property_num_elements(livido_port_t * port,
|
||||
const char *key);
|
||||
extern int livido_property_atom_type(livido_port_t * port,
|
||||
const char *key);
|
||||
extern size_t livido_property_element_size(livido_port_t * port,
|
||||
const char *key,
|
||||
const int idx);
|
||||
extern char **livido_list_properties(livido_port_t * port);
|
||||
|
||||
extern void *livido_malloc_f(size_t size);
|
||||
extern void livido_free_f(void *ptr);
|
||||
extern void *livido_memset_f(void *s, int c, size_t n);
|
||||
extern void *livido_memcpy_f(void *dest, const void *src, size_t n);
|
||||
|
||||
typedef livido_port_t *(*livido_setup_f) (void);
|
||||
typedef int (*livido_init_f) (livido_port_t * filter_instance);
|
||||
typedef int (*livido_process_f) (livido_port_t * filter_instance,
|
||||
double timestamp);
|
||||
typedef int (*livido_deinit_f) (livido_port_t * filter_instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* Using void* to pass base address of function, needs explicit typecast and host
|
||||
must match ordering */
|
||||
#define LIVIDO_IMPORT(list) \
|
||||
{\
|
||||
livido_malloc = (livido_malloc_f) list[0].f;\
|
||||
livido_free = (livido_free_f) list[1].f;\
|
||||
livido_memset = (livido_memset_f) list[2].f;\
|
||||
livido_memcpy = (livido_memcpy_f) list[3].f;\
|
||||
livido_port_free = (livido_port_free_f) list[5].f;\
|
||||
livido_port_new = (livido_port_new_f) list[4].f;\
|
||||
livido_property_set = (livido_property_set_f) list[6].f;\
|
||||
livido_property_get = (livido_property_get_f) list[7].f;\
|
||||
livido_property_num_elements = (livido_property_num_elements_f) list[8].f;\
|
||||
livido_property_atom_type = (livido_property_atom_type_f) list[9].f;\
|
||||
livido_property_element_size = (livido_property_element_size_f) list[10].f;\
|
||||
livido_list_properties = (livido_list_properties_f) list[11].f;\
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
LIVIDO_END_DECLS
|
||||
#endif // #ifndef __LIVIDO_H__
|
||||
|
||||
36
vevo-current/include/lowlevel.h
Normal file
36
vevo-current/include/lowlevel.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright (c) 2004-2005 N.Elburg <nelburg@looze.net>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef VEVO_LOW_LEVEL_H
|
||||
#define VEVO_LOW_LEVEL_H
|
||||
/* Mediation layer structures, provided by this host */
|
||||
typedef struct {
|
||||
int type;
|
||||
void *value;
|
||||
size_t size;
|
||||
} atom_t;
|
||||
#endif
|
||||
53
vevo-current/include/pool.h
Normal file
53
vevo-current/include/pool.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (c) 2004-2005 N.Elburg <nelburg@looze.net>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VEVO_POOL_H
|
||||
#define VEVO_POOL_H
|
||||
#ifdef VEVO_MEMPOOL
|
||||
/* Have 160 atoms and 160 atom slots available ,
|
||||
uses aprox. 4Kb of memory.
|
||||
Use a value that is a multiple of 4
|
||||
*/
|
||||
#ifndef VEVO_MEM_LIMIT
|
||||
#define VEVO_MEM_LIMIT 2048
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define ATOM_INT 0
|
||||
#define ATOM_PTR 1
|
||||
#define ATOM_DBL 2
|
||||
#define ATOM_ATOM 3
|
||||
|
||||
void *vevo_new_pool(void);
|
||||
void vevo_free_pool(void *v);
|
||||
|
||||
void *vevo_malloc(void *v, int vevo_type);
|
||||
int vevo_pool_verify(void *v);
|
||||
void vevo_free(void *v, void *ptr, int vevo_type);
|
||||
|
||||
#endif
|
||||
@@ -1,17 +1,29 @@
|
||||
/* VeVo is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
/*
|
||||
Copyright (c) 2004-2005 N.Elburg <nelburg@looze.net>
|
||||
|
||||
VeVo is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
All rights reserved.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this source code; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
# ifndef VEVO_H_INCLUDED
|
||||
@@ -27,6 +39,30 @@
|
||||
#define TRUE 1
|
||||
#endif
|
||||
|
||||
#define HAVE_LIVIDO_PORT_T
|
||||
#define HAVE_VEVO_PORT_T
|
||||
typedef void livido_port_t;
|
||||
|
||||
|
||||
///# sed s/LIVIDO/VEVO
|
||||
#define VEVO_PROPERTY_READONLY (1<<0)
|
||||
|
||||
#define VEVO_NO_ERROR 0
|
||||
#define VEVO_ERROR_MEMORY_ALLOCATION 1
|
||||
#define VEVO_ERROR_PROPERTY_READONLY 2
|
||||
#define VEVO_ERROR_NOSUCH_ELEMENT 3
|
||||
#define VEVO_ERROR_NOSUCH_PROPERTY 4
|
||||
#define VEVO_ERROR_WRONG_ATOM_TYPE 5
|
||||
#define VEVO_ERROR_TOO_MANY_INSTANCES 6
|
||||
#define VEVO_ERROR_HARDWARE 7
|
||||
#define VEVO_ATOM_TYPE_INT 1
|
||||
#define VEVO_ATOM_TYPE_DOUBLE 2
|
||||
#define VEVO_ATOM_TYPE_BOOLEAN 3
|
||||
#define VEVO_ATOM_TYPE_STRING 4
|
||||
#define VEVO_ATOM_TYPE_VOIDPTR 65
|
||||
#define VEVO_ATOM_TYPE_PORTPTR 66
|
||||
|
||||
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +0,0 @@
|
||||
#include <stddef.h>
|
||||
#include "stdio.h"
|
||||
#include "../include/livido.h"
|
||||
|
||||
#include "../src/livido-utils.c"
|
||||
|
||||
#define num_palettes 5
|
||||
|
||||
int palettes[num_palettes] = { LIVIDO_PALETTE_RGB565,
|
||||
LIVIDO_PALETTE_RGB888,
|
||||
LIVIDO_PALETTE_RGBA8888,
|
||||
LIVIDO_PALETTE_YUV888,
|
||||
LIVIDO_PALETTE_YUVA8888
|
||||
} ;
|
||||
|
||||
|
||||
livido_init_f init_instance (livido_port_t *my_instance)
|
||||
{
|
||||
livido_set_string_value(my_instance, "PLUGIN_mydata", "My personal data, that the host won't touch!!!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
livido_init_f deinit_instance (livido_port_t* my_instance)
|
||||
{
|
||||
// we would do cleanup and freeing here, but we have nothing to do
|
||||
return 0;
|
||||
}
|
||||
|
||||
livido_process_f process_frame( livido_port_t *my_instance,
|
||||
double timecode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
livido_port_t *livido_setup(void)
|
||||
{
|
||||
livido_port_t *info;
|
||||
livido_port_t *filter1;
|
||||
livido_port_t *in_chann, *out_chann, *in_param, *out_param;
|
||||
info = livido_port_new(LIVIDO_PORT_TYPE_PLUGIN_INFO);
|
||||
livido_set_string_value(info, "maintainer", "Andraz Tori");
|
||||
livido_set_string_value(info, "version", "1.0");
|
||||
|
||||
filter1 = livido_port_new(LIVIDO_PORT_TYPE_FILTER_CLASS);
|
||||
livido_set_string_value (filter1, "name", "Fade plugin");
|
||||
livido_set_string_value (filter1, "description", "Fades the image with alpha channel when exists or to black when it does not");
|
||||
livido_set_int_value (filter1, "version", 1);
|
||||
livido_set_int_value (filter1, "api_version", 100);
|
||||
livido_set_string_value (filter1, "license", "Public domain");
|
||||
livido_set_int_value (filter1, "flags", LIVIDO_FILTER_CAN_DO_INPLACE | LIVIDO_FILTER_STATELESS);
|
||||
livido_set_voidptr_value(filter1, "process_func", &process_frame);
|
||||
livido_set_voidptr_value(filter1, "init_func", &init_instance);
|
||||
livido_set_voidptr_value(filter1, "deinit_func", &deinit_instance);
|
||||
|
||||
in_chann = livido_port_new(LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE);
|
||||
livido_set_string_value (in_chann, "name", "input");
|
||||
livido_set_int_value (in_chann, "flags", 0);
|
||||
livido_set_int_array (in_chann, "palette_list", num_palettes, palettes);
|
||||
livido_set_portptr_value(filter1, "in_channel_templates", in_chann);
|
||||
|
||||
out_chann = livido_port_new(LIVIDO_PORT_TYPE_CHANNEL_TEMPLATE);
|
||||
livido_set_string_value (out_chann, "name", "faded output");
|
||||
livido_set_int_value (out_chann, "flags", 0);
|
||||
livido_set_int_array (out_chann, "palette_list", num_palettes, palettes);
|
||||
livido_set_voidptr_value (out_chann, "same_as_size", in_chann);
|
||||
livido_set_voidptr_value (out_chann, "same_as_palette", in_chann);
|
||||
livido_set_portptr_value(filter1, "out_channel_templates", in_chann);
|
||||
|
||||
in_param = livido_port_new(LIVIDO_PORT_TYPE_PARAMETER_TEMPLATE);
|
||||
livido_set_string_value (in_param, "name", "Fade percentage");
|
||||
livido_set_int_value (in_param, "flags", 0);
|
||||
livido_set_string_value (in_param, "kind", "NUMBER");
|
||||
livido_set_string_value (in_param, "PLUGIN_kinda", "NUMBER");
|
||||
livido_set_double_value (in_param, "default", 0.5);
|
||||
livido_set_double_value (in_param, "min", 0.0);
|
||||
livido_set_double_value (in_param, "max", 0.0);
|
||||
livido_set_boolean_value (in_param, "transition", 1);
|
||||
|
||||
livido_set_portptr_value(filter1, "in_parameter_templates", in_param);
|
||||
|
||||
// Create an empty array of output templates
|
||||
livido_set_portptr_array(filter1, "out_parameter_templates", 0, 0);
|
||||
|
||||
|
||||
// Just to demonstrate - conformancy checking host will not complain about our own PLUGIN_ variable
|
||||
livido_set_string_value (filter1, "PLUGIN_my_stuff", "I can put here whatever i want");
|
||||
|
||||
livido_set_portptr_value(info, "filters", filter1);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
CC = gcc
|
||||
LINKER = ld
|
||||
CFLAGS = -I. -I../include -I ../ -Wall -g $(shell vevo-config --cflags)
|
||||
all:
|
||||
# vevo - veejay video objects
|
||||
#
|
||||
# plugins :
|
||||
# bathroom
|
||||
# opacity
|
||||
#
|
||||
# compile: make plugins
|
||||
# run:
|
||||
# export LD_LIBRARY_PATH=`pwd`
|
||||
# host <plugin.so>
|
||||
|
||||
plugins: fade_plugin.so
|
||||
|
||||
|
||||
fade.so: fade_plugin.o
|
||||
|
||||
clean:
|
||||
rm -rf *.o *.so
|
||||
|
||||
# generic make rules
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $< -ldl
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
%.so: %.o
|
||||
$(LINKER) -shared $^ -o $@
|
||||
# $(LINKER) -E -z now -shared $^ -o $@
|
||||
|
||||
|
||||
@@ -1,355 +0,0 @@
|
||||
/* LiViDO is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
LiViDO is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this source code; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
LiViDO is developed by:
|
||||
|
||||
Niels Elburg - http://veejay.sf.net
|
||||
|
||||
Gabriel "Salsaman" Finch - http://lives.sourceforge.net
|
||||
|
||||
Denis "Jaromil" Rojo - http://freej.dyne.org
|
||||
|
||||
Tom Schouten - http://zwizwa.fartit.com
|
||||
|
||||
Andraz Tori - http://cvs.cinelerra.org
|
||||
|
||||
reviewed with suggestions and contributions from:
|
||||
|
||||
Silvano "Kysucix" Galliani - http://freej.dyne.org
|
||||
|
||||
Kentaro Fukuchi - http://megaui.net/fukuchi
|
||||
|
||||
Jun Iio - http://www.malib.net
|
||||
|
||||
Carlo Prelz - http://www2.fluido.as:8080/
|
||||
|
||||
*/
|
||||
|
||||
/* (C) Gabriel "Salsaman" Finch, 2005 */
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
int livido_has_property (livido_port_t *port, const char *key) {
|
||||
if (livido_property_get(port,key,0,NULL)==LIVIDO_ERROR_NOSUCH_PROPERTY) return 0;
|
||||
return 1;
|
||||
}
|
||||
#include "livido.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// property setters
|
||||
|
||||
int livido_set_int_value (livido_port_t *port, const char *key, int value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_INT,1,&value);
|
||||
}
|
||||
|
||||
int livido_set_double_value (livido_port_t *port, const char *key, double value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_DOUBLE,1,&value);
|
||||
}
|
||||
|
||||
int livido_set_boolean_value (livido_port_t *port, const char *key, int value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_BOOLEAN,1,&value);
|
||||
}
|
||||
|
||||
int livido_set_string_value (livido_port_t *port, const char *key, char *value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_STRING,1,&value);
|
||||
}
|
||||
|
||||
int livido_set_portptr_value (livido_port_t *port, const char *key, void *value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_PORTPTR,1,&value);
|
||||
}
|
||||
|
||||
int livido_set_voidptr_value (livido_port_t *port, const char *key, void *value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_VOIDPTR,1,&value);
|
||||
}
|
||||
|
||||
|
||||
/////////// these functions need a size ////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// general property getter
|
||||
|
||||
inline int livido_get_value (livido_port_t *port, const char *key, void *value) {
|
||||
// returns a LIVIDO_ERROR
|
||||
return livido_property_get( port, key, 0, value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
int livido_get_int_value (livido_port_t *port, const char *key, int *error) {
|
||||
int retval=0;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_INT) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return retval;
|
||||
}
|
||||
else *error=livido_get_value (port,key,&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
double livido_get_double_value (livido_port_t *port, const char *key, int *error) {
|
||||
double retval=0.;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_DOUBLE) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return retval;
|
||||
}
|
||||
*error=livido_get_value (port,key,&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
int livido_get_boolean_value (livido_port_t *port, const char *key, int *error) {
|
||||
int retval=0;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_BOOLEAN) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return retval;
|
||||
}
|
||||
*error=livido_get_value (port,key,&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
char *livido_get_string_value (livido_port_t *port, const char *key, int *error) {
|
||||
char *retval=NULL;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_STRING) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
if ((retval=(char *)livido_malloc_f(livido_property_element_size(port,key,0)+1))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
if ((*error=livido_get_value (port,key,&retval))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void *livido_get_voidptr_value (livido_port_t *port, const char *key, int *error) {
|
||||
void *retval=NULL;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_VOIDPTR) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return retval;
|
||||
}
|
||||
*error=livido_get_value (port,key,&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
livido_port_t *livido_get_portptr_value (livido_port_t *port, const char *key, int *error) {
|
||||
livido_port_t *retval=NULL;
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_PORTPTR) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return retval;
|
||||
}
|
||||
*error=livido_get_value (port,key,&retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
int *livido_get_int_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
int *retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_INT) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(int *)livido_malloc_f(num_elems*sizeof(int)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
double *livido_get_double_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
double *retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_DOUBLE) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(double *)livido_malloc_f(num_elems*sizeof(double)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int *livido_get_boolean_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
int *retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_BOOLEAN) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(int *)livido_malloc_f(num_elems*sizeof(int)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
char **livido_get_string_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
char **retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_STRING) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(char **)livido_malloc_f(num_elems*sizeof(char *)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((retval[i]=(char *)livido_malloc_f(livido_property_element_size(port,key,i)+1))==NULL) {
|
||||
for (--i;i>=0;i--) livido_free_f(retval[i]);
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
for (--i;i>=0;i--) livido_free_f(retval[i]);
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void **livido_get_voidptr_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
void **retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_VOIDPTR) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(void **)livido_malloc_f(num_elems*sizeof(void *)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
livido_port_t **livido_get_portptr_array (livido_port_t *port, const char *key, int *error) {
|
||||
int i;
|
||||
int num_elems;
|
||||
livido_port_t **retval;
|
||||
|
||||
if (livido_has_property(port,key)&&livido_property_atom_type(port,key)!=LIVIDO_ATOM_TYPE_PORTPTR) {
|
||||
*error=LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((num_elems=livido_property_num_elements (port,key))==0) return NULL;
|
||||
|
||||
if ((retval=(livido_port_t **)livido_malloc_f(num_elems*sizeof(livido_port_t *)))==NULL) {
|
||||
*error=LIVIDO_ERROR_MEMORY_ALLOCATION;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i=0;i<num_elems;i++) {
|
||||
if ((*error=livido_property_get(port, key, i, &retval[i]))!=LIVIDO_NO_ERROR) {
|
||||
livido_free_f (retval);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
int livido_set_int_array (livido_port_t *port, const char *key, int num_elems, int *values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_INT,num_elems,values);
|
||||
}
|
||||
|
||||
int livido_set_double_array (livido_port_t *port, const char *key, int num_elems, double *values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_DOUBLE,num_elems,values);
|
||||
}
|
||||
|
||||
int livido_set_boolean_array (livido_port_t *port, const char *key, int num_elems, int *values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_BOOLEAN,num_elems,values);
|
||||
}
|
||||
|
||||
int livido_set_string_array (livido_port_t *port, const char *key, int num_elems, char **values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_STRING,num_elems,values);
|
||||
}
|
||||
|
||||
int livido_set_voidptr_array (livido_port_t *port, const char *key, int num_elems, void **values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_VOIDPTR,num_elems,values);
|
||||
}
|
||||
|
||||
int livido_set_portptr_array (livido_port_t *port, const char *key, int num_elems, livido_port_t **values) {
|
||||
return livido_property_set (port,key,LIVIDO_ATOM_TYPE_PORTPTR,num_elems,values);
|
||||
}
|
||||
|
||||
260
vevo-current/src/pool.c
Normal file
260
vevo-current/src/pool.c
Normal file
@@ -0,0 +1,260 @@
|
||||
/*
|
||||
Copyright (c) 2004-2005 N.Elburg <nelburg@looze.net>
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifdef VEVO_MEMPOOL
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <libvevo/lowlevel.h>
|
||||
#include <libvevo/pool.h>
|
||||
#define FREE_LISTS 5
|
||||
|
||||
typedef struct {
|
||||
int vevo_type;
|
||||
size_t size;
|
||||
void *ptr;
|
||||
void *next;
|
||||
} free_node_t;
|
||||
|
||||
typedef free_node_t free_list_t;
|
||||
typedef struct {
|
||||
size_t l[2];
|
||||
void *a4;
|
||||
void *p4;
|
||||
void *t;
|
||||
double *d;
|
||||
void *s;
|
||||
free_list_t **f;
|
||||
int idx[2];
|
||||
} pool_t;
|
||||
|
||||
static struct {
|
||||
int index;
|
||||
size_t size;
|
||||
} type_list[] = {
|
||||
{
|
||||
ATOM_INT, sizeof(int32_t)}
|
||||
, {
|
||||
ATOM_PTR, sizeof(void *)}, {
|
||||
ATOM_DBL, sizeof(double)}, {
|
||||
ATOM_ATOM, sizeof(atom_t)}
|
||||
,};
|
||||
|
||||
//clean up todo!
|
||||
static free_node_t *vevo_new_node(int vevo_type, void *area)
|
||||
{
|
||||
free_node_t *n = (free_node_t *) malloc(sizeof(free_node_t));
|
||||
n->size = type_list[vevo_type].size;
|
||||
n->ptr = area;
|
||||
n->next = NULL;
|
||||
return n;
|
||||
}
|
||||
|
||||
static void vevo_node_free(free_node_t * n)
|
||||
{
|
||||
if (n)
|
||||
free(n);
|
||||
n = NULL;
|
||||
}
|
||||
|
||||
static void append_node_to_freelist(pool_t * p, int vevo_type,
|
||||
size_t offset, void *base)
|
||||
{
|
||||
free_node_t *n = vevo_new_node(vevo_type, base);
|
||||
free_node_t *c = NULL;
|
||||
free_list_t *l = p->f[vevo_type];
|
||||
if (l == NULL)
|
||||
p->f[vevo_type] = n;
|
||||
else {
|
||||
while (l != NULL) {
|
||||
c = (free_node_t *) l->next;
|
||||
if (c == NULL) {
|
||||
l->next = (void *) n;
|
||||
break;
|
||||
}
|
||||
l = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *vevo_new_pool(void)
|
||||
{
|
||||
pool_t *p = (pool_t *) malloc(sizeof(pool_t));
|
||||
memset(p, 0, sizeof(pool_t));
|
||||
p->f = (free_list_t **) malloc(sizeof(free_list_t *) * FREE_LISTS);
|
||||
memset(p->f, 0, sizeof(free_list_t *) * FREE_LISTS);
|
||||
|
||||
p->l[0] = (VEVO_MEM_LIMIT / 4) * 3;
|
||||
p->l[1] = (VEVO_MEM_LIMIT / 4) * 1;
|
||||
|
||||
size_t chunk = (p->l[0] / 2) * sizeof(int32_t);
|
||||
size_t d_chunk = p->l[1] * sizeof(double);
|
||||
size_t t_chunk = VEVO_MEM_LIMIT * sizeof(atom_t);
|
||||
|
||||
p->a4 = (void *) malloc(p->l[0] * sizeof(int32_t)); // int and bool
|
||||
p->p4 = (void *) malloc(p->l[0] * sizeof(void *)); // port and ptr
|
||||
p->d = (double *) malloc(p->l[1] * sizeof(double)); // double
|
||||
p->t = (atom_t *) malloc(VEVO_MEM_LIMIT * sizeof(atom_t));
|
||||
|
||||
memset(p->a4, 0, p->l[0] * sizeof(int32_t));
|
||||
memset(p->p4, 0, p->l[0] * sizeof(void *));
|
||||
memset(p->d, 0, p->l[1] * sizeof(double));
|
||||
memset(p->t, 0, VEVO_MEM_LIMIT * sizeof(atom_t));
|
||||
|
||||
void *base = NULL;
|
||||
|
||||
int n = 0;
|
||||
/* initialize free lists for int and bool types */
|
||||
size_t it = 0;
|
||||
while (it < chunk) {
|
||||
base = ((int32_t *) p->a4 + it);
|
||||
append_node_to_freelist(p, ATOM_INT, chunk, base);
|
||||
it += type_list[ATOM_INT].size;
|
||||
n++;
|
||||
}
|
||||
|
||||
/* initalize ptr free lists */
|
||||
it = 0;
|
||||
while (it < chunk) {
|
||||
base = ((void **) p->p4 + (ATOM_PTR * chunk + it));
|
||||
append_node_to_freelist(p, ATOM_PTR, chunk, base);
|
||||
it += type_list[ATOM_PTR].size;
|
||||
n++;
|
||||
}
|
||||
|
||||
/* initialize double free lists */
|
||||
it = 0;
|
||||
while (it < d_chunk) {
|
||||
base = (void *) ((double *) p->d + it);
|
||||
append_node_to_freelist(p, ATOM_DBL, d_chunk, base);
|
||||
it += type_list[ATOM_DBL].size;
|
||||
n++;
|
||||
}
|
||||
/* fill to hold atom container */
|
||||
it = 0;
|
||||
while (it < t_chunk) {
|
||||
base = (void *) ((double *) p->t + it);
|
||||
append_node_to_freelist(p, ATOM_ATOM, t_chunk, base);
|
||||
it += type_list[ATOM_ATOM].size;
|
||||
}
|
||||
|
||||
p->idx[0] = n;
|
||||
p->idx[1] = 0;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p->idx[0] != 0);
|
||||
#endif
|
||||
|
||||
return (void *) p;
|
||||
}
|
||||
|
||||
void vevo_free_pool(void *v)
|
||||
{
|
||||
int n = 0;
|
||||
pool_t *p = (pool_t *) v;
|
||||
if (p) {
|
||||
if (p->a4)
|
||||
free(p->a4);
|
||||
if (p->p4)
|
||||
free(p->p4);
|
||||
if (p->d)
|
||||
free(p->d);
|
||||
if (p->t)
|
||||
free(p->t);
|
||||
for (n = 0; n < FREE_LISTS; n++) {
|
||||
free_node_t *node = NULL;
|
||||
while (p->f[n] != NULL) {
|
||||
node = (free_node_t *) p->f[n]->next;
|
||||
vevo_node_free(p->f[n]);
|
||||
p->f[n] = node;
|
||||
}
|
||||
}
|
||||
free(p->f);
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *vevo_malloc(void *v, int vevo_type)
|
||||
{
|
||||
pool_t *p = (pool_t *) v;
|
||||
free_node_t *l = p->f[vevo_type];
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(l != NULL);
|
||||
#endif
|
||||
|
||||
while (l != NULL) {
|
||||
if (l->size == 0)
|
||||
l = l->next;
|
||||
else { /* found memory */
|
||||
void *res = l->ptr;
|
||||
free_node_t *next = l->next;
|
||||
l->size = 0;
|
||||
l->vevo_type = vevo_type;
|
||||
l = next;
|
||||
p->idx[1]++;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p->idx[1] < p->idx[0]);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
}
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(0);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int vevo_pool_verify(void *v)
|
||||
{
|
||||
pool_t *p = (pool_t *) v;
|
||||
return (p->idx[0] > p->idx[1] ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
void vevo_free(void *v, void *ptr, int vevo_type)
|
||||
{
|
||||
pool_t *p = (pool_t *) v;
|
||||
free_node_t *l = NULL;
|
||||
l = p->f[vevo_type];
|
||||
while (l != NULL) {
|
||||
if (l->ptr == ptr) {
|
||||
l->size = type_list[vevo_type].size;
|
||||
p->idx[1]--;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p->idx[1] >= 0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
l = l->next;
|
||||
}
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(0);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -27,32 +27,23 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <include/lowlevel.h>
|
||||
#include <include/vevo.h>
|
||||
#include <include/livido.h>
|
||||
#include <include/hash.h>
|
||||
|
||||
/**
|
||||
libVeVo - Veejay's Video Objects Library
|
||||
-----------------------------------------
|
||||
|
||||
This (shared) library attempts to provide a leightweight and efficient
|
||||
framework for handling Livido plugins.
|
||||
|
||||
*/
|
||||
#ifdef VEVO_MEMPOOL
|
||||
#include <include/pool.h>
|
||||
#endif
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
#include <assert.h>
|
||||
#endif
|
||||
|
||||
/* Mediation layer structures, provided by this host */
|
||||
typedef struct {
|
||||
void *value;
|
||||
size_t size;
|
||||
} atom_t;
|
||||
|
||||
/* The storage container, this holds the atoms of a property */
|
||||
typedef struct {
|
||||
int atom_type;
|
||||
union {
|
||||
@@ -63,19 +54,95 @@ typedef struct {
|
||||
int flags;
|
||||
} livido_storage_t;
|
||||
|
||||
/* For fast indexing of livido keys, define the port index: */
|
||||
/* For livido ports use a linked list , especially
|
||||
when a port does not hold a large number of properties
|
||||
a linked list is usually faster.
|
||||
Non livido ports are initialized with a hash, which
|
||||
is efficient for a large number of properties */
|
||||
typedef struct {
|
||||
livido_storage_t *st;
|
||||
int key;
|
||||
void *next;
|
||||
} livido_property_t;
|
||||
|
||||
/* For fast indexing of livido keys, define the port index
|
||||
The function livido_property_set adds a key to the port index
|
||||
if the property does not exist yet.
|
||||
*/
|
||||
typedef struct {
|
||||
const char *key;
|
||||
int hash_code;
|
||||
int hash_code; /* vevo uses a integer representation of key, eliminates strcmp */
|
||||
void *next;
|
||||
} port_index_t;
|
||||
|
||||
/* Now, define our port structure */
|
||||
typedef struct {
|
||||
hash_t *table;
|
||||
port_index_t *index;
|
||||
} vevo_port_t;
|
||||
hash_t *table; /* hashtable for custom ports */
|
||||
livido_property_t *list; /* linked list for livido ports */
|
||||
port_index_t *index; /* key index */
|
||||
void *pool; /* memory pool (compile option) */
|
||||
int atom_types[70]; /* atom types to vevo types */
|
||||
} __vevo_port_t;
|
||||
|
||||
|
||||
/* Functions for creating new 'properties' */
|
||||
static livido_property_t *prop_node_new(int hash_key,
|
||||
livido_storage_t * stor)
|
||||
{
|
||||
livido_property_t *p =
|
||||
(livido_property_t *) malloc(sizeof(livido_property_t));
|
||||
p->st = stor;
|
||||
p->key = hash_key;
|
||||
p->next = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
static void prop_node_free(livido_property_t * p)
|
||||
{
|
||||
if (p) {
|
||||
free(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static livido_property_t *prop_node_append(livido_port_t * p, int key,
|
||||
livido_storage_t * t)
|
||||
{
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
livido_property_t *node = prop_node_new(key, t);
|
||||
livido_property_t *next;
|
||||
livido_property_t *list = port->list;
|
||||
if (list == NULL)
|
||||
port->list = node;
|
||||
else {
|
||||
while (list != NULL) {
|
||||
next = list->next;
|
||||
if (next == NULL) {
|
||||
list->next = node;
|
||||
return node;
|
||||
}
|
||||
list = next;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
static livido_property_t *prop_node_get(livido_port_t * p, int key)
|
||||
{
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert( port != NULL );
|
||||
#endif
|
||||
livido_property_t *l = port->list;
|
||||
while (l != NULL) {
|
||||
if (key == l->key)
|
||||
return l;
|
||||
l = l->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Functions for new key items */
|
||||
static inline port_index_t *port_node_new(const char *key, int hash_key)
|
||||
{
|
||||
port_index_t *i = (port_index_t *) malloc(sizeof(port_index_t));
|
||||
@@ -101,6 +168,7 @@ static inline void port_node_free(port_index_t * node)
|
||||
}
|
||||
node = NULL;
|
||||
}
|
||||
|
||||
static inline void port_node_append(livido_port_t * p, const char *key,
|
||||
int hash_key)
|
||||
{
|
||||
@@ -109,7 +177,7 @@ static inline void port_node_append(livido_port_t * p, const char *key,
|
||||
assert(key != NULL);
|
||||
assert(hash_key != 0);
|
||||
#endif
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
port_index_t *node = port_node_new(key, hash_key);
|
||||
port_index_t *next;
|
||||
port_index_t *list = port->index;
|
||||
@@ -132,7 +200,7 @@ static inline void port_node_append(livido_port_t * p, const char *key,
|
||||
|
||||
#define atom_store__(value) {\
|
||||
for (i = 0; i < d->num_elements; i++)\
|
||||
d->elements.array[i] = livido_put_atom( &value[i], v ); }
|
||||
d->elements.array[i] = livido_put_atom(port, &value[i], v ); }
|
||||
|
||||
#define array_load__(value) {\
|
||||
for( i = 0; i < t->num_elements ; i ++ )\
|
||||
@@ -154,25 +222,36 @@ static inline int hash_key_code(const char *key)
|
||||
|
||||
static int livido_property_finalize(livido_port_t * p, const char *key)
|
||||
{
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
hnode_t *node = NULL;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
int hash_key = hash_key_code(key);
|
||||
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
stor->flags |= LIVIDO_PROPERTY_READONLY;
|
||||
hnode_t *new_node = hnode_create((void *) stor);
|
||||
hnode_put(new_node, (void *) hash_key);
|
||||
hnode_destroy(new_node);
|
||||
}
|
||||
if (!port->table) {
|
||||
livido_property_t *node = NULL;
|
||||
if ((node = prop_node_get(port, hash_key)) != NULL) {
|
||||
node->st->flags |= VEVO_PROPERTY_READONLY;
|
||||
return VEVO_NO_ERROR;
|
||||
}
|
||||
} else {
|
||||
hnode_t *node = NULL;
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
stor->flags |= VEVO_PROPERTY_READONLY;
|
||||
hnode_t *new_node = hnode_create((void *) stor);
|
||||
hnode_put(new_node, (void *) hash_key);
|
||||
hnode_destroy(new_node);
|
||||
return VEVO_NO_ERROR;
|
||||
}
|
||||
|
||||
return LIVIDO_NO_ERROR;
|
||||
}
|
||||
//fixme: error is wrong
|
||||
return VEVO_NO_ERROR;
|
||||
}
|
||||
|
||||
static int atom_get_value(livido_storage_t * t, int idx, void *dst)
|
||||
{
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(t != NULL);
|
||||
assert(dst != NULL);
|
||||
#endif
|
||||
atom_t *atom = NULL;
|
||||
|
||||
@@ -183,12 +262,12 @@ static int atom_get_value(livido_storage_t * t, int idx, void *dst)
|
||||
atom = t->elements.array[idx];
|
||||
|
||||
if (!atom)
|
||||
return LIVIDO_ERROR_NOSUCH_ELEMENT;
|
||||
return VEVO_ERROR_NOSUCH_ELEMENT;
|
||||
|
||||
if (atom->size <= 0)
|
||||
return LIVIDO_NO_ERROR;
|
||||
return VEVO_NO_ERROR;
|
||||
|
||||
if (t->atom_type != LIVIDO_ATOM_TYPE_STRING) {
|
||||
if (t->atom_type != VEVO_ATOM_TYPE_STRING) {
|
||||
memcpy(dst, atom->value, atom->size);
|
||||
} else {
|
||||
char **ptr = (char **) dst;
|
||||
@@ -197,24 +276,24 @@ static int atom_get_value(livido_storage_t * t, int idx, void *dst)
|
||||
p[atom->size - 1] = '\0';
|
||||
}
|
||||
|
||||
return LIVIDO_NO_ERROR;
|
||||
return VEVO_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
static size_t livido_atom_size(int atom_type)
|
||||
{
|
||||
switch (atom_type) {
|
||||
case LIVIDO_ATOM_TYPE_DOUBLE:
|
||||
case VEVO_ATOM_TYPE_DOUBLE:
|
||||
return sizeof(double);
|
||||
case LIVIDO_ATOM_TYPE_INT:
|
||||
case VEVO_ATOM_TYPE_INT:
|
||||
return sizeof(int32_t);
|
||||
case LIVIDO_ATOM_TYPE_VOIDPTR:
|
||||
case VEVO_ATOM_TYPE_VOIDPTR:
|
||||
return sizeof(void *);
|
||||
case LIVIDO_ATOM_TYPE_STRING:
|
||||
case VEVO_ATOM_TYPE_STRING:
|
||||
return 0;
|
||||
case LIVIDO_ATOM_TYPE_PORTPTR:
|
||||
case VEVO_ATOM_TYPE_PORTPTR:
|
||||
return sizeof(livido_port_t *);
|
||||
case LIVIDO_ATOM_TYPE_BOOLEAN:
|
||||
case VEVO_ATOM_TYPE_BOOLEAN:
|
||||
return sizeof(int32_t);
|
||||
default:
|
||||
#ifdef STRICT_CHECKING
|
||||
@@ -226,41 +305,66 @@ static size_t livido_atom_size(int atom_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static atom_t *livido_new_atom(int atom_type, size_t atom_size)
|
||||
static atom_t *livido_new_atom(__vevo_port_t * port, int atom_type,
|
||||
size_t atom_size)
|
||||
{
|
||||
#ifdef VEVO_MEMPOOL
|
||||
atom_t *atom = (atom_t *) vevo_malloc(port->pool, ATOM_ATOM);
|
||||
#else
|
||||
atom_t *atom = (atom_t *) malloc(sizeof(atom_t));
|
||||
#endif
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(atom != NULL);
|
||||
#endif
|
||||
atom->size = atom_size;
|
||||
#ifndef VEVO_MEMPOOL
|
||||
atom->value = (atom_size > 0 ? (void *) malloc(atom_size) : NULL);
|
||||
#else
|
||||
atom->type = port->atom_types[atom_type];
|
||||
if (atom->type >= 0) {
|
||||
atom->value =
|
||||
(atom_size >
|
||||
0 ? (void *) vevo_malloc(port->pool, atom->type) : NULL);
|
||||
} else
|
||||
atom->value = (atom_size > 0 ? (void *) malloc(atom_size) : NULL);
|
||||
#endif
|
||||
#ifdef STRICT_CHECING
|
||||
assert(atom->value != NULL);
|
||||
#endif
|
||||
return atom;
|
||||
}
|
||||
|
||||
static void livido_free_atom(atom_t * atom)
|
||||
static void livido_free_atom(void *pool, atom_t * atom)
|
||||
{
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(atom != NULL);
|
||||
#endif
|
||||
|
||||
if (atom) {
|
||||
#ifndef VEVO_MEMPOOL
|
||||
free(atom->value);
|
||||
free(atom);
|
||||
#else
|
||||
if (atom->type >= 0)
|
||||
vevo_free(pool, atom->value, atom->type);
|
||||
else
|
||||
free(atom->value);
|
||||
vevo_free(pool, atom, ATOM_ATOM);
|
||||
#endif
|
||||
}
|
||||
atom = NULL;
|
||||
}
|
||||
|
||||
static atom_t *livido_put_atom(void *dst, int atom_type)
|
||||
static atom_t *livido_put_atom(__vevo_port_t * port, void *dst,
|
||||
int atom_type)
|
||||
{
|
||||
atom_t *atom = NULL;
|
||||
size_t atom_size = livido_atom_size(atom_type);
|
||||
if (atom_type == LIVIDO_ATOM_TYPE_STRING) {
|
||||
|
||||
if (atom_type == VEVO_ATOM_TYPE_STRING) {
|
||||
char **s = (char **) dst;
|
||||
atom_size = strlen(*s) + 1;
|
||||
atom = livido_new_atom(atom_type, atom_size);
|
||||
atom = livido_new_atom(port, atom_type, atom_size);
|
||||
if (atom_size > 0)
|
||||
memcpy(atom->value, *s, (atom_size - 1));
|
||||
} else {
|
||||
@@ -269,19 +373,23 @@ static atom_t *livido_put_atom(void *dst, int atom_type)
|
||||
assert(atom_size > 0);
|
||||
assert(dst != NULL);
|
||||
#endif
|
||||
atom = livido_new_atom(atom_type, atom_size);
|
||||
atom = livido_new_atom(port, atom_type, atom_size);
|
||||
|
||||
#ifdef STRICT_CHECING
|
||||
assert(atom != NULL);
|
||||
assert(atom->value != NULL);
|
||||
#else
|
||||
if (!atom)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
memcpy(atom->value, dst, atom_size);
|
||||
}
|
||||
return atom;
|
||||
}
|
||||
|
||||
static void
|
||||
storage_put_atom_value(void *src, int n, livido_storage_t * d, int v)
|
||||
storage_put_atom_value(__vevo_port_t * port, void *src, int n,
|
||||
livido_storage_t * d, int v)
|
||||
{
|
||||
int i;
|
||||
#ifdef STRICT_CHECKING
|
||||
@@ -292,11 +400,11 @@ storage_put_atom_value(void *src, int n, livido_storage_t * d, int v)
|
||||
if (d->num_elements >= 0) {
|
||||
if (d->num_elements >= 0 && d->num_elements <= 1) {
|
||||
if (d->elements.atom)
|
||||
livido_free_atom(d->elements.atom);
|
||||
livido_free_atom(port->pool, d->elements.atom);
|
||||
} else if (d->num_elements > 1) {
|
||||
if (d->elements.array) {
|
||||
for (i = 0; i < d->num_elements; i++)
|
||||
livido_free_atom(d->elements.array[i]);
|
||||
livido_free_atom(port->pool, d->elements.array[i]);
|
||||
free(d->elements.array);
|
||||
}
|
||||
}
|
||||
@@ -307,19 +415,19 @@ storage_put_atom_value(void *src, int n, livido_storage_t * d, int v)
|
||||
|
||||
switch (n) {
|
||||
case 0:
|
||||
d->elements.atom = livido_new_atom(v, livido_atom_size(v));
|
||||
d->elements.atom = livido_new_atom(port, v, livido_atom_size(v));
|
||||
break;
|
||||
case 1:
|
||||
d->elements.atom = livido_put_atom(src, v);
|
||||
d->elements.atom = livido_put_atom(port, src, v);
|
||||
break;
|
||||
default:
|
||||
d->elements.array = (atom_t **) malloc(sizeof(atom_t *) * n);
|
||||
if (d->atom_type == LIVIDO_ATOM_TYPE_DOUBLE) {
|
||||
if (d->atom_type == VEVO_ATOM_TYPE_DOUBLE) {
|
||||
double *value = (double *) src;
|
||||
atom_store__(value);
|
||||
} else {
|
||||
if (d->atom_type == LIVIDO_ATOM_TYPE_INT
|
||||
|| d->atom_type == LIVIDO_ATOM_TYPE_BOOLEAN) {
|
||||
if (d->atom_type == VEVO_ATOM_TYPE_INT
|
||||
|| d->atom_type == VEVO_ATOM_TYPE_BOOLEAN) {
|
||||
int32_t *value = (int *) src;
|
||||
atom_store__(value);
|
||||
} else {
|
||||
@@ -335,23 +443,26 @@ static inline livido_storage_t *livido_new_storage(int num_elements)
|
||||
{
|
||||
livido_storage_t *d =
|
||||
(livido_storage_t *) malloc(sizeof(livido_storage_t));
|
||||
#ifdef HAVE_STRICT
|
||||
assert(d != NULL);
|
||||
#endif
|
||||
d->elements.atom = NULL;
|
||||
d->num_elements = num_elements;
|
||||
d->flags = 0;
|
||||
return d;
|
||||
}
|
||||
|
||||
static inline void livido_free_storage(livido_storage_t * t)
|
||||
static inline void livido_free_storage(void *pool, livido_storage_t * t)
|
||||
{
|
||||
if (t) {
|
||||
if (t->num_elements > 1) {
|
||||
int i;
|
||||
for (i = 0; i < t->num_elements; i++)
|
||||
livido_free_atom(t->elements.array[i]);
|
||||
livido_free_atom(pool, t->elements.array[i]);
|
||||
free(t->elements.array);
|
||||
}
|
||||
if (t->num_elements <= 1)
|
||||
livido_free_atom(t->elements.atom);
|
||||
livido_free_atom(pool, t->elements.atom);
|
||||
free(t);
|
||||
}
|
||||
t = NULL;
|
||||
@@ -367,21 +478,34 @@ static inline int key_compare(const void *key1, const void *key2)
|
||||
return ((int) key1 == (int) key2 ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Livido API implementation, public functions follow below
|
||||
*/
|
||||
|
||||
int livido_property_num_elements(livido_port_t * p, const char *key)
|
||||
{
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p != NULL);
|
||||
assert(key != NULL);
|
||||
#endif
|
||||
if(!p) return -1;
|
||||
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
hnode_t *node = NULL;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
int hash_key = hash_key_code(key);
|
||||
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
if (stor)
|
||||
return stor->num_elements;
|
||||
if (!port->table) {
|
||||
livido_property_t *node;
|
||||
if ((node = prop_node_get(port, hash_key)) != NULL)
|
||||
return node->st->num_elements;
|
||||
} else {
|
||||
hnode_t *node = NULL;
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
if (stor)
|
||||
return stor->num_elements;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -392,14 +516,28 @@ int livido_property_atom_type(livido_port_t * p, const char *key)
|
||||
assert(p != NULL);
|
||||
assert(key != NULL);
|
||||
#endif
|
||||
|
||||
vevo_port_t *port = (vevo_port_t *) port;
|
||||
hnode_t *node = NULL;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port != NULL);
|
||||
#endif
|
||||
int hash_key = hash_key_code(key);
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
if (stor)
|
||||
return stor->atom_type;
|
||||
|
||||
if (!port->table) {
|
||||
livido_property_t *node;
|
||||
if ((node = prop_node_get(port, hash_key)) != NULL)
|
||||
return node->st->atom_type;
|
||||
} else {
|
||||
hnode_t *node = NULL;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port->table != NULL);
|
||||
assert(hash_verify(port->table) != 0);
|
||||
#endif
|
||||
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
if (stor)
|
||||
return stor->atom_type;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -411,32 +549,41 @@ livido_property_element_size(livido_port_t * p, const char *key,
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p != NULL);
|
||||
assert(key != NULL);
|
||||
assert(idx >= 0);
|
||||
#endif
|
||||
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
hnode_t *node = NULL;
|
||||
if(!p) return -1;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
int hash_key = hash_key_code(key);
|
||||
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
|
||||
if (!port->table) {
|
||||
livido_property_t *node;
|
||||
if ((node = prop_node_get(port, hash_key)) != NULL) {
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(stor != NULL);
|
||||
if (idx > 0)
|
||||
assert(idx < node->st->num_elements);
|
||||
#endif
|
||||
//todo: sum all element sizes for index of -1
|
||||
if (stor->num_elements == 1) {
|
||||
return stor->elements.atom->size;
|
||||
} else if (stor->num_elements > 1) {
|
||||
|
||||
if (node->st->num_elements == 1)
|
||||
return node->st->elements.atom->size;
|
||||
else if (node->st->num_elements > 1)
|
||||
return node->st->elements.array[idx]->size;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
hnode_t *node = NULL;
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *stor = (livido_storage_t *) hnode_get(node);
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(idx >= 0);
|
||||
assert(idx < stor->num_elements);
|
||||
assert(stor->elements.array[idx] != NULL);
|
||||
#endif
|
||||
return stor->elements.array[idx]->size;
|
||||
} else {
|
||||
if (stor->num_elements == 0)
|
||||
return 0;
|
||||
//todo: sum all element sizes for index of -1
|
||||
if (stor->num_elements == 1) {
|
||||
return stor->elements.atom->size;
|
||||
} else if (stor->num_elements > 1) {
|
||||
return stor->elements.array[idx]->size;
|
||||
} else {
|
||||
if (stor->num_elements == 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,62 +592,84 @@ livido_property_element_size(livido_port_t * p, const char *key,
|
||||
|
||||
livido_port_t *livido_port_new(int port_type)
|
||||
{
|
||||
vevo_port_t *port = (vevo_port_t *) malloc(sizeof(vevo_port_t));
|
||||
__vevo_port_t *port = (__vevo_port_t *) malloc(sizeof(__vevo_port_t));
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port != NULL);
|
||||
#endif
|
||||
port->index = NULL;
|
||||
port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash);
|
||||
port->list = NULL;
|
||||
port->table = NULL;
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port->table != NULL);
|
||||
#endif
|
||||
|
||||
livido_property_set(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type);
|
||||
#ifdef STRICT_CHECKING
|
||||
int hash_key = hash_key_code("type");
|
||||
assert(property_exists(port, hash_key) != NULL);
|
||||
/* If the port type is a Livido port this or that */
|
||||
if (port_type >= 1 && port_type <= 10)
|
||||
port->list = NULL;
|
||||
else
|
||||
port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash);
|
||||
|
||||
#ifdef VEVO_MEMPOOL
|
||||
port->pool = vevo_new_pool();
|
||||
|
||||
port->atom_types[VEVO_ATOM_TYPE_INT] = ATOM_INT;
|
||||
port->atom_types[VEVO_ATOM_TYPE_DOUBLE] = ATOM_DBL;
|
||||
port->atom_types[VEVO_ATOM_TYPE_BOOLEAN] = ATOM_INT;
|
||||
port->atom_types[VEVO_ATOM_TYPE_VOIDPTR] = ATOM_PTR;
|
||||
port->atom_types[VEVO_ATOM_TYPE_PORTPTR] = ATOM_PTR;
|
||||
port->atom_types[VEVO_ATOM_TYPE_STRING] = -1;
|
||||
#else
|
||||
port->pool = NULL;
|
||||
#endif
|
||||
|
||||
if(port_type <= 1024)
|
||||
{
|
||||
livido_property_set(port, "type", VEVO_ATOM_TYPE_INT, 1, &port_type);
|
||||
livido_property_finalize(port, "type");
|
||||
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(livido_property_set
|
||||
(port, "type", LIVIDO_ATOM_TYPE_INT, 1, &port_type)
|
||||
!= LIVIDO_PROPERTY_READONLY);
|
||||
(port, "type", VEVO_ATOM_TYPE_INT, 1, &port_type)
|
||||
!= VEVO_PROPERTY_READONLY);
|
||||
#endif
|
||||
|
||||
}
|
||||
return (livido_port_t *) port;
|
||||
}
|
||||
|
||||
void livido_port_free(livido_port_t * p)
|
||||
{
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
|
||||
if (port) {
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port->table != NULL);
|
||||
#endif
|
||||
if (!hash_isempty((hash_t *) port->table)) {
|
||||
hscan_t scan;
|
||||
hash_scan_begin(&scan, (hash_t *) port->table);
|
||||
hnode_t *node;
|
||||
if (port->table) {
|
||||
if (!hash_isempty((hash_t *) port->table)) {
|
||||
hscan_t scan;
|
||||
hash_scan_begin(&scan, (hash_t *) port->table);
|
||||
hnode_t *node;
|
||||
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
livido_storage_t *stor;
|
||||
stor = hnode_get(node);
|
||||
while ((node = hash_scan_next(&scan)) != NULL) {
|
||||
livido_storage_t *stor;
|
||||
stor = hnode_get(node);
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(stor != NULL);
|
||||
assert(node != NULL);
|
||||
assert((const char *) hnode_getkey(node) != NULL);
|
||||
assert(stor != NULL);
|
||||
assert(node != NULL);
|
||||
assert((const char *) hnode_getkey(node) != NULL);
|
||||
#endif
|
||||
livido_free_storage(stor);
|
||||
livido_free_storage(port->pool, stor);
|
||||
}
|
||||
hash_free_nodes((hash_t *) port->table);
|
||||
hash_destroy((hash_t *) port->table);
|
||||
}
|
||||
} else {
|
||||
livido_property_t *l = port->list;
|
||||
livido_property_t *n;
|
||||
while (l != NULL) {
|
||||
n = l->next;
|
||||
livido_free_storage(port->pool, l->st);
|
||||
prop_node_free(l);
|
||||
l = n;
|
||||
}
|
||||
hash_free_nodes((hash_t *) port->table);
|
||||
hash_destroy((hash_t *) port->table);
|
||||
}
|
||||
|
||||
|
||||
if (port->index) {
|
||||
port_index_t *l = port->index;
|
||||
port_index_t *n = NULL;
|
||||
@@ -510,10 +679,12 @@ void livido_port_free(livido_port_t * p)
|
||||
l = n;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VEVO_MEMPOOL
|
||||
vevo_free_pool(port->pool);
|
||||
#endif
|
||||
free(port);
|
||||
}
|
||||
port = NULL;
|
||||
p = port = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -524,45 +695,80 @@ livido_property_set(livido_port_t * p,
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p != NULL);
|
||||
#endif
|
||||
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
hnode_t *old_node = NULL;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
int hash_key = hash_key_code(key);
|
||||
if ((old_node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *oldstor =
|
||||
(livido_storage_t *) hnode_get(old_node);
|
||||
if (oldstor->atom_type != atom_type)
|
||||
return LIVIDO_ERROR_WRONG_ATOM_TYPE;
|
||||
|
||||
if (oldstor->flags & LIVIDO_PROPERTY_READONLY)
|
||||
return LIVIDO_ERROR_PROPERTY_READONLY;
|
||||
|
||||
livido_free_storage(oldstor);
|
||||
|
||||
hash_delete((hash_t *) port->table, old_node);
|
||||
hnode_destroy(old_node);
|
||||
int new = 1;
|
||||
void *node = NULL;
|
||||
#ifdef STRICT_CHECKING
|
||||
assert( port != NULL );
|
||||
#endif
|
||||
if (!port->table) {
|
||||
livido_property_t *pnode = NULL;
|
||||
if ((pnode = prop_node_get(port, hash_key)) != NULL) {
|
||||
if (pnode->st->atom_type != atom_type)
|
||||
return VEVO_ERROR_WRONG_ATOM_TYPE;
|
||||
if (pnode->st->flags & VEVO_PROPERTY_READONLY)
|
||||
return VEVO_ERROR_PROPERTY_READONLY;
|
||||
livido_free_storage(port->pool, pnode->st);
|
||||
new = 0;
|
||||
node = (void *) pnode;
|
||||
}
|
||||
} else {
|
||||
port_node_append(port, key, hash_key);
|
||||
hnode_t *old_node = NULL;
|
||||
if ((old_node = property_exists(port, hash_key)) != NULL) {
|
||||
livido_storage_t *oldstor =
|
||||
(livido_storage_t *) hnode_get(old_node);
|
||||
if (oldstor->atom_type != atom_type)
|
||||
return VEVO_ERROR_WRONG_ATOM_TYPE;
|
||||
|
||||
if (oldstor->flags & VEVO_PROPERTY_READONLY)
|
||||
return VEVO_ERROR_PROPERTY_READONLY;
|
||||
|
||||
livido_free_storage(port->pool, oldstor);
|
||||
|
||||
hash_delete((hash_t *) port->table, old_node);
|
||||
hnode_destroy(old_node);
|
||||
new = 0;
|
||||
}
|
||||
}
|
||||
livido_storage_t *stor = livido_new_storage(num_elements);
|
||||
storage_put_atom_value(port, src, num_elements, stor, atom_type);
|
||||
|
||||
if (new) {
|
||||
#ifdef VEVO_MEMPOOL
|
||||
if (!vevo_pool_verify(port->pool))
|
||||
return VEVO_ERROR_MEMORY_ALLOCATION;
|
||||
#endif
|
||||
port_node_append(port, key, hash_key);
|
||||
if (!port->table)
|
||||
node = (void *) prop_node_append(port, hash_key, stor);
|
||||
}
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(stor != NULL);
|
||||
#endif
|
||||
|
||||
storage_put_atom_value(src, num_elements, stor, atom_type);
|
||||
|
||||
hnode_t *node = hnode_create(stor);
|
||||
if (!port->table) {
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(node != NULL);
|
||||
#endif
|
||||
if (!new) {
|
||||
livido_property_t *current = (livido_property_t *) node;
|
||||
current->st = stor;
|
||||
}
|
||||
} else {
|
||||
hnode_t *node2 = hnode_create(stor);
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(node != NULL);
|
||||
assert(!hash_isfull((hash_t *) port->table));
|
||||
assert(!property_exists(port, hash_key));
|
||||
assert(node2 != NULL);
|
||||
assert(!hash_isfull((hash_t *) port->table));
|
||||
assert(!property_exists(port, hash_key));
|
||||
#endif
|
||||
|
||||
hash_insert((hash_t *) port->table, node, (const void *) hash_key);
|
||||
hash_insert((hash_t *) port->table, node2,
|
||||
(const void *) hash_key);
|
||||
}
|
||||
|
||||
return LIVIDO_NO_ERROR;
|
||||
return VEVO_NO_ERROR;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -571,46 +777,56 @@ livido_property_get(livido_port_t * p, const char *key, int idx, void *dst)
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(p != NULL);
|
||||
#endif
|
||||
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
if(!p) return VEVO_ERROR_NOSUCH_PROPERTY;
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port->table != NULL);
|
||||
assert(key != NULL);
|
||||
#endif
|
||||
|
||||
hnode_t *node = NULL;
|
||||
int hash_key = hash_key_code(key);
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
if (dst == NULL)
|
||||
return LIVIDO_NO_ERROR;
|
||||
else {
|
||||
livido_storage_t *stor = hnode_get(node);
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(stor != NULL);
|
||||
#endif
|
||||
return atom_get_value(stor, idx, dst);
|
||||
if (!port->table) {
|
||||
livido_property_t *node = NULL;
|
||||
if ((node = prop_node_get(port, hash_key)) != NULL) {
|
||||
if (dst == NULL)
|
||||
return VEVO_NO_ERROR;
|
||||
else
|
||||
return atom_get_value(node->st, idx, dst);
|
||||
}
|
||||
} else {
|
||||
hnode_t *node = NULL;
|
||||
if ((node = property_exists(port, hash_key)) != NULL) {
|
||||
if (dst == NULL)
|
||||
return VEVO_NO_ERROR;
|
||||
else
|
||||
return atom_get_value((livido_storage_t *) hnode_get(node),
|
||||
idx, dst);
|
||||
}
|
||||
}
|
||||
|
||||
return LIVIDO_ERROR_NOSUCH_PROPERTY;
|
||||
return VEVO_ERROR_NOSUCH_PROPERTY;
|
||||
}
|
||||
|
||||
char **livido_list_properties(livido_port_t * p)
|
||||
{
|
||||
vevo_port_t *port = (vevo_port_t *) p;
|
||||
__vevo_port_t *port = (__vevo_port_t *) p;
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
assert(port != NULL);
|
||||
assert(port->table != NULL);
|
||||
assert(hash_isempty((hash_t *) port->table) == 0);
|
||||
#endif
|
||||
|
||||
if(!p) return NULL;
|
||||
char **list = NULL;
|
||||
|
||||
#ifdef STRICT_CHECKING
|
||||
int nn = hash_count((hash_t *) port->table);
|
||||
int nn = 1;
|
||||
if (port->table)
|
||||
nn += hash_count((hash_t *) port->table);
|
||||
else {
|
||||
livido_property_t *c = port->list;
|
||||
while (c != NULL) {
|
||||
c = c->next;
|
||||
nn++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int n = 1; // null terminated list of keys
|
||||
|
||||
Reference in New Issue
Block a user