aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
committerTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
commit7591a024f184bd385d35583d19d86c1d5f2531ba (patch)
tree77aa0c44ccb700eb9a2b16e1b246e3c8026c40ed
parent91dd6b68f0f209ad015a303095bb1df018dca71e (diff)
pdp current darcs merge
svn path=/trunk/externals/pdp/; revision=5816
-rw-r--r--CHANGES.LOG2
-rw-r--r--Makefile18
-rw-r--r--Makefile.config22
-rw-r--r--Makefile.config.in6
-rw-r--r--README10
-rw-r--r--TODO51
-rwxr-xr-xbuildall7
-rw-r--r--configure.ac15
-rw-r--r--doc/misc/devdoc.html3
-rw-r--r--doc/misc/overview.html26
-rw-r--r--doc/reference.txt4
-rw-r--r--include/pdp_comm.h25
-rw-r--r--include/pdp_config.h4
-rw-r--r--include/pdp_list.h2
-rw-r--r--include/pdp_mem.h1
-rw-r--r--include/pdp_net.h2
-rw-r--r--include/pdp_packet.h5
-rw-r--r--include/pdp_post.h18
-rw-r--r--include/pdp_queue.h2
-rw-r--r--include/pdp_types.h15
-rw-r--r--modules/generic/Makefile2
-rw-r--r--modules/generic/pdp_del.c18
-rw-r--r--modules/generic/pdp_rawin.c302
-rw-r--r--modules/generic/pdp_rawout.c376
-rw-r--r--modules/image_basic/pdp_cheby.c6
-rw-r--r--modules/image_io/pdp_glx.c20
-rw-r--r--modules/image_io/pdp_qt.c6
-rw-r--r--modules/image_io/pdp_v4l.c24
-rw-r--r--modules/image_io/pdp_xv.c1
-rw-r--r--opengl/Makefile19
-rw-r--r--opengl/Makefile.config15
-rw-r--r--opengl/modules/pdp_3d_draw.c48
-rw-r--r--opengl/system/pdp_3Dcontext_common.c2
-rw-r--r--opengl/system/pdp_3Dcontext_glx.c1
-rw-r--r--opengl/system/pdp_opengl.c2
-rw-r--r--opengl/system/setup.c7
-rw-r--r--puredata/pdp_comm.c17
-rw-r--r--puredata/pdp_queue.c10
-rw-r--r--scaf/Makefile2
-rw-r--r--scaf/Makefile.config4
-rw-r--r--scaf/Makefile.config.in2
-rw-r--r--scaf/pdp/pdp_ca_system.c2
-rw-r--r--system/image/pdp_imageproc_portable.c6
-rw-r--r--system/kernel/pdp_list.c4
-rw-r--r--system/kernel/pdp_mem.c19
-rw-r--r--system/kernel/pdp_packet.c38
-rw-r--r--system/kernel/pdp_post.c4
-rw-r--r--system/kernel/pdp_type.c2
-rw-r--r--system/mmx/pixel_biquad_s16.s4
-rw-r--r--system/pdp.c13
-rw-r--r--system/png/pdp_png.c6
-rw-r--r--system/type/pdp_bitmap.c70
-rw-r--r--system/type/pdp_image.c5
53 files changed, 924 insertions, 371 deletions
diff --git a/CHANGES.LOG b/CHANGES.LOG
index 976955c..dd0bc40 100644
--- a/CHANGES.LOG
+++ b/CHANGES.LOG
@@ -157,5 +157,7 @@ v0.12: 2003/06/21
0.12.4: 2004/07/09
build fixes
+0.12.5:
+ build fixes
diff --git a/Makefile b/Makefile
index ab9a61c..0bc8ad0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,18 @@
include Makefile.config
-# all: $(PDP_TARGET)
+# hc ?
+#ifeq ($(OS_NAME),darwin)
+#all: darwin
+#else
+#all: linux
+#endif
-ifeq ($(OS_NAME),darwin)
-all: darwin
-else
-all: linux
-endif
+
+all: $(PDP_TARGET)
+
+everything: all
+ make -C opengl
+ make -C scaf
pdp_all:
make -C system
diff --git a/Makefile.config b/Makefile.config
index d023d8f..62b3c5f 100644
--- a/Makefile.config
+++ b/Makefile.config
@@ -3,20 +3,22 @@
#
#PD_CPPFLAGS=-I/path_to_pd_dir/src
#PD_EXECUTABLE=/path_to_pd_dir/bin/pd
-PD_CPPFLAGS=
-PD_EXECUTABLE=/usr/local/bin/pd
-PDP_CFLAGS=-DPD -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -O2 -funroll-loops -fomit-frame-pointer -ffast-math
+PD_CPPFLAGS=-I/home/tom/pdcvs/externals/pdp/../../pd/src
+PD_EXECUTABLE=
+PDP_CFLAGS=-DPD -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -I/../../pd/src -O2 -funroll-loops -fomit-frame-pointer -ffast-math
+# these are reused in opengl module
prefix=/usr/local
-PDP_VERSION = 0.12.4
-PDP_TARGET = darwin
-PDP_LIBRARY_NAME = pdp.pd_darwin
-PDP_EXTRA_CPPFLAGS = -I/sw/include
+PDP_VERSION=0.12.4
+PDP_TARGET=linux_mmx
+
+PDP_LIBRARY_NAME = pdp.pd_linux
+PDP_EXTRA_CPPFLAGS =
PDP_EXTRA_CFLAGS =
SDL_FLAGS = -D_REENTRANT
# optional objects
-PDP_OPTMOD = pdp_xv.o pdp_qt.o pdp_glx.o
+PDP_OPTMOD = pdp_v4l.o pdp_xv.o pdp_qt.o pdp_glx.o pdp_sdl.o
PDP_X11MOD = pdp_xwindow.o pdp_xvideo.o
PDP_PDMOD =
PDP_OPTTYPES = pdp_matrix.o
@@ -28,7 +30,7 @@ PDP_IMAGE_SPECIAL = pdp_histo.o
PDP_CPPFLAGS = -I. -I/usr/X11R6/include -I../include -I../../include $(PD_CPPFLAGS) $(PDP_EXTRA_CPPFLAGS)
-PDP_LIBS = -lgslcblas -lm -L/sw/lib -lgslcblas -lgsl -lz -lpng -L/usr/X11R6/lib -lX11 -lXv -lXext -lquicktime -lGL -lGLU
+PDP_LIBS = -lgslcblas -lm -lgslcblas -lgsl -lz -lpng -L/usr/X11R6/lib -lX11 -lXv -lXext -lquicktime -lGL -lGLU -lSDL
PDP_AFLAGS =
#--gstabs
@@ -45,7 +47,7 @@ PDP_CFLAGS += $(SDL_CFLAGS) $(PDP_EXTRA_CFLAGS) -DPDP_VERSION=\"$(PDP_VERSION)\"
#CC = gcc-3.2
#CC = gcc
#AS = as
-CC = cc
+CC = gcc
# build rules
diff --git a/Makefile.config.in b/Makefile.config.in
index e93eef9..446523e 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -7,9 +7,11 @@ PD_CPPFLAGS=@PD_CPPFLAGS@
PD_EXECUTABLE=@PD_EXECUTABLE@
PDP_CFLAGS=@PDP_CFLAGS@
+# these are reused in opengl module
prefix=@prefix@
-PDP_VERSION = @PDP_VERSION@
-PDP_TARGET = @PDP_TARGET@
+PDP_VERSION=@PDP_VERSION@
+PDP_TARGET=@PDP_TARGET@
+
PDP_LIBRARY_NAME = @PDP_LIBRARY_NAME@
PDP_EXTRA_CPPFLAGS = @PDP_EXTRA_CPPFLAGS@
PDP_EXTRA_CFLAGS = @PDP_EXTRA_CFLAGS@
diff --git a/README b/README
index 7ced23a..fef44df 100644
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
PDP - Pure Data Packet v0.12.4
a packet processing library for pure data
-Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
+Copyright (c) by Tom Schouten <pdp@goto10.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,7 +29,6 @@ as possible compatible with the pd messaging system.
This distro contains the main pdp library and 3 extension libs:
* pdp_scaf (in directory scaf/)
* pdp_opengl (in directory opengl/)
-* pdp_guile (in directory guile)
Features:
@@ -51,9 +50,9 @@ Optional features
* cellular automata simulator and effects processor with
built in forth extension language (only for mmx)
* opengl 3d processing (gem like, but built around packets)
-* embedded guile interpreter
-See the README files in the scaf/ opengl/ and guile/ dirs for more
+
+See the README files in the scaf/ and opengl/ dirs for more
info on the extension libraries.
@@ -153,7 +152,7 @@ now :)
Some Remarks:
* New versions of this package can be found at
-http://zwizwa.fartit.com/pd/pdp
+http://zwizwa.goto10.org/pd/pdp
Experimental relases are in the subdirectory test/
* If you have libquicktime and quicktime4linux installed, this can
@@ -249,7 +248,6 @@ include/ header files
modules/ pd object code
opengl/ opengl extension lib (experimental)
scaf/ CA extension lib
-guile/ scheme extension lib
system/ core pdp system
diff --git a/TODO b/TODO
index 318180c..a0c4e6a 100644
--- a/TODO
+++ b/TODO
@@ -1,56 +1,30 @@
-
-todo 0.12.x:
-best to do an intermediate release for documentation. 0.13 is not
-there yet.
-
-* check reference.txt
-
-
-
known bugs:
* running out of memory (using delay lines or loops) will likely crash pd.
short story: don't, use pdp_control's memlimit for limiting pdp's memory usage.
-* no known other fatal (crashing) bugs. please let me know if you find one.
-pdp/libpdp remark:
-i'm working on a version 2 of pdp. until that is finished, pdp proper will
-probably be frozen, except for bug fixes.
+todo 0.12.5:
+
+* find nasty 3dp bug
+* fix pdp_glx BadMatch bug (crashes on OSX)
+* platform independent [pdp_vdac] [pdp_vadc]
-todo 0.13:
-* yves shm code
-* make fobs (all c object code usable in packet forth should be wrapped (automaticly??))
-* pdp_xwindow event handling is not thread safe (fixed ?)
-* fine tune udp protocol
-* solve scheduling probs: pd+3dp = ok, pd+pdp+(3dp) = not
-(lots of frags -> video slow, few frags -> audio drops.
-pdp threading is not implemented everywhere and is a problem for feedback stuff. think about
-a synchronous dropping scheme (central point of failure), like for 3dp. most of the threading
-problems could be solved with the new threadsafe pd 0.37 -> check this out)
+todo later:
-* add source type to source objects (noise,plasma,constant,...) (solve with forth)
+* include guenter's / carmen's windows changes
+* field based bttv capture (might be possible without driver hacks using v4l2)
* pdp_crop/pad
-* seed plasma
-* reorganize headers to cut down compile time (done for core stuff, move pd objects to forth)
-* fullscreen x command -> add window manager suppression
* where to solve autoconvert? per type, or central in pdp_base? 2 cases:
- template based autoconvert: in pdp_base
- compatibility based autoconvert: i.e. pdp_add (solve in base: move_passive)
* finish high level packet conversion:
- move 8bit images to packet level (iow: cleanup pdp_qt, pdp_v4l, pdp_xv) (solve with forth)
-- add bitmap packet support to source modules (optim for pdp_opengl usage)
-(solve with sliceforth: pdp image processing should become independent of image encoding: at least
-packed 8/16 rgb(a), and all planar rgb/yuv formats should be well supported: sliceforth feeders)
- get rid of pdp_type* methods
* fix mac/linux name differences (use pdp_video, pdp_movie, pdp_window)
* pdp_xv framerate doc + pwc addons
-
-todo 0.14:
-
-* stress test the memory manager. it looks like there's a bug that pops up after running for a while
* enable audio output on bttv cards in pdp_v4l
* fix cache slicer objects + thread problems (fixed in sliceforth)
* derive as much classes as possible from pdp_base class (obsolete: use forth instead)
@@ -76,18 +50,9 @@ todo 0.14:
* moebius transforms
* type multiplexing: find a way to use the same name for packet processors. (solved in forth: polymorhpy)
i.e. pdp_add should add images, but also vectors, ascii packets, textures,...
-
-experimental stuff
-
* modify 2D rotation to be used as arbitrary rotation (givens)
* add 3D rotation
* frame rate limited delay line (burst delay?)
* optimize resampling code (mipmapped packed 16bit format?)
-* better type handling
-
-core is in place. todo:
-- better (tree) search algorithm (breadth first + cost)
-- add more converters
-
diff --git a/buildall b/buildall
index 155633f..dcfc6d6 100755
--- a/buildall
+++ b/buildall
@@ -3,16 +3,17 @@
# a build script to build and configure the entire pdp distro
# might need some editing to work for you
+# PREFIX=--prefix=/home/tom/pd
+
# build the stable stuff
-autoconf && ./configure --enable-mmx --prefix=/home/tom/pd && make install
+./configure --enable-mmx && make install
cd scaf
-autoconf && ./configure && make install
+./configure && make install
cd ..
# build the experimental stuff
-
make -C opengl
diff --git a/configure.ac b/configure.ac
index 31aca5e..ac20560 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AC_HEADER_STDC
dnl TAG CVS WHEN RELEASE VERSION CHANGES !!!
-PDP_VERSION=0.12.4
+PDP_VERSION=0.12.5-darcs
AC_SUBST(PDP_VERSION)
AC_ARG_ENABLE(mmx,
@@ -42,10 +42,11 @@ AC_ARG_ENABLE(debug,
[ --enable-debug enable debugging support (no)], , enable_debug=no)
-PWD=`pwd`
-PDP_CFLAGS="-DPD -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -I$(PWD)/../../pd/src"
+# long double? -Wno-long-double
+PDP_CFLAGS="-DPD -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses -Wno-switch -fPIC"
dnl -Werror -Wshadow
+dnl the -Wshadow option is way too strict.. gl headers won't compile
@@ -53,7 +54,7 @@ dnl setup debugging
if test $enable_debug == yes
then
AC_DEFINE(PDP_DEBUG, 1, "enable debugging support")
- PDP_CFLAGS="$PDP_CFLAGS -g -Werror -Wshadow"
+ PDP_CFLAGS="$PDP_CFLAGS -g -Werror"
else
AC_DEFINE(PDP_DEBUG, 0, "disable debugging support")
PDP_CFLAGS="$PDP_CFLAGS -O2 -funroll-loops -fomit-frame-pointer -ffast-math"
@@ -75,6 +76,7 @@ fi
dnl try to locate the pd header in case the setup is nonstandard
dnl check in $prefix/pd/src then ../pd/src
dnl if this fails we trust it is in the standard include path
+PWD=`pwd`
if test -f $prefix/pd/src/m_pd.h;
then
PD_CPPFLAGS="-I$prefix/pd/src"
@@ -82,9 +84,6 @@ then
elif test -f $prefix/src/pd/src/m_pd.h;
then
PD_CPPFLAGS="-I$prefix/src/pd/src"
-elif test -f $PWD/../../pd/src/m_pd.h;
-then
- PD_CPPFLAGS="-I$PWD/../../pd/src"
elif test -f $PWD/../pd/src/m_pd.h;
then
PD_CPPFLAGS="-I$PWD/../pd/src"
@@ -127,7 +126,7 @@ dnl Darwin specific stuff: this is still pretty experimental
dnl How to test if frameworks are present ????
if test $ARCH == Darwin
then
- PD_EXECUTABLE=$PWD/../../pd/bin/pd
+ PD_EXECUTABLE=$prefix/bin/pd
LIBS="$LIBS -L/sw/lib"
CPPFLAGS="$CPPFLAGS -I/sw/include"
PDP_EXTRA_CPPFLAGS="-I/sw/include"
diff --git a/doc/misc/devdoc.html b/doc/misc/devdoc.html
index 5ce1f83..c587c48 100644
--- a/doc/misc/devdoc.html
+++ b/doc/misc/devdoc.html
@@ -5,6 +5,9 @@
</head>
<body>
+ <p> FIXME: This is probably a bit out of date.
+
+
<h1>PDP Developer Documentation</h1>
<h2>Introduction</h2>
diff --git a/doc/misc/overview.html b/doc/misc/overview.html
index 6eb0e70..fd83454 100644
--- a/doc/misc/overview.html
+++ b/doc/misc/overview.html
@@ -16,12 +16,8 @@ standard PD numbers and symbol types. In short it puts any data object on
the same level as a float or a symbol.
<p>PDP runs on Linux and OSX. The OSX version depends on <a
-href="http://fink.sourceforge.net/">Fink</a>, which is not in the "point &
-click" stage yet, so setting it up will require some efford. There is no
-windows version. The reason for this is simple: i don't use windows myself.
-Porting would require writing code for input/output and getting the
-libraries PDP depends on to work. If anyone is willing to do this, just let
-me know. PDP can run without X Window, using SDL.
+href="http://fink.sourceforge.net/">Fink</a>. There is no
+windows version.
<p> Currently, PDP's focus is on images and video, but there is no reason it
should stay like that. There is limited support for matrix processing
@@ -38,19 +34,20 @@ href="http://ydegoyon.free.fr/pidip.html">PiDiP</a> library.
If you're used to working with PD, the the documentation and example
patches should be enough to get you started. Have a look at the README file
in the distribution to find out how to compile and setup. The file
-doc/reference.txt contains a list of objects. If you have installed PDP
+<code>doc/reference.txt</code> contains a list of objects. If you have installed PDP
properly, you can just press the right mouse button on an object and select
help to get a help patch. If this doesn't work, look in the directory
-doc/objects for a collection of help patches. The directory doc/examples
-contains some more demos. The directory doc/objects contains two
+<code>doc/objects</code> for a collection of help patches. The directory <code>doc/examples</code>
+contains some more demos. The directory <code>doc/objects</code> contains two
abstractions that are used to setup the input and output in the help
patches. You might want to cut and connect some wires to use the
input/output setup that works for you.
<h2>Packets and Types</h2>
-<p> PDP is centered around the concept of packets and operations on
-packets. There are several types of packets. The default type for most
+<p> PDP is about packets and operations on packets. Packets are just chunks
+of dumb data. The interpretation of this data depends on its type name.
+There are several types of packets. The default type for most
objects is <code><b>image/YCrCb/320x240</b></code>. This is a single video
frame, encoded in the internal 16bit YUV format, measuring 320 by 240
pixels. Another image type is the grayscale image
@@ -90,13 +87,16 @@ can be drawn to the screen, captured as a texture, converted back to an
image, which can then be converted to a sound, processed and converted back
to an image, etc... You get the point. The possibilities are endless.
-
+<p> Over the last couple of years, PDP has given birth to a forked off project called
+<a href="http://zwizwa.goto10.org/zwikizwaki.php?page=PacketForth">Packet Forth</a>.
+This is a programming laguage based on ideas from Forth and Lisp. It's aim is
+loosely to be a kind of 'media Perl'.
<hr>
<address><a href="mailto:pdp@zzz.kotnet.org">Tom Schouten</a></address>
<!-- Created: Thu Apr 24 22:21:03 CEST 2003 -->
<!-- hhmts start -->
-Last modified: Thu Sep 25 20:51:44 CEST 2003
+Last modified: Thu Jan 25 23:56:07 CEST 2006
<!-- hhmts end -->
</body>
</html>
diff --git a/doc/reference.txt b/doc/reference.txt
index d9b7d92..a57953e 100644
--- a/doc/reference.txt
+++ b/doc/reference.txt
@@ -12,6 +12,7 @@ pdp_route routes a packet to a specific outlet
pdp_loop a packet loop sampler (packet array)
pdp_description output a symbol describing the packet type
pdp_convert convert between packet types
+pdp_metro~ audio/video sync object
image inputs/outputs:
@@ -19,6 +20,9 @@ pdp_xv displays images using the xvideo extension
pdp_glx displays images using opengl
pdp_v4l reads images from a video4linux device
pdp_qt reads quicktime movies
+pdp_rawin read packets from pipe or file
+pdp_rawout write packets to pipe or file
+pdp_rawout~ write audio to pipe or file
image processors:
diff --git a/include/pdp_comm.h b/include/pdp_comm.h
index bd6cab8..7932e1d 100644
--- a/include/pdp_comm.h
+++ b/include/pdp_comm.h
@@ -37,8 +37,17 @@ extern "C"
/* pdp's pd symbols for communication
don't use these directly!!
use the macros instead, in case
- this is proven to be too much of a hack.. */
+ this is proven to be too much of a hack..
+ it's too much of a hack. getting rid of them.
+
+ */
+
+
+#define PDP_SYMBOL_HACK 0
+
+
+#if PDP_SYMBOL_HACK
extern t_symbol s_pdp;
extern t_symbol s_register_ro;
extern t_symbol s_register_rw;
@@ -58,6 +67,20 @@ extern t_symbol s_chanmask;
#define S_ACCUMULATE &s_accumulate
#define S_CHANMASK &s_chanmask
+#else
+
+#define S_PDP gensym("pdp")
+#define S_REGISTER_RO gensym("register_ro")
+#define S_REGISTER_RW gensym("register_rw")
+#define S_PROCESS gensym("process")
+#define S_DPD gensym("dpd")
+#define S_INSPECT gensym("inspect")
+#define S_ACCUMULATE gensym("accumulate")
+#define S_CHANMASK gensym("chanmask")
+
+
+#endif
+
/* utility methods */
diff --git a/include/pdp_config.h b/include/pdp_config.h
index 74274e2..7d93a9f 100644
--- a/include/pdp_config.h
+++ b/include/pdp_config.h
@@ -29,10 +29,10 @@
/* #undef HAVE_PDP_READLINE */
/* build pdp_sdl */
-/* #undef HAVE_PDP_SDL */
+#define HAVE_PDP_SDL 1
/* build pdp_v4l */
-/* #undef HAVE_PDP_V4L */
+#define HAVE_PDP_V4L 1
/* experimental vforth dsp engine */
/* #undef HAVE_PDP_VFORTH */
diff --git a/include/pdp_list.h b/include/pdp_list.h
index 2f7b8f5..3d55593 100644
--- a/include/pdp_list.h
+++ b/include/pdp_list.h
@@ -179,7 +179,7 @@ void pdp_list_add_back_atom(t_pdp_list *l, t_pdp_atom *a);
/* these don't do error checking. out of bound == error */
t_pdp_atom *pdp_list_pop_atom (t_pdp_list *l);
t_pdp_word pdp_list_pop (t_pdp_list *l);
-t_pdp_word pdp_list_index (t_pdp_list *l, int index);
+t_pdp_word pdp_list_index (t_pdp_list *l, int indx);
void pdp_list_pop_push (t_pdp_list *source, t_pdp_list *dest);
/* some aliases */
diff --git a/include/pdp_mem.h b/include/pdp_mem.h
index 3301655..00141e4 100644
--- a/include/pdp_mem.h
+++ b/include/pdp_mem.h
@@ -29,7 +29,6 @@ void pdp_dealloc(void *stuff);
/* fast allocator object (for lists and atoms) */
-#define PDP_FASTALLOC_BLOCK_ELEMENTS 4096
typedef struct _pdp_fastalloc
{
unsigned int atom_size;
diff --git a/include/pdp_net.h b/include/pdp_net.h
index 9e638c4..4f775c6 100644
--- a/include/pdp_net.h
+++ b/include/pdp_net.h
@@ -114,7 +114,7 @@ typedef struct _pdp_udp_receiver
unsigned int x_data_size;
void *x_data;
struct sockaddr_in x_source_socket;
- int x_sslen;
+ socklen_t x_sslen;
int x_receive_finished;
int x_packet_transferred;
diff --git a/include/pdp_packet.h b/include/pdp_packet.h
index f944095..234024d 100644
--- a/include/pdp_packet.h
+++ b/include/pdp_packet.h
@@ -49,12 +49,15 @@
The interface to the packet manager contains the following managing methods:
- * pdp_packet_new: create a new packet or reuse a previous one
+ * pdp_packet_create: create a new packet
* pdp_packet_mark_unused: release a packet
* pdp_packet_copy_ro: register a packet for read only use
* pdp_packet_copy_rw: register a packet for read/write use (this creates a copy if necessary)
* pdp_packet_clone_rw: create a new packet using a template, but don't copy the data
+ ( some types have shortcut methods pdp_packet_new_ which create/reuse a packet
+ unless you are writing a factory method for a packet, you should NEVER call a _create method )
+
And two methods for raw data access
* pdp_packet_header: retreive the header of the packet
diff --git a/include/pdp_post.h b/include/pdp_post.h
index 05b5143..1054388 100644
--- a/include/pdp_post.h
+++ b/include/pdp_post.h
@@ -22,8 +22,22 @@
#ifndef _PDP_POST_H_
#define _PDP_POST_H_
+#include <stdarg.h>
+#include <m_pd.h>
+
/* write a message to log (console) */
-void pdp_post_n(char *fmt, ...);
-void pdp_post(char *fmt, ...);
+
+#include <m_pd.h>
+
+// old
+//void pdp_post_n(char *fmt, ...);
+//void pdp_post(char *fmt, ...);
+
+// new
+//void startpost(const char *fmt, ...);
+//void post(const char *fmt, ...);
+
+#define pdp_post_n startpost
+#define pdp_post post
#endif
diff --git a/include/pdp_queue.h b/include/pdp_queue.h
index eeffd2e..b4d19be 100644
--- a/include/pdp_queue.h
+++ b/include/pdp_queue.h
@@ -82,7 +82,7 @@ int pdp_procqueue_full(t_pdp_procqueue *q);
void pdp_procqueue_flush(t_pdp_procqueue *q);
void pdp_procqueue_wait(t_pdp_procqueue *q);
-void pdp_procqueue_finish(t_pdp_procqueue *q, int index);
+void pdp_procqueue_finish(t_pdp_procqueue *q, int indx);
void pdp_procqueue_add(t_pdp_procqueue *q, void *owner, void *process, void *callback, int *queue_id);
void pdp_procqueue_use_thread(t_pdp_procqueue* q, int t);
void pdp_procqueue_init(t_pdp_procqueue *q, double milliseconds, int logsize);
diff --git a/include/pdp_types.h b/include/pdp_types.h
index b021dd7..767a937 100644
--- a/include/pdp_types.h
+++ b/include/pdp_types.h
@@ -24,14 +24,25 @@
#ifndef PDP_TYPES_H
#define PDP_TYPES_H
+/* check
+ http://www.unix.org/whitepapers/64bit.html
+ on unix (LP64) int = 32bit
+
+ it was like this:
+
+ typedef signed long s32;
+ typedef unsigned long u32;
+*/
+
+
typedef signed char s8;
typedef signed short s16;
-typedef signed long s32;
+typedef signed int s32;
typedef signed long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
-typedef unsigned long u32;
+typedef unsigned int u32;
typedef unsigned long long u64;
diff --git a/modules/generic/Makefile b/modules/generic/Makefile
index 035f970..e264828 100644
--- a/modules/generic/Makefile
+++ b/modules/generic/Makefile
@@ -4,7 +4,7 @@ include ../../Makefile.config
PDP_MOD = pdp_reg.o pdp_del.o pdp_snap.o pdp_trigger.o \
pdp_route.o pdp_inspect.o pdp_loop.o pdp_description.o pdp_convert.o \
- pdp_udp_send.o pdp_udp_receive.o pdp_rawin.o pdp_rawout.o
+ pdp_udp_send.o pdp_udp_receive.o pdp_rawin.o pdp_rawout.o pdp_metro.o
# build generic modules
all_modules: $(PDP_MOD)
diff --git a/modules/generic/pdp_del.c b/modules/generic/pdp_del.c
index 4b51023..6b7aeb2 100644
--- a/modules/generic/pdp_del.c
+++ b/modules/generic/pdp_del.c
@@ -71,7 +71,14 @@ static void pdp_del_input_0(t_pdp_del *x, t_symbol *s, t_floatarg f)
else if (s == gensym("process")){
out = (((x->x_head + x->x_delay)) % x->x_order);
packet = x->x_packet[out];
- pdp_packet_pass_if_valid(x->x_outlet0, &x->x_packet[out]);
+
+ // originally, we wouldn't keep the packet in the delay line to save memory
+ // however, this behaviour is very annoying, and doesn't allow ''scratching''
+ // so we send out a copy instead.
+ // pdp_packet_pass_if_valid(x->x_outlet0, &x->x_packet[out]);
+ int p = pdp_packet_copy_ro(packet);
+ pdp_packet_pass_if_valid(x->x_outlet0, &p);
+
/*
if (-1 != packet){
@@ -88,6 +95,15 @@ static void pdp_del_input_0(t_pdp_del *x, t_symbol *s, t_floatarg f)
*/
x->x_head = (x->x_head + x->x_order - 1) % x->x_order;
+
+/*
+ int i;
+ for (i=0; i<x->x_order; i++){
+ fprintf(stderr, " %d", x->x_packet[i]);
+ }
+ fprintf(stderr, "\n");
+*/
+
}
diff --git a/modules/generic/pdp_rawin.c b/modules/generic/pdp_rawin.c
index 28ef8fb..04d8775 100644
--- a/modules/generic/pdp_rawin.c
+++ b/modules/generic/pdp_rawin.c
@@ -1,5 +1,5 @@
/*
- * Pure Data Packet module. packet forth console
+ * Pure Data Packet module. Raw packet input
* Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,7 @@
*/
+#include <string.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
@@ -40,6 +41,55 @@
#define D if (1)
+/* TODO: add flow control
+
+reminder: pthread condition values for synchro
+
+writing to a queue goes like this:
+* pthread_mutex_lock
+* atomic op (write)
+* pthread_cond_signal
+* pthread_mutex_unlock
+
+reading from a queue goes like this:
+* pthread_mutex_lock
+* while (!CONDITION) pthread_cond_wait
+* atomic op (read)
+* pthread_mutex_unlock
+
+
+in this case, there is a reader and a writer, AND a maximum
+size of the buffer between them (1 atom) so both reader and writer
+might block. compare this to the 'command queue' in libpf, where
+only the reader blocks.
+
+so the course of events is:
+
+READER
+* wait for data ready (COND_READ) this blocks pd, it is assumed data is always ready in normal operation
+* consume
+* signal writer (COND_WRITE)
+
+
+WRITER
+* wait for space ready (COND_WRITE)
+* write
+* signal reader
+
+
+one remark though:
+is this machinery really necessary?
+-----------------------------------
+
+it might be easier to just read in the pd thread.
+the only problem this gives is when data really arrives not in a single chunk, but as a stream.
+to me that seems a really awkward special case which can be solved using another PROCESS to
+do the buffering / dropping.
+
+so, for now, it's just synchronous, no threads for sync reading.
+
+*/
+
/* raw input from a unix pipe */
@@ -54,16 +104,18 @@ typedef struct rawin_struct
/* comm */
t_pdp_list *x_queue; // packet queue
+ int x_pipefd;
/* thread */
pthread_mutex_t x_mut;
pthread_attr_t x_attr;
pthread_t x_thread;
+
/* sync */
+ int x_mode; // 1-> sync to input
int x_giveup; // 1-> terminate reader thread
int x_active; // 1-> reader thread is launched
- int x_done; // 1-> reader thread has exited
/* config */
t_symbol *x_pipe;
@@ -76,138 +128,125 @@ static inline void lock(t_rawin *x){pthread_mutex_lock(&x->x_mut);}
static inline void unlock(t_rawin *x){pthread_mutex_unlock(&x->x_mut);}
static void rawin_close(t_rawin *x);
-static void tick(t_rawin *x)
-{
- /* send all packets in queue to outlet */
- lock(x);
- while (x->x_queue->elements){
- outlet_pdp_atom(x->x_outlet, x->x_queue->first);
- pdp_list_pop(x->x_queue); // pop stale reference
- }
- unlock(x);
- clock_delay(x->x_clock, PERIOD);
- /* check if thread is done */
- if (x->x_done) rawin_close(x);
-}
-static void move_current_to_queue(t_rawin *x, int packet)
-{
- lock(x);
- pdp_list_add_back(x->x_queue, a_packet, (t_pdp_word)packet);
- unlock(x);
-}
-static void *rawin_thread(void *y)
-{
- int pipe;
+static int read_packet(t_rawin *x){
+
int packet = -1;
- t_rawin *x = (t_rawin *)y;
+ void *data = 0;
+ int left = -1;
int period_sec;
int period_usec;
-
- //D pdp_post("pipe: %s", x->x_pipe->s_name);
- //D pdp_post("type: %s", x->x_type->s_name);
-
- /* open pipe */
- if (-1 == (pipe = open(x->x_pipe->s_name, O_RDONLY|O_NONBLOCK))){
- perror(x->x_pipe->s_name);
- goto exit;
+ /* create packet */
+ if (-1 != packet){
+ pdp_post("WARNING: deleting stale packet");
+ pdp_packet_mark_unused(packet);
+ }
+ packet = pdp_factory_newpacket(x->x_type);
+ if (-1 == packet){
+ pdp_post("ERROR: can't create packet. type = %s", x->x_type->s_name);
+ goto close;
}
+
+ /* fill packet */
+ data = pdp_packet_data(packet);
+ left = pdp_packet_data_size(packet);
+ // D pdp_post("packet %d, data %x, size %d", packet, data, left);
+
+ /* inner loop: pipe reads */
+ while(left){
- /* main loop (packets) */
- while(1){
- void *data = 0;
- int left = -1;
+ fd_set inset;
+ struct timeval tv = {0,10000};
- /* create packet */
- if (-1 != packet){
- pdp_post("WARNING: deleting stale packet");
+ /* check if we need to stop */
+ if (x->x_giveup){
pdp_packet_mark_unused(packet);
+ goto close;
}
- packet = pdp_factory_newpacket(x->x_type);
- if (-1 == packet){
- pdp_post("ERROR: can't create packet. type = %s", x->x_type->s_name);
- goto exit;
+ /* select, with timeout */
+ FD_ZERO(&inset);
+ FD_SET(x->x_pipefd, &inset);
+ if (-1 == select(x->x_pipefd+1, &inset, NULL,NULL, &tv)){
+ pdp_post("select error");
+ goto close;
}
-
- /* fill packet */
- data = pdp_packet_data(packet);
- left = pdp_packet_data_size(packet);
- // D pdp_post("packet %d, data %x, size %d", packet, data, left);
-
- /* inner loop: pipe reads */
- while(left){
-
- fd_set inset;
- struct timeval tv = {0,10000};
-
- /* check if we need to stop */
- if (x->x_giveup){
- pdp_packet_mark_unused(packet);
- goto close;
- }
- /* select, with timeout */
- FD_ZERO(&inset);
- FD_SET(pipe, &inset);
- if (-1 == select(pipe+1, &inset, NULL,NULL, &tv)){
- pdp_post("select error");
- goto close;
- }
- /* if ready, read, else retry */
- if (FD_ISSET(pipe, &inset)){
- int bytes = read(pipe, data, left);
- if (!bytes){
- /* if no bytes are read, pipe is closed */
- goto close;
- }
- data += bytes;
- left -= bytes;
+ /* if ready, read, else retry */
+ if (FD_ISSET(x->x_pipefd, &inset)){
+ int bytes = read(x->x_pipefd, data, left);
+ if (!bytes){
+ /* if no bytes are read, pipe is closed */
+ goto close;
}
+ data += bytes;
+ left -= bytes;
}
-
- /* move to queue */
- move_current_to_queue(x, packet);
- packet = -1;
+ }
+ return packet;
+ close:
+ return -1;
+}
-
+/* reader thread syncs to pipe */
+static void *rawin_thread(void *y)
+{
+ t_rawin *x = (t_rawin *)y;
+ int packet = -1;
+
+ /* loop until error or close */
+ while (-1 != (packet = read_packet(x))) {
+ lock(x);
+ pdp_list_add_back(x->x_queue, a_packet, (t_pdp_word)packet);
+ unlock(x);
}
- close:
- /* close pipe */
- close(pipe);
-
-
- exit:
- x->x_done = 1;
return 0;
}
+/* sync to stream:
+ tick polls the receive queue */
+static void rawin_tick(t_rawin *x)
+{
+ int p = -1;
+
+ /* send all packets in queue to outlet */
+ while (x->x_queue->elements){
+ lock(x);
+ //pdp_post("%d", x->x_queue->elements);
+ p = pdp_list_pop(x->x_queue).w_packet;
+ unlock(x);
+ //pdp_post_n("%d ", p);
+ pdp_packet_pass_if_valid(x->x_outlet, &p);
+ //pdp_post("%d",p);
+ }
+ clock_delay(x->x_clock, PERIOD);
+}
-static void rawin_type(t_rawin *x, t_symbol *type)
-{
- x->x_type = pdp_gensym(type->s_name);
+/* sync to bang:
+ this runs the reader in the pd thread
+ */
+static void rawin_bang(t_rawin *x){
+ if (!x->x_active) return;
+ if (x->x_mode) return;
+ int packet = read_packet(x);
+ if (-1 == packet) rawin_close(x); // close on error
+ pdp_packet_pass_if_valid(x->x_outlet, &packet);
+
}
-static void rawin_open(t_rawin *x, t_symbol *pipe)
-{
- /* save pipe name if not empty */
- if (pipe->s_name[0]) {x->x_pipe = pipe;}
- if (x->x_active) {
- pdp_post("already open");
- return;
- }
- /* start thread */
- x->x_giveup = 0;
- x->x_done = 0;
- pthread_create(&x->x_thread, &x->x_attr, rawin_thread , x);
- x->x_active = 1;
+
+
+
+static void rawin_type(t_rawin *x, t_symbol *type)
+{
+ x->x_type = pdp_gensym(type->s_name);
}
static void rawin_close(t_rawin *x)
@@ -217,19 +256,52 @@ static void rawin_close(t_rawin *x)
/* stop thread: set giveup + wait */
x->x_giveup = 1;
- pthread_join(x->x_thread, NULL);
+ if (x->x_mode) pthread_join(x->x_thread, NULL);
x->x_active = 0;
+ /* close pipe */
+ close(x->x_pipefd);
+
/* notify */
outlet_bang(x->x_sync_outlet);
- pdp_post("connection to %s closed", x->x_pipe->s_name);
-
+ pdp_post("pdp_rawin: connection to %s closed", x->x_pipe->s_name);
+}
+
+
+static void rawin_open(t_rawin *x, t_symbol *spipe)
+{
+ /* save pipe name if not empty */
+ if (spipe->s_name[0]) {x->x_pipe = spipe;}
+ if (x->x_active) {
+ pdp_post("pdp_rawin: already open");
+ return;
+ }
+ /* open pipe */
+ if (-1 == (x->x_pipefd = open(x->x_pipe->s_name, O_RDONLY|O_NONBLOCK))){
+ perror(x->x_pipe->s_name);
+ return;
+ }
+
+ /* thread control vars */
+ x->x_giveup = 0;
+ x->x_active = 1;
+
+ /* start thread if sync mode */
+ if (x->x_mode)
+ pthread_create(&x->x_thread, &x->x_attr, rawin_thread , x);
}
+
+static void rawin_sync(t_rawin *x, t_float fmode){
+ rawin_close(x);
+ x->x_mode = (int)fmode;
+}
+
+
static void rawin_free(t_rawin *x)
{
rawin_close(x);
@@ -241,21 +313,21 @@ static void rawin_free(t_rawin *x)
t_class *rawin_class;
-static void *rawin_new(t_symbol *pipe, t_symbol *type)
+static void *rawin_new(t_symbol *spipe, t_symbol *type)
{
t_rawin *x;
- pdp_post("%s %s", pipe->s_name, type->s_name);
+ pdp_post("%s %s", spipe->s_name, type->s_name);
/* allocate & init */
x = (t_rawin *)pd_new(rawin_class);
x->x_outlet = outlet_new(&x->x_obj, &s_anything);
x->x_sync_outlet = outlet_new(&x->x_obj, &s_anything);
- x->x_clock = clock_new(x, (t_method)tick);
+ x->x_clock = clock_new(x, (t_method)rawin_tick);
x->x_queue = pdp_list_new(0);
x->x_active = 0;
x->x_giveup = 0;
- x->x_done = 0;
+ x->x_mode = 0;
x->x_type = pdp_gensym("image/YCrCb/320x240"); //default
x->x_pipe = gensym("/tmp/pdpraw"); // default
pthread_attr_init(&x->x_attr);
@@ -264,7 +336,7 @@ static void *rawin_new(t_symbol *pipe, t_symbol *type)
/* args */
rawin_type(x, type);
- if (pipe->s_name[0]) x->x_pipe = pipe;
+ if (spipe->s_name[0]) x->x_pipe = spipe;
return (void *)x;
@@ -286,10 +358,12 @@ void pdp_rawin_setup(void)
rawin_class = class_new(gensym("pdp_rawin"), (t_newmethod)rawin_new,
(t_method)rawin_free, sizeof(t_rawin), 0, A_DEFSYMBOL, A_DEFSYMBOL, A_NULL);
- /* add global message handler */
+ /* add global message handlers */
class_addmethod(rawin_class, (t_method)rawin_type, gensym("type"), A_SYMBOL, A_NULL);
class_addmethod(rawin_class, (t_method)rawin_open, gensym("open"), A_DEFSYMBOL, A_NULL);
class_addmethod(rawin_class, (t_method)rawin_close, gensym("close"), A_NULL);
+ class_addmethod(rawin_class, (t_method)rawin_sync, gensym("sync"), A_FLOAT, A_NULL);
+ class_addmethod(rawin_class, (t_method)rawin_bang, gensym("bang"), A_NULL);
}
diff --git a/modules/generic/pdp_rawout.c b/modules/generic/pdp_rawout.c
index e1e9edf..01d7ca0 100644
--- a/modules/generic/pdp_rawout.c
+++ b/modules/generic/pdp_rawout.c
@@ -1,5 +1,5 @@
/*
- * Pure Data Packet module. packet forth console
+ * Pure Data Packet module. Raw packet output.
* Copyright (c) by Tom Schouten <pdp@zzz.kotnet.org>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,6 +19,31 @@
*/
+/*
+ This is the most straightforward way to get data out of pdp.
+ The internals follow the simple reader/writer pattern
+ * writer: runs in pd thread, accepts packets from inlet and stores in queue
+ * reader: runs in own thread, reads packets from queue and writes to pipe
+
+ Since there is no communication from reader to writer, we need a watchdog
+ timer to check the status of the writer. Mainly to close when necessary.
+
+ To enable audio recording, pdp_rawout will also produce interleaved 16bit
+ audio. You will need to instantiate it with [pdp_rawout~ nbchans]
+
+
+
+*/
+
+/* TODO:
+
+ make audio buffer smaller (128 bytes writes is too heavy)
+
+*/
+
+
+
+#include <string.h>
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
@@ -39,10 +64,9 @@
#define D if (1)
-#define MAX_QUEUESIZE 4
+#define DEF_QUEUESIZE 100
#define PIPE_BLOCKSIZE 4096
-
-
+#define POLLTIME 20
/* raw input from a unix pipe */
@@ -51,11 +75,19 @@ typedef struct rawout_struct
{
/* pd */
t_object x_obj;
+ t_float x_f;
+
//t_outlet *x_outlet;
t_outlet *x_sync_outlet;
/* comm */
- t_pdp_list *x_queue; // packet queue
+ t_pdp_list *x_queue; // packet queue
+ t_clock *x_clock; // watchdog timer
+ t_float x_deltime; // watchdog period
+ int x_verbose;
+ int x_packet; // dsp fillup state
+ int x_countdown; // amount of packet filled up
+ short int * x_needle; // start writing here
/* thread */
pthread_mutex_t x_mut;
@@ -68,8 +100,10 @@ typedef struct rawout_struct
int x_done; // 1-> writer thread has exited
/* config */
- t_symbol *x_pipe;
- t_pdp_symbol *x_type;
+ t_symbol *x_pipe;
+ int x_chans; // nb audio channels
+ t_pdp_symbol *x_tmptype;
+ int x_max_queuesize; // buffer size ( < 0 = infty )
} t_rawout;
@@ -78,55 +112,41 @@ static inline void lock(t_rawout *x){pthread_mutex_lock(&x->x_mut);}
static inline void unlock(t_rawout *x){pthread_mutex_unlock(&x->x_mut);}
static void rawout_close(t_rawout *x);
-static void pdp_in(t_rawout *x, t_symbol *s, t_float f)
-{
- /* save packet to pdp queue, if size is smaller than maxsize */
- if (s == S_REGISTER_RO){
- if (x->x_queue->elements < MAX_QUEUESIZE){
- int p = (int)f;
- p = pdp_packet_copy_ro(p);
- if (p != -1){
- lock(x);
- pdp_list_add_back(x->x_queue, a_packet, (t_pdp_word)p);
- unlock(x);
- }
- }
- else {
- pdp_post("pdp_rawout: dropping packet: (queue full)", MAX_QUEUESIZE);
- }
-
- }
-
- /* check if thread is done */
- if (x->x_done) rawout_close(x);
-
-}
-
+/* READER THREAD: reads from queue, writes to pipe */
static void *rawout_thread(void *y)
{
- int pipe;
+ int pipefd;
int packet = -1;
t_rawout *x = (t_rawout *)y;
int period_sec;
int period_usec;
- sigset_t sigvec; /* signal handling */
+ sigset_t _sigvec; /* signal handling */
+
+ char me[1024];
+ sprintf(me, "pdp_rawout: %s", x->x_pipe->s_name);
/* ignore pipe signal */
- sigemptyset(&sigvec);
- sigaddset(&sigvec,SIGPIPE);
- pthread_sigmask(SIG_BLOCK, &sigvec, 0);
+ sigemptyset(&_sigvec);
+ sigaddset(&_sigvec,SIGPIPE);
+ pthread_sigmask(SIG_BLOCK, &_sigvec, 0);
//D pdp_post("pipe: %s", x->x_pipe->s_name);
//D pdp_post("type: %s", x->x_type->s_name);
+
/* open pipe */
- if (-1 == (pipe = open(x->x_pipe->s_name, O_WRONLY|O_NONBLOCK))){
- perror(x->x_pipe->s_name);
- goto exit;
+ if (-1 == (pipefd = open(x->x_pipe->s_name, O_WRONLY|O_NONBLOCK|O_APPEND))){
+ if (-1 == (pipefd = open(x->x_pipe->s_name, O_WRONLY|O_CREAT))){
+ perror(me);
+ goto exit;
+ }
}
+ pdp_post("pdp_rawout: opened %s", x->x_pipe->s_name);
+
+
/* main loop (packets) */
while(1){
void *data = 0;
@@ -147,10 +167,15 @@ static void *rawout_thread(void *y)
lock(x);
packet = pdp_list_pop(x->x_queue).w_packet;
unlock(x);
-
+
/* send packet */
+ //t_pdp *h = pdp_packet_header(packet);
+ //fprintf(stderr, "users %d\n", h->users);
+
data = pdp_packet_data(packet);
left = pdp_packet_data_size(packet);
+ //int i; for (i = 0; i<left/2; i++) fprintf(stderr, "%06x ", ((short int *)data)[i]); fprintf(stderr, "\n");
+
/* inner loop: pipe reads */
while(left){
@@ -166,19 +191,20 @@ static void *rawout_thread(void *y)
/* select, with timeout */
FD_ZERO(&outset);
- FD_SET(pipe, &outset);
- if (-1 == select(pipe+1, NULL, &outset, NULL, &tv)){
+ FD_SET(pipefd, &outset);
+ if (-1 == select(pipefd+1, NULL, &outset, NULL, &tv)){
pdp_post("select error");
goto close;
}
/* if ready, read, else retry */
- if (FD_ISSET(pipe, &outset)){
- int bytes = write(pipe, data, left);
+ if (FD_ISSET(pipefd, &outset)){
+
+ int bytes = write(pipefd, data, left);
/* handle errors */
if (bytes <= 0){
- perror(x->x_pipe->s_name);
- if (bytes != EAGAIN) goto close;
+ perror(me);
+ if (errno != EAGAIN) goto close;
}
/* or update pointers */
else{
@@ -200,7 +226,7 @@ static void *rawout_thread(void *y)
close:
/* close pipe */
- close(pipe);
+ close(pipefd);
exit:
@@ -209,16 +235,121 @@ static void *rawout_thread(void *y)
}
+/* DSP INPUT */
+#define DSP_ARG(type, name, source) type name = (type)source
-static void rawout_type(t_rawout *x, t_symbol *type)
+static t_int *rawout_perform(t_int *w);
+static void rawout_dsp(t_rawout *x, t_signal **sp){
+ int nargs = 2 + x->x_chans;
+ t_int args[nargs];
+ args[0] = (int)x;
+ args[1] = (int)sp[0]->s_n;
+ float **in = (float **)(args+2);
+ int i;
+ for (i=0; i<x->x_chans; i++) in[i] = sp[i]->s_vec;
+ dsp_addv(rawout_perform, nargs, args);
+}
+
+static t_int *rawout_perform(t_int *w)
{
- x->x_type = pdp_gensym(type->s_name);
+ DSP_ARG(t_rawout*, x, w[1]);
+ DSP_ARG(t_int, n, w[2]);
+ DSP_ARG(t_float**, in, &w[3]);
+
+ short int *out;
+ int i,c,k;
+
+
+ if (x->x_queue->elements >= x->x_max_queuesize){
+ // drop
+ if (x->x_verbose && x->x_active) pdp_post_n(".");
+ }
+ else {
+
+ // create packet
+ if (x->x_countdown) {
+ out = x->x_needle;
+ }
+ else {
+ int p = pdp_factory_newpacket(x->x_tmptype);
+ pdp_packet_mark_unused(x->x_packet);
+ // if (-1 == p) pdp_post("pdp_rawout~: can't create packet");
+ x->x_needle = out = (short int *)pdp_packet_data(p);
+ x->x_packet = p;
+ x->x_countdown = pdp_packet_data_size(p) / 2;
+ }
+
+ //pdp_post("data size = %d bytes", pdp_packet_data_size(p));
+
+ //memset(out, 0, pdp_packet_data_size(p));
+
+
+ // convert & interleave
+ for (k=0,i=0; i<n; i++){
+ for (c=0; c<x->x_chans; c++,k++){
+ float val = (in[c])[i];
+ val *= (float)((1<<15)-1);
+ out[k] = (short int)(val);
+ //out[k] = 0x1234;
+ //fprintf(stderr, "(%d,%d,%d) %d\n", c, i, k, (int)out[k]);
+ }
+ }
+
+ x->x_needle += k;
+ x->x_countdown -= k;
+ if (!x->x_countdown){
+ // transfer
+ lock(x);
+ pdp_list_add_back(x->x_queue, a_packet, (t_pdp_word)x->x_packet);
+ x->x_packet = -1;
+ unlock(x);
+ }
+ }
+
+ return w+3+x->x_chans;
}
-static void rawout_open(t_rawout *x, t_symbol *pipe)
+
+/* PACKET INPUT */
+
+
+static void pdp_in(t_rawout *x, t_symbol *s, t_float f)
+{
+ /* save packet to pdp queue, if size is smaller than maxsize */
+ if (s == S_REGISTER_RO){
+ if (x->x_queue->elements < x->x_max_queuesize){
+ int p = (int)f;
+ p = pdp_packet_copy_ro(p);
+ if (p != -1){
+ lock(x);
+ pdp_list_add_back(x->x_queue, a_packet, (t_pdp_word)p);
+ unlock(x);
+ }
+ }
+ else {
+ //pdp_post("pdp_rawout: dropping packet: (queue full)", x->x_max_queuesize);
+ if (x->x_active && x->x_verbose) pdp_post_n(".");
+ }
+
+ }
+
+ /* check if thread is done */
+ if (x->x_done) rawout_close(x);
+
+}
+
+/* CONTROL */
+
+//static void rawout_type(t_rawout *x, t_symbol *type)
+//{
+ //x->x_type = pdp_gensym(type->s_name);
+//}
+
+static void clear_queue(t_rawout *x);
+static void rawout_open(t_rawout *x, t_symbol *spipe)
{
/* save pipe name if not empty */
- if (pipe->s_name[0]) {x->x_pipe = pipe;}
+ if (spipe->s_name[0]) {x->x_pipe = spipe;}
if (x->x_active) {
pdp_post("already open");
@@ -227,67 +358,133 @@ static void rawout_open(t_rawout *x, t_symbol *pipe)
/* start thread */
x->x_giveup = 0;
x->x_done = 0;
+ clear_queue(x);
pthread_create(&x->x_thread, &x->x_attr, rawout_thread , x);
x->x_active = 1;
}
-static void rawout_close(t_rawout *x)
-{
-
+static void rawout_stopthread(t_rawout *x){
if (!x->x_active) return;
/* stop thread: set giveup + wait */
x->x_giveup = 1;
pthread_join(x->x_thread, NULL);
x->x_active = 0;
+ clear_queue(x);
+}
+
+static void rawout_close(t_rawout *x)
+{
+ if (!x->x_active) return;
+ rawout_stopthread(x);
/* notify */
outlet_bang(x->x_sync_outlet);
- pdp_post("connection to %s closed", x->x_pipe->s_name);
-
+ pdp_post("pdp_rawout: closed %s", x->x_pipe->s_name);
+}
+static void rawout_verbose(t_rawout *x, t_float fverbose){
+ x->x_verbose = (int)fverbose;
+}
+static void rawout_tick(t_rawout *x){
+ if (x->x_done) rawout_close(x);
+ clock_delay(x->x_clock, x->x_deltime);
+}
-
+static void clear_queue(t_rawout *x){
+ lock(x);
+ while(x->x_queue->elements){
+ pdp_packet_mark_unused(pdp_list_pop(x->x_queue).w_packet);
+ }
+ unlock(x);
+}
+
+#define MAXINT (0x80 << ((sizeof(int)-1)*8))
+static void rawout_queuesize(t_rawout *x, t_float fbufsize){
+ int bufsize = (int)fbufsize;
+ if (fbufsize < 1) fbufsize = MAXINT;
+ x->x_max_queuesize = bufsize;
}
static void rawout_free(t_rawout *x)
{
- rawout_close(x);
- pdp_tree_strip_packets(x->x_queue);
+ // terminate thread
+ rawout_stopthread(x);
+
+ // cleanup
+ clock_unset(x->x_clock);
+ clear_queue(x);
pdp_tree_free(x->x_queue);
+ pdp_packet_mark_unused(x->x_packet);
}
t_class *rawout_class;
+t_class *rawout_dsp_class;
-
-static void *rawout_new(t_symbol *pipe, t_symbol *type)
-{
- t_rawout *x;
-
- pdp_post("%s %s", pipe->s_name, type->s_name);
-
- /* allocate & init */
- x = (t_rawout *)pd_new(rawout_class);
+// shared stuff
+static void rawout_init(t_rawout *x, t_symbol *spipe){
//x->x_outlet = outlet_new(&x->x_obj, &s_anything);
x->x_sync_outlet = outlet_new(&x->x_obj, &s_anything);
x->x_queue = pdp_list_new(0);
x->x_active = 0;
x->x_giveup = 0;
x->x_done = 0;
- x->x_type = pdp_gensym("image/YCrCb/320x240"); //default
+ x->x_packet = -1;
+ x->x_countdown = 0;
+ x->x_max_queuesize = DEF_QUEUESIZE;
+ //x->x_type = pdp_gensym("image/YCrCb/320x240"); //default
x->x_pipe = gensym("/tmp/pdpraw"); // default
+ x->x_deltime = POLLTIME;
+ x->x_clock = clock_new(x, (t_method)rawout_tick);
pthread_attr_init(&x->x_attr);
pthread_mutex_init(&x->x_mut, NULL);
/* args */
- rawout_type(x, type);
- if (pipe->s_name[0]) x->x_pipe = pipe;
+ //rawout_type(x, type);
+ if (spipe && spipe->s_name[0]) x->x_pipe = spipe;
+ rawout_tick(x);
+ rawout_verbose(x,0);
+}
+// [pdp_rawout]
+static void *rawout_new(t_symbol *spipe /* , t_symbol *type */)
+{
+ t_rawout *x;
+ /* allocate & init */
+ x = (t_rawout *)pd_new(rawout_class);
+ rawout_init(x, spipe);
return (void *)x;
}
+// [pdp_rawout~]
+
+
+// HUH??? why do i get the symbol first, then the float????
+// see http://lists.puredata.info/pipermail/pd-dev/2003-09/001618.html
+//static void *rawout_dsp_new(t_float fchans, t_symbol *spipe){
+static void *rawout_dsp_new(t_symbol *spipe, t_float fchans){
+ int chans = (int)fchans;
+ if (chans < 1) chans = 1;
+ if (chans > 64) return 0; // this is just a safety measure
+
+ t_rawout *x = (t_rawout *)pd_new(rawout_dsp_class);
+ rawout_init(x, spipe);
+
+ // hack: temp packet
+ char temp_packet[1024];
+ sprintf(temp_packet, "image/grey/256x%d", 8 * chans);
+ pdp_post("pdp_rawout: using fake packet %s", temp_packet);
+ x->x_tmptype = pdp_gensym(temp_packet);
+
+ // create audio inlets
+ x->x_chans = chans;
+ while (--chans) inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("signal"), gensym("signal"));
+
+ return (void *)x;
+}
+
#ifdef __cplusplus
@@ -296,25 +493,46 @@ extern "C"
#endif
-void pdp_rawout_setup(void)
-{
+
+#define COMMON(base_class)\
+ class_addmethod(base_class, (t_method)rawout_open, gensym("open"), A_DEFSYMBOL, A_NULL);\
+ class_addmethod(base_class, (t_method)rawout_close, gensym("close"), A_NULL);\
+ class_addmethod(base_class, (t_method)rawout_verbose, gensym("verbose"), A_FLOAT, A_NULL);\
+ class_addmethod(base_class, (t_method)rawout_queuesize, gensym("bufsize"), A_FLOAT, A_NULL);
+
+void pdp_rawout_setup(void){
+
int i;
+ /* PACKETS */
+
/* create a standard pd class: [pdp_rawout pipe type] */
rawout_class = class_new(gensym("pdp_rawout"), (t_newmethod)rawout_new,
- (t_method)rawout_free, sizeof(t_rawout), 0, A_DEFSYMBOL, A_DEFSYMBOL, A_NULL);
+ (t_method)rawout_free, sizeof(t_rawout), 0, A_DEFSYMBOL, A_NULL);
/* add global message handler */
- class_addmethod(rawout_class, (t_method)pdp_in,
- gensym("pdp"), A_SYMBOL, A_FLOAT, A_NULL);
+ class_addmethod(rawout_class, (t_method)pdp_in, gensym("pdp"), A_SYMBOL, A_FLOAT, A_NULL);
+ COMMON(rawout_class);
+
+ /* DSP */
- class_addmethod(rawout_class, (t_method)rawout_type, gensym("type"), A_SYMBOL, A_NULL);
- class_addmethod(rawout_class, (t_method)rawout_open, gensym("open"), A_DEFSYMBOL, A_NULL);
- class_addmethod(rawout_class, (t_method)rawout_close, gensym("close"), A_NULL);
+ /* create a standard pd class: [pdp_rawout pipe type] */
+ rawout_dsp_class = class_new(gensym("pdp_rawout~"), (t_newmethod)rawout_dsp_new,
+ (t_method)rawout_free, sizeof(t_rawout), 0, A_DEFFLOAT, A_DEFSYMBOL, A_NULL);
+ /* add signal input */
+ CLASS_MAINSIGNALIN(rawout_dsp_class, t_rawout, x_f);
+ class_addmethod(rawout_dsp_class, (t_method)rawout_dsp, gensym("dsp"), 0);
+ COMMON(rawout_dsp_class);
}
+
+
+
+
+
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/image_basic/pdp_cheby.c b/modules/image_basic/pdp_cheby.c
index 1bd1a16..6d382ad 100644
--- a/modules/image_basic/pdp_cheby.c
+++ b/modules/image_basic/pdp_cheby.c
@@ -44,14 +44,14 @@ typedef struct pdp_cheby_struct
static double pdp_cheby_mappingfunction(double f, void *params)
{
t_pdp_cheby *x = (t_pdp_cheby *)params;
- int index;
+ int indx;
/* if there's no array, return the identity function */
if (!x->x_vec) return f;
/* else interpolate the array */
- index = ((f + 1) * 0.5) * (x->x_nbpoints - 1);
- return x->x_vec[index];
+ indx = ((f + 1) * 0.5) * (x->x_nbpoints - 1);
+ return x->x_vec[indx];
}
diff --git a/modules/image_io/pdp_glx.c b/modules/image_io/pdp_glx.c
index 1df127f..d454de9 100644
--- a/modules/image_io/pdp_glx.c
+++ b/modules/image_io/pdp_glx.c
@@ -72,6 +72,7 @@ typedef struct pdp_glx_struct
int x_initialized;
int x_autocreate;
+ int x_interpol;
} t_pdp_glx;
@@ -375,8 +376,17 @@ static void pdp_glx_display_texture(t_pdp_glx *x)
glBindTexture(GL_TEXTURE_2D, x->x_texture);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+
+ if (x->x_interpol){
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
+ }
+
+
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
/* display texture */
@@ -485,6 +495,9 @@ static void pdp_glx_display(t_pdp_glx *x, t_symbol *s)
}
}
+static void pdp_glx_interpol(t_pdp_glx *x, t_float finterpol){
+ x->x_interpol = (int)finterpol;
+}
static void pdp_glx_free(t_pdp_glx *x)
@@ -525,6 +538,8 @@ void *pdp_glx_new(void)
x->x_tex_width = 64;
x->x_tex_height = 64;
+ x->x_interpol = 1;
+
//pdp_glx_create(x);
return (void *)x;
@@ -563,6 +578,7 @@ void pdp_glx_setup(void)
class_addmethod(pdp_glx_class, (t_method)pdp_glx_cursor, gensym("cursor"), A_FLOAT, A_NULL);
class_addmethod(pdp_glx_class, (t_method)pdp_glx_fullscreen, gensym("fullscreen"), A_NULL);
class_addmethod(pdp_glx_class, (t_method)pdp_glx_moveresize, gensym("posdim"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
+ class_addmethod(pdp_glx_class, (t_method)pdp_glx_interpol, gensym("interpol"), A_FLOAT, A_NULL);
class_addmethod(pdp_glx_class, (t_method)pdp_glx_tile, gensym("tile"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
diff --git a/modules/image_io/pdp_qt.c b/modules/image_io/pdp_qt.c
index 5e1111c..7c8d415 100644
--- a/modules/image_io/pdp_qt.c
+++ b/modules/image_io/pdp_qt.c
@@ -19,8 +19,10 @@
*/
-#include <quicktime/lqt.h>
-#include <quicktime/colormodels.h>
+//#include <quicktime/lqt.h>
+//#include <quicktime/colormodels.h>
+#include <lqt/lqt.h>
+#include <lqt/colormodels.h>
#include "pdp.h"
#include "pdp_llconv.h"
diff --git a/modules/image_io/pdp_v4l.c b/modules/image_io/pdp_v4l.c
index 85c34f1..7f16842 100644
--- a/modules/image_io/pdp_v4l.c
+++ b/modules/image_io/pdp_v4l.c
@@ -184,6 +184,18 @@ static void pdp_v4l_close_error(t_pdp_v4l *x)
if(x->x_open_retry) x->x_open_retry--;
}
+static void pdp_v4l_pwc_agc(t_pdp_v4l *x, float gain){
+ gain *= (float)(1<<16);
+ int g = (int)gain;
+ if (g < 0) g = -1; // automatic
+ if (g > 1<<16) g = 1<<16 - 1; // fixed
+
+ //post("pdp_v4l: setting agc to %d", g);
+ if (ioctl(x->x_tvfd, VIDIOCPWCSAGC, &g)){
+ post("pdp_v4l: pwc: VIDIOCPWCSAGC");
+ //goto closit;
+ }
+}
static void pdp_v4l_pwc_init(t_pdp_v4l *x)
{
@@ -206,10 +218,21 @@ static void pdp_v4l_pwc_init(t_pdp_v4l *x)
post("pdp_v4l: detected pwc");
+
if(ioctl(x->x_tvfd, VIDIOCPWCRUSER)){
perror("pdp_v4l: pwc: VIDIOCPWCRUSER");
goto closit;
}
+
+ /* this is a workaround:
+ we disable AGC after restoring user prefs
+ something is wrong with newer cams (like Qickcam 4000 pro)
+ */
+
+ if (1){
+ pdp_v4l_pwc_agc(x, 1.0);
+ }
+
if (ioctl(x->x_tvfd, VIDIOCGWIN, &x->x_vwin)){
perror("pdp_v4l: pwc: VIDIOCGWIN");
@@ -824,6 +847,7 @@ void pdp_v4l_setup(void)
class_addmethod(pdp_v4l_class, (t_method)pdp_v4l_dim, gensym("dim"), A_FLOAT, A_FLOAT, A_NULL);
class_addmethod(pdp_v4l_class, (t_method)pdp_v4l_freq, gensym("freq"), A_FLOAT, A_NULL);
class_addmethod(pdp_v4l_class, (t_method)pdp_v4l_freqMHz, gensym("freqMHz"), A_FLOAT, A_NULL);
+ class_addmethod(pdp_v4l_class, (t_method)pdp_v4l_pwc_agc, gensym("gain"), A_FLOAT, A_NULL);
class_addmethod(pdp_v4l_class, (t_method)pdp_v4l_format, gensym("captureformat"), A_SYMBOL, A_NULL);
diff --git a/modules/image_io/pdp_xv.c b/modules/image_io/pdp_xv.c
index 93383fd..2faabd4 100644
--- a/modules/image_io/pdp_xv.c
+++ b/modules/image_io/pdp_xv.c
@@ -153,6 +153,7 @@ static void pdp_xv_bang_thread(t_pdp_xv *x)
static void pdp_xv_bang_callback(t_pdp_xv *x)
{
+
/* receive events + send to outputs */
t_pdp_list *eventlist = pdp_xwindow_get_eventlist(x->x_xwin);
t_pdp_atom *a;
diff --git a/opengl/Makefile b/opengl/Makefile
index d62358e..b0b3027 100644
--- a/opengl/Makefile
+++ b/opengl/Makefile
@@ -24,4 +24,21 @@ pdp_opengl.pd_linux: subdirs
pdp_opengl.pd_darwin: subdirs
rm -f pdp_opengl.pd_linux
- $(CC) -o pdp_opengl.pd_pd_darwin modules/*.o system/*.o $(LDFLAGS) -g -bundle -bundle_loader $(PD_EXECUTABLE)
+ $(CC) -o pdp_opengl.pd_pd_darwin ../modules/*/*.o ../system/pdp.o ../system/*/*.o ../puredata/*.o modules/*.o system/*.o $(PDP_LIBS) -bundle -undefined error -twolevel_namespace -bundle_loader $(PD_EXECUTABLE)
+
+
+# $(CC) -o pdp_opengl.pd_pd_darwin modules/*.o system/*.o $(LDFLAGS) -g -dynamic -bundle -flat_namespace -undefined suppress
+# $(CC) -o pdp_opengl.pd_pd_darwin modules/*.o system/*.o $(LDFLAGS) -g -bundle -bundle_loader $(PD_EXECUTABLE)
+
+install: all
+ test -d $(prefix)/lib/pd #check if pd is installed. if this fails make install will stop here.
+ install -d $(prefix)/lib/pd/extra
+ install -m 755 $(PDP_OPENGL_LIBRARY_NAME) $(prefix)/lib/pd/extra
+ install -m 644 abstractions/*.pd $(prefix)/lib/pd/extra
+ install -m 644 doc/objects/*.pd $(prefix)/lib/pd/doc/5.reference
+ install -m 755 -d $(prefix)/lib/pd/doc/pdp
+ install -m 755 -d $(prefix)/lib/pd/doc/pdp/introduction
+ install -m 755 -d $(prefix)/lib/pd/doc/pdp/examples_opengl
+ install -m 644 doc/reference_opengl.txt $(prefix)/lib/pd/doc/pdp
+ install -m 644 doc/examples/*.pd $(prefix)/lib/pd/doc/pdp/examples_opengl
+
diff --git a/opengl/Makefile.config b/opengl/Makefile.config
index 4e59a4c..203420c 100644
--- a/opengl/Makefile.config
+++ b/opengl/Makefile.config
@@ -1,18 +1,25 @@
-PD_DIR = /home/tom/pd/distro/pd/src
-PDP_DIR = /home/tom/pd/packet/include
-PDP_OGL_DIR = /home/tom/pd/packet/opengl/include
+prefix = /usr/local
+
+PDP_VERSION=0.12.5-darcs
+PDP_DIR = ../../include
+PDP_OGL_DIR = ../include
CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
-Wall -W -Wstrict-prototypes -Werror \
-Wno-unused -Wno-parentheses -Wno-switch -g
-CPPFLAGS = -I$(PD_DIR) -I$(PDP_DIR) -I$(PDP_OGL_DIR) -I/usr/X11R6/include
+
+CPPFLAGS = -I$(PDP_DIR) -I$(PDP_OGL_DIR) -I/usr/X11R6/include -DPDP_VERSION=\"$(PDP_VERSION)\"
+# CPPFLAGS = -I$(PD_DIR) -I$(PDP_DIR) -I$(PDP_OGL_DIR) -I/usr/X11R6/include
+
LDFLAGS = -lGL -lglut
TARGET=linux
+PDP_OPENGL_LIBRARY_NAME=pdp_opengl.pd_$(TARGET)
+
#uncomment these for darwin:
#TARGET=darwin
#CPPFLAGS+=-I/sw/include
diff --git a/opengl/modules/pdp_3d_draw.c b/opengl/modules/pdp_3d_draw.c
index 39434cb..a47db71 100644
--- a/opengl/modules/pdp_3d_draw.c
+++ b/opengl/modules/pdp_3d_draw.c
@@ -20,7 +20,8 @@
//#include "GL/gl.h"
-#include <GL/glut.h>
+//#include <GL/glut.h>
+#include <GL/glu.h>
#include <math.h>
#include "pdp_opengl.h"
@@ -162,16 +163,23 @@ static void draw_wtriangle(t_drawcommand *x)
static void draw_wcube(t_drawcommand *x)
{
- glutWireCube(x->x_p0);
+ x->x_p1 = x->x_p0; // set square z coord;
+ glPushMatrix();
+ draw_wsquare(x);
+ glRotatef(90, 0,1,0);
+ draw_wsquare(x);
+ glRotatef(90, 0,1,0);
+ draw_wsquare(x);
+ glRotatef(90, 0,1,0);
+ draw_wsquare(x);
+ glPopMatrix();
+
}
static void draw_cube(t_drawcommand *x)
{
x->x_p1 = x->x_p0; // set square z coord;
- //glutSolidCube(x->x_p0);
-
- //glMatrixMode(GL_MODELVIEW);
glPushMatrix();
draw_square(x);
glRotatef(90, 0,1,0);
@@ -201,7 +209,7 @@ static void draw_wtorus(t_drawcommand *x)
if (n < 1) n = 20;
if (m < 1) m = n;
- glutWireTorus(ri, ro, n, m);
+ // glutWireTorus(ri, ro, n, m);
}
@@ -215,7 +223,7 @@ static void draw_torus(t_drawcommand *x)
if (n < 1) n = 20;
if (m < 1) m = n;
- glutSolidTorus(ri, ro, n, m);
+ // glutSolidTorus(ri, ro, n, m);
}
@@ -229,7 +237,7 @@ static void draw_cone(t_drawcommand *x)
if (n < 1) n = 20;
if (m < 1) m = n;
- glutSolidCone(base, height, n, m);
+ // glutSolidCone(base, height, n, m);
}
@@ -243,21 +251,21 @@ static void draw_wcone(t_drawcommand *x)
if (n < 1) n = 20;
if (m < 1) m = n;
- glutWireCone(base, height, n, m);
+ // glutWireCone(base, height, n, m);
}
static void draw_wteapot(t_drawcommand *x)
{
float f = x->x_p0;
- glutWireTeapot(f);
+ // glutWireTeapot(f);
}
static void draw_teapot(t_drawcommand *x)
{
float f = x->x_p0;
- glutSolidTeapot(f);
+ // glutSolidTeapot(f);
}
@@ -270,7 +278,7 @@ static void draw_wsphere(t_drawcommand *x)
if (n < 1) n = 20;
if (m < 1) m = n;
- glutWireSphere(f, n, m);
+ // glutWireSphere(f, n, m);
}
@@ -289,15 +297,15 @@ static void draw_sphere(t_drawcommand *x)
}
-static void draw_dodeca(t_drawcommand *x){glutSolidDodecahedron();}
-static void draw_octa(t_drawcommand *x) {glutSolidOctahedron();}
-static void draw_tetra(t_drawcommand *x) {glutSolidTetrahedron();}
-static void draw_icosa(t_drawcommand *x) {glutSolidIcosahedron();}
+static void draw_dodeca(t_drawcommand *x){ /* glutSolidDodecahedron(); */ }
+static void draw_octa(t_drawcommand *x) { /* glutSolidOctahedron(); */ }
+static void draw_tetra(t_drawcommand *x) { /* glutSolidTetrahedron(); */ }
+static void draw_icosa(t_drawcommand *x) { /* glutSolidIcosahedron(); */ }
-static void draw_wdodeca(t_drawcommand *x){glutWireDodecahedron();}
-static void draw_wocta(t_drawcommand *x) {glutWireOctahedron();}
-static void draw_wtetra(t_drawcommand *x) {glutWireTetrahedron();}
-static void draw_wicosa(t_drawcommand *x) {glutWireIcosahedron();}
+static void draw_wdodeca(t_drawcommand *x){ /* glutWireDodecahedron(); */ }
+static void draw_wocta(t_drawcommand *x) { /* glutWireOctahedron(); */ }
+static void draw_wtetra(t_drawcommand *x) { /* glutWireTetrahedron(); */ }
+static void draw_wicosa(t_drawcommand *x) { /* glutWireIcosahedron(); */ }
diff --git a/opengl/system/pdp_3Dcontext_common.c b/opengl/system/pdp_3Dcontext_common.c
index 185e2be..86f5657 100644
--- a/opengl/system/pdp_3Dcontext_common.c
+++ b/opengl/system/pdp_3Dcontext_common.c
@@ -28,9 +28,7 @@
#include "pdp_3Dcontext.h"
#include <GL/gl.h>
-//#include <GL/glx.h>
#include <GL/glu.h>
-//#include <GL/glut.h>
#define D if (0)
diff --git a/opengl/system/pdp_3Dcontext_glx.c b/opengl/system/pdp_3Dcontext_glx.c
index ac25a13..f124686 100644
--- a/opengl/system/pdp_3Dcontext_glx.c
+++ b/opengl/system/pdp_3Dcontext_glx.c
@@ -28,7 +28,6 @@
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
-//#include <GL/glut.h>
/* all symbols are C-style */
#ifdef __cplusplus
diff --git a/opengl/system/pdp_opengl.c b/opengl/system/pdp_opengl.c
index 541af75..c8ede29 100644
--- a/opengl/system/pdp_opengl.c
+++ b/opengl/system/pdp_opengl.c
@@ -56,6 +56,7 @@ static void pdp_control_thread(void *x, t_symbol *s, int argc, t_atom *argv)
}
+
/* kernel setup */
void pdp_opengl_system_setup(void)
{
@@ -68,6 +69,7 @@ void pdp_opengl_system_setup(void)
/* add pdp_control method for thread */
pdp_control_addmethod((t_method)pdp_control_thread, gensym("3dthread"));
+
}
t_pdp_procqueue* pdp_opengl_get_queue(void){return (&_3dp_queue);}
diff --git a/opengl/system/setup.c b/opengl/system/setup.c
index 18d267a..5b40c1b 100644
--- a/opengl/system/setup.c
+++ b/opengl/system/setup.c
@@ -46,10 +46,15 @@ void pdp_3d_subcontext_setup(void);
//#define D(x) { pdp_post_n( #x ".." ); x; pdp_post("done"); }
#define D(x) x
+
+void pdp_setup(void);
void pdp_opengl_setup(void)
{
int i;
- post("PDP: pdp_opengl extension library");
+
+ pdp_setup();
+
+ post("PDP: opengl extensions version " PDP_VERSION);
/* setup system */
D(pdp_opengl_system_setup());
diff --git a/puredata/pdp_comm.c b/puredata/pdp_comm.c
index 4c67659..2674e36 100644
--- a/puredata/pdp_comm.c
+++ b/puredata/pdp_comm.c
@@ -116,12 +116,16 @@ void
pdp_packet_pass_if_valid(t_outlet *outlet, int *packet_ptr)
{
+
+
t_pdp *header = pdp_packet_header(*packet_ptr);
if (header){
+
/* send register phase */
outlet_pdp_register(outlet, *packet_ptr);
+
/* unregister */
pdp_packet_mark_unused(*packet_ptr);
*packet_ptr = -1;
@@ -129,7 +133,9 @@ pdp_packet_pass_if_valid(t_outlet *outlet, int *packet_ptr)
/* send process phase */
outlet_pdp_process(outlet);
+
}
+
}
void
@@ -317,7 +323,7 @@ void pd_atom_to_pdp_atom(t_atom *pdatom, t_pdp_atom *pdpatom)
}
}
-
+#if PDP_SYMBOL_HACK
/* some "accelerated" pd symbols */
t_symbol s_pdp = {"pdp", 0, 0};
@@ -329,6 +335,8 @@ t_symbol s_inspect = {"inspect", 0, 0};
t_symbol s_accumulate = {"accumulate", 0, 0};
t_symbol s_chanmask = {"chanmask", 0, 0};
+
+
// internal pd method
t_symbol *dogensym(char *s, t_symbol *oldsym);
static void _addsym(t_symbol *s)
@@ -345,6 +353,7 @@ static void _addsym(t_symbol *s)
}
}
+
void
pdp_pdsym_setup(void)
{
@@ -360,6 +369,12 @@ pdp_pdsym_setup(void)
}
+#else
+
+void pdp_pdsym_setup(void){
+}
+
+#endif
#ifdef __cplusplus
diff --git a/puredata/pdp_queue.c b/puredata/pdp_queue.c
index b66289a..f5a9d65 100644
--- a/puredata/pdp_queue.c
+++ b/puredata/pdp_queue.c
@@ -79,10 +79,10 @@ void pdp_procqueue_wait(t_pdp_procqueue *q)
D post("pdp_procqueue_wait(%x): pdp_procqueue_thread has finished processing", q);
}
-void pdp_procqueue_finish(t_pdp_procqueue *q, int index)
+void pdp_procqueue_finish(t_pdp_procqueue *q, int indx)
{
- if (-1 == index) {
+ if (-1 == indx) {
//post("pdp_pq_remove: index == -1");
return;
}
@@ -90,8 +90,8 @@ void pdp_procqueue_finish(t_pdp_procqueue *q, int index)
pdp_procqueue_wait(q);
/* invalidate callback at index */
- q->q[index & q->mask].x_callback = 0;
- q->q[index & q->mask].x_queue_id = 0;
+ q->q[indx & q->mask].x_callback = 0;
+ q->q[indx & q->mask].x_queue_id = 0;
}
@@ -364,7 +364,7 @@ t_pdp_procqueue *pdp_queue_get_queue(void){return &pdp_queue;}
#if 1
/* default pdp queue shortcut methods */
void pdp_queue_wait() {pdp_procqueue_wait(&pdp_queue);}
-void pdp_queue_finish(int index) { pdp_procqueue_finish(&pdp_queue, index);}
+void pdp_queue_finish(int indx) { pdp_procqueue_finish(&pdp_queue, indx);}
void pdp_queue_add(void *owner, void *process, void *callback, int *queue_id) {
pdp_procqueue_add(&pdp_queue, owner, process, callback, queue_id);
}
diff --git a/scaf/Makefile b/scaf/Makefile
index d9af670..a75695c 100644
--- a/scaf/Makefile
+++ b/scaf/Makefile
@@ -39,5 +39,5 @@ install: all
#Check if pd is installed in $(prefix)/lib/pd.
#If this fails the pdp_scaf lib and the docs won't be installed.
test -d $(prefix)/lib/pd
- install -m 755 pdp_scaf.pd_linux $(prefix)/lib/pd/externs
+ install -m 755 pdp_scaf.pd_linux $(prefix)/lib/pd/extra
install -m 644 doc/*.pd $(prefix)/lib/pd/doc/5.reference
diff --git a/scaf/Makefile.config b/scaf/Makefile.config
index 4faea70..4ddb31c 100644
--- a/scaf/Makefile.config
+++ b/scaf/Makefile.config
@@ -6,13 +6,13 @@
prefix=/usr/local
-PDP_CA_INCLUDE = -I/home/tom/pd/packet/include -I/home/tom/pd/packet/scaf/include
+PDP_CA_INCLUDE = -I/usr/local/include/pdp -I/home/tom/pdcvs/externals/pdp/scaf/include
PDP_CA_LIBS = -ldl -lm
DEFAULT_RULES_LIB = /usr/local/lib/scaf/default.scafo
PDP_CA_AFLAGS =
#--gstabs
PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
- -Wall -W -Wstrict-prototypes -Werror \
+ -Wall -W -Wstrict-prototypes -I../include -I../../include \
-Wno-unused -Wno-parentheses -Wno-switch -g $(PDP_CFLAGS) $(PD_CFLAGS) \
-DPDP_CA_RULES_LIB=\"$(DEFAULT_RULES_LIB)\"
# -Wshadow
diff --git a/scaf/Makefile.config.in b/scaf/Makefile.config.in
index 12927d3..6515eaf 100644
--- a/scaf/Makefile.config.in
+++ b/scaf/Makefile.config.in
@@ -12,7 +12,7 @@ DEFAULT_RULES_LIB = @DEFAULT_RULES_LIB@
PDP_CA_AFLAGS =
#--gstabs
PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
- -Wall -W -Wstrict-prototypes -Werror \
+ -Wall -W -Wstrict-prototypes -I../include -I../../include \
-Wno-unused -Wno-parentheses -Wno-switch -g $(PDP_CFLAGS) $(PD_CFLAGS) \
-DPDP_CA_RULES_LIB=\"$(DEFAULT_RULES_LIB)\"
# -Wshadow
diff --git a/scaf/pdp/pdp_ca_system.c b/scaf/pdp/pdp_ca_system.c
index acbab34..2ecf43c 100644
--- a/scaf/pdp/pdp_ca_system.c
+++ b/scaf/pdp/pdp_ca_system.c
@@ -296,7 +296,7 @@ void pdp_scaf_setup(void)
t_pdp_conversion_program *program;
/* babble */
- post ("PDP: pdp_scaf extension library");
+ post ("PDP: cellular automata extension library");
/* setup modules */
pdp_ca_setup();
diff --git a/system/image/pdp_imageproc_portable.c b/system/image/pdp_imageproc_portable.c
index 112f729..facb2c8 100644
--- a/system/image/pdp_imageproc_portable.c
+++ b/system/image/pdp_imageproc_portable.c
@@ -494,7 +494,7 @@ void pdp_imageproc_random_setseed(void *x, float seed)
void pdp_imageproc_random_process(void *x, u32 width, u32 height, short int *image)
{
- s32 *d = (u32 *)x;
+ u32 *d = (u32 *)x;
u32 i;
s32 r;
srandom(d[0]);
@@ -586,8 +586,8 @@ void pdp_imageproc_resample_affinemap_process(void *x, u32 width, u32 height, s1
double s = sin(angle);
/* affine x, y mappings in screen coordinates */
- double mapx(double x, double y){return cx + izx * ( c * (x-cx) + s * (y-cy));}
- double mapy(double x, double y){return cy + izy * (-s * (x-cx) + c * (y-cy));}
+ double mapx(double _x, double _y){return cx + izx * ( c * (_x-cx) + s * (_y-cy));}
+ double mapy(double _x, double _y){return cy + izy * (-s * (_x-cx) + c * (_y-cy));}
u32 colstate_x = (u32)(scalew * mapx(0,0));
u32 colstate_y = (u32)(scaleh * mapy(0,0));
diff --git a/system/kernel/pdp_list.c b/system/kernel/pdp_list.c
index deeb7f1..8558e35 100644
--- a/system/kernel/pdp_list.c
+++ b/system/kernel/pdp_list.c
@@ -760,10 +760,10 @@ void pdp_list_pop_push(t_pdp_list *source, t_pdp_list *dest)
/* return element at index */
-t_pdp_word pdp_list_index(t_pdp_list *l, int index)
+t_pdp_word pdp_list_index(t_pdp_list *l, int indx)
{
t_pdp_atom *a;
- for (a = l->first; index--; a = a->next);
+ for (a = l->first; indx--; a = a->next);
return a->w;
}
diff --git a/system/kernel/pdp_mem.c b/system/kernel/pdp_mem.c
index 33822ef..93c7122 100644
--- a/system/kernel/pdp_mem.c
+++ b/system/kernel/pdp_mem.c
@@ -19,9 +19,14 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include "pdp_mem.h"
#include "pdp_debug.h"
+// defined here so we don't need to rebuild when changing it (deps for headers are broken)
+#define PDP_FASTALLOC_BLOCK_ELEMENTS 4096
+//#define PDP_FASTALLOC_BLOCK_ELEMENTS 1
+#define D if (0)
/* malloc wrapper that calls garbage collector */
void *pdp_alloc(int size)
@@ -30,6 +35,8 @@ void *pdp_alloc(int size)
PDP_ASSERT(ptr);
+ D fprintf(stderr, "alloc %p %d\n", ptr, size);
+
return ptr;
//TODO: REPAIR THIS
@@ -41,6 +48,7 @@ void *pdp_alloc(int size)
void pdp_dealloc(void *stuff)
{
+ D fprintf(stderr, "dealloc %p\n", stuff);
free (stuff);
}
@@ -87,6 +95,10 @@ static void _pdp_fastalloc_refill_freelist(t_pdp_fastalloc *x)
}
+#define USE_FASTALLOC 1
+
+#if USE_FASTALLOC
+
void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x)
{
t_fastalloc *atom;
@@ -127,3 +139,10 @@ t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size)
return x;
}
+#else
+
+void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x) {return pdp_alloc(12);}
+void pdp_fastalloc_save_atom(t_pdp_fastalloc *x, void *atom) {pdp_dealloc(atom);}
+t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size) {return 0;}
+
+#endif
diff --git a/system/kernel/pdp_packet.c b/system/kernel/pdp_packet.c
index 0eb569a..e5f1a1f 100644
--- a/system/kernel/pdp_packet.c
+++ b/system/kernel/pdp_packet.c
@@ -32,6 +32,8 @@
#include "pdp_debug.h"
+#define D if(0)
+
/* packet implementation. contains class and packet (instance) handling
some notes on packet operations.
@@ -152,6 +154,7 @@ int pdp_factory_newpacket(t_pdp_symbol *type)
/* call class constructor */
while(a){
+ D pdp_post("new: %s", type->s_name);
c = (t_pdp_class *)(a->w.w_pointer);
if (c->type && pdp_type_description_match(type, c->type)){
//pdp_post("method %x, type %s", c->create, type->s_name);
@@ -287,6 +290,15 @@ pdp_packet_create(unsigned int datatype, unsigned int datasize /*without header*
*/
+/* NEW DOES NOT USE THE REUSE FIFO !!!!
+ this is a true and genuine mess:
+ the reuse fifo can grow indefinitely with garbage elements if it's never used,
+ while it points to stale packets.. backdoor access = BAD.
+
+ if i recall, this is mainly a compatibility issue..
+
+*/
+
int
pdp_packet_new(unsigned int datatype, unsigned int datasize)
{
@@ -327,6 +339,9 @@ pdp_packet_new(unsigned int datatype, unsigned int datasize)
void
_pdp_packet_save_nolock(int packet)
{
+
+
+
t_pdp *header = pdp_packet_header(packet);
t_pdp_symbol *s;
PDP_ASSERT(header);
@@ -334,7 +349,30 @@ _pdp_packet_save_nolock(int packet)
PDP_ASSERT(header->desc);
s = header->desc;
if (!s->s_reusefifo) s->s_reusefifo = pdp_list_new(0);
+
+
+ /* big o hack: since pdp_packet_new can reap packets behind our back,
+ we won't add a packet if it's already in here */
+
+ if (1) {
+ t_pdp_atom *a = s->s_reusefifo->first;
+ while (a){
+ if (a->w.w_packet == packet) goto found;
+ a = a->next;
+ }
+ }
+
pdp_list_add(s->s_reusefifo, a_packet, (t_pdp_word)packet);
+
+ found:
+
+
+
+ if (PDP_DEBUG){
+ int el = s->s_reusefifo->elements;
+ int maxel = 100;
+ if (el > maxel) pdp_post("WARNING: %s reuse fifo has %d elements.", s->s_name, el);
+ }
}
/* this will revive a packet matching a certain type description
diff --git a/system/kernel/pdp_post.c b/system/kernel/pdp_post.c
index fb761d0..b75283b 100644
--- a/system/kernel/pdp_post.c
+++ b/system/kernel/pdp_post.c
@@ -29,14 +29,14 @@
/* list printing should be moved here too */
/* write a message to log (console) */
-void pdp_post_n(char *fmt, ...)
+void _pdp_post_n(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
-void pdp_post(char *fmt, ...)
+void _pdp_post(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
diff --git a/system/kernel/pdp_type.c b/system/kernel/pdp_type.c
index 0216d07..57edc00 100644
--- a/system/kernel/pdp_type.c
+++ b/system/kernel/pdp_type.c
@@ -342,7 +342,7 @@ int _pdp_packet_convert(int packet, t_pdp_symbol *dest_template)
return -1;
}
if (program_last == program_tail){
- pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
+ //pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
}
program_last = program_tail;
diff --git a/system/mmx/pixel_biquad_s16.s b/system/mmx/pixel_biquad_s16.s
index 844b041..ef48c87 100644
--- a/system/mmx/pixel_biquad_s16.s
+++ b/system/mmx/pixel_biquad_s16.s
@@ -124,7 +124,7 @@
# %mm0 == {a0 b0 c0 d0}
- .macro antitranspose_4x4:
+ .macro antitranspose_4x4
movq %mm3, %mm4
punpcklwd %mm1, %mm4 # mm4 <- {b2 d2 b3 d3}
movq %mm3, %mm5
@@ -163,7 +163,7 @@
# %mm0 == {d0 c0 b0 a0}
- .macro transpose_4x4:
+ .macro transpose_4x4
movq %mm0, %mm4
punpcklwd %mm2, %mm4 # mm4 <- {c1 a1 c0 a0}
movq %mm0, %mm5
diff --git a/system/pdp.c b/system/pdp.c
index d74323b..4f8962d 100644
--- a/system/pdp.c
+++ b/system/pdp.c
@@ -22,6 +22,7 @@
#include "pdp_config.h"
#include "pdp_post.h"
+static int initialized = 0;
/* all symbols are C style */
#ifdef __cplusplus
@@ -91,6 +92,7 @@ void pdp_udp_send_setup(void);
void pdp_udp_receive_setup(void);
void pdp_rawin_setup(void);
void pdp_rawout_setup(void);
+void pdp_metro_setup(void);
/* hacks */
@@ -105,11 +107,13 @@ void pdp_dpd_test_setup(void);
/* library setup routine */
void pdp_setup(void){
- /* babble */
- pdp_post ("PDP: pure data packet");
+ if (initialized) return;
+ /* babble */
#ifdef PDP_VERSION
- pdp_post("PDP: version " PDP_VERSION );
+ pdp_post("PDP: pure data packet version " PDP_VERSION );
+#else
+ pdp_post ("PDP: pure data packet");
#endif
@@ -175,6 +179,7 @@ void pdp_setup(void){
pdp_array_setup();
pdp_rawin_setup();
pdp_rawout_setup();
+ pdp_metro_setup();
/* experimental stuff */
@@ -220,7 +225,7 @@ void pdp_setup(void){
pdp_glx_setup();
#endif
-
+ initialized++;
}
diff --git a/system/png/pdp_png.c b/system/png/pdp_png.c
index f751912..9ac2825 100644
--- a/system/png/pdp_png.c
+++ b/system/png/pdp_png.c
@@ -88,7 +88,7 @@ static int _cleanup(t_png_image *x)
static int _open_read(t_png_image* x, char *file)
{
- char header[SIG_BYTES];
+ unsigned char header[SIG_BYTES];
int is_png;
x->x_fp = fopen(file, "r");
@@ -243,7 +243,7 @@ static int _buildstruct_write(t_png_image *x)
static int _getimagedata(t_png_image *x)
{
int nbchans = 0;
- char *image_data;
+ unsigned char *image_data;
png_bytep row_pointers[x->x_height];
png_uint_32 i;
@@ -277,7 +277,7 @@ static int _saveimagedata(t_png_image *x, int packet)
png_uint_32 i;
int nbchans;
t_pdp *h = pdp_packet_header(packet);
- char *image_data = (char *)pdp_packet_data(packet);
+ unsigned char *image_data = (unsigned char *)pdp_packet_data(packet);
if (!h) return 0;
if (PDP_BITMAP != h->type) return 0;
diff --git a/system/type/pdp_bitmap.c b/system/type/pdp_bitmap.c
index 8a30d3e..9265879 100644
--- a/system/type/pdp_bitmap.c
+++ b/system/type/pdp_bitmap.c
@@ -71,6 +71,7 @@ t_pdp_symbol *pdp_packet_bitmap_get_description(int packet)
case PDP_BITMAP_RGBA: c += sprintf(c, "/rgba"); break;
case PDP_BITMAP_GREY: c += sprintf(c, "/grey"); break;
case PDP_BITMAP_YV12: c += sprintf(c, "/yv12"); break;
+ case PDP_BITMAP_I420: c += sprintf(c, "/i420"); break;
default:
c += sprintf(c, "/unknown"); goto exit;
}
@@ -110,6 +111,17 @@ int pdp_packet_new_bitmap_yv12(u32 w, u32 h)
return packet;
}
+int pdp_packet_new_bitmap_i420(u32 w, u32 h){
+ int p = pdp_packet_new_bitmap_yv12(w,h);
+ if (-1 == p) return -1;
+ t_pdp *header = pdp_packet_header(p);
+ t_bitmap *bitmap = pdp_packet_subheader(p);
+ bitmap->encoding = PDP_BITMAP_I420;
+ header->desc = 0; // structured programming.. ha!
+ header->desc = pdp_packet_bitmap_get_description(p);
+ return p;
+}
+
int pdp_packet_new_bitmap_grey(u32 w, u32 h)
{
t_pdp *header;
@@ -189,6 +201,7 @@ int pdp_packet_new_bitmap(int type, u32 w, u32 h)
switch(type){
case PDP_BITMAP_GREY: return pdp_packet_new_bitmap_grey(w,h);
case PDP_BITMAP_YV12: return pdp_packet_new_bitmap_yv12(w,h);
+ case PDP_BITMAP_I420: return pdp_packet_new_bitmap_i420(w,h);
case PDP_BITMAP_RGB: return pdp_packet_new_bitmap_rgb(w,h);
case PDP_BITMAP_RGBA: return pdp_packet_new_bitmap_rgba(w,h);
default: return -1;
@@ -444,6 +457,39 @@ static int _pdp_packet_bitmap_convert_rgb8_to_mchp(int packet, t_pdp_symbol *des
return new_p;
}
+static int _pdp_packet_bitmap_convert_yv12_tofrom_i420(int packet, t_pdp_symbol *dest_template)
+{
+ t_pdp *header = pdp_packet_header(packet);
+ t_bitmap *in = pdp_packet_bitmap_info(packet);
+ int w = in->width;
+ int h = in->height;
+ int out_encoding;
+ if (in->encoding == PDP_BITMAP_YV12) out_encoding = PDP_BITMAP_I420;
+ else if (in->encoding == PDP_BITMAP_I420) out_encoding = PDP_BITMAP_YV12;
+ else return -1;
+
+ int new_p = pdp_packet_new_bitmap(out_encoding, w,h);
+ // t_pdp *out_h = pdp_packet_header(new_p);
+ // pdp_post("%x %s", out_encoding, out_h->desc->s_name);
+
+
+ if (-1 == new_p) return -1;
+ unsigned char *in_d = pdp_packet_data(packet);
+ unsigned char *out_d = pdp_packet_data(new_p);
+ int plane = w*h;
+ memcpy(out_d, in_d, plane);
+ out_d += plane;
+ in_d += plane;
+ plane /= 4;
+ memcpy(out_d, in_d+plane, plane);
+ memcpy(out_d+plane, in_d, plane);
+
+
+
+ return new_p;
+}
+
+
static int _pdp_packet_bitmap_convert_yv12_to_image(int packet, t_pdp_symbol *dest_template)
{
t_pdp *header = pdp_packet_header(packet);
@@ -463,11 +509,6 @@ static int _pdp_packet_bitmap_convert_yv12_to_image(int packet, t_pdp_symbol *de
return new_p;
}
-static inline u8 _map(s32 pixel){
- s32 mask = ~(pixel>>16);
- return ((pixel >> 7) & mask);
-}
-
static int _pdp_packet_bitmap_convert_mchp_to_rgb8(int packet, t_pdp_symbol *dest_template)
{
t_pdp *header = pdp_packet_header(packet);
@@ -480,6 +521,12 @@ static int _pdp_packet_bitmap_convert_mchp_to_rgb8(int packet, t_pdp_symbol *des
int nb_channels = image->depth;
int new_p, i;
+ // static inline u8 _map(s32 pixel){
+ inline u8 _map(s32 pixel){
+ s32 mask = ~(pixel>>16);
+ return ((pixel >> 7) & mask);
+ }
+
switch(nb_channels){
default: return -1;
case 1:
@@ -554,9 +601,9 @@ static int pdp_bitmap_factory(t_pdp_symbol *type)
p = pdp_packet_new_bitmap(t,w,h);
if (p != -1){
- t_pdp *h = pdp_packet_header(p);
+ t_pdp *header = pdp_packet_header(p);
/* if type is not exact, delete the packet */
- if (type != h->desc) {
+ if (type != header->desc) {
pdp_packet_delete(p);
p = -1;
}
@@ -587,6 +634,9 @@ void pdp_bitmap_setup(void)
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_image_to_yv12, 0);
pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/yv12/*"), program);
pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/yv12/*"), program);
+ pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/*"), program);
+ pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/*"), program);
+
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_to_image, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("image/YCrCb/*"), program);
@@ -604,6 +654,11 @@ void pdp_bitmap_setup(void)
pdp_type_register_conversion(pdp_gensym("image/multi/*"), pdp_gensym("bitmap/*/*"), program);
+ /* yv12 <-> i420 */
+ program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_tofrom_i420, 0);
+ pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("bitmap/i420/*"), program);
+ pdp_type_register_conversion(pdp_gensym("bitmap/i420/*"), pdp_gensym("bitmap/yv12/*"), program);
+
/* rgb <-> rgba */
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_rgba8, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("bitmap/rgba/*"), program);
@@ -611,6 +666,7 @@ void pdp_bitmap_setup(void)
pdp_type_register_conversion(pdp_gensym("bitmap/rgba/*"), pdp_gensym("bitmap/rgb/*"), program);
+
/* fallback rgb convertor */
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_YCrCb, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("image/*/*"), program);
diff --git a/system/type/pdp_image.c b/system/type/pdp_image.c
index 66fe22b..29d2976 100644
--- a/system/type/pdp_image.c
+++ b/system/type/pdp_image.c
@@ -89,6 +89,7 @@ int pdp_packet_new_image_grey(u32 w, u32 h)
u32 size = w*h;
u32 totalnbpixels = size;
u32 packet_size = totalnbpixels << 1;
+ //pdp_post("grey %d x %d = %d bytes", w,h,packet_size);
_checkdim(w,h);
@@ -529,9 +530,9 @@ static int pdp_image_factory(t_pdp_symbol *type)
break;
}
if (p != -1){
- t_pdp *h = pdp_packet_header(p);
+ t_pdp *header = pdp_packet_header(p);
/* if type is not exact, delete the packet */
- if (type != h->desc) {
+ if (type != header->desc) {
pdp_packet_delete(p);
p = -1;
}