[pdp stuff tom**20030428141041] { hunk ./TODO 4 -* running out of memory will likely crash pd. short story: don't, use pdp_control's memlimit if you need protection. +* 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. adddir ./doc adddir ./doc/pdp.old addfile ./doc/pdp.old/devdoc.html hunk ./doc/pdp.old/devdoc.html 1 + + + + PDP Developer Documentation + + + +

PDP Developer Documentation

+ +

Introduction

+ +

There is not yet much developer information, partly because pdp is not that big. I believe it is + not too hard to figure out how it works, once you get started somewhere. This document is a minimalistic + attempt to provide that starting point. For full prototypes see the header files. I've factored most + of the code into separate modules, but the borders are fluid, and will probably be subject + to further change in the future. I suggest you have a look at the pdp_base base class, and some simple + modules: pdp_add, pdp_noise and pdp_gain for examples. + +

PDP architecture

+ Architecture is a big word, but pdp is organized as modules. A packet module (using the pool module), + a packet pool module, a processing queue module, a high level type conversion module, a low level image + conversion module, a low level image processing module, an image packet module, ... + The different pdp_* externs use the core modules' functionality to minimize code duplication. I'm + relatively happy with how it fits together, but i'm not an expert at these things.. + +

PD ties

+

PDP is written as an extension for PD. One of the goals of pdp is to evolve to a separate library that can + be reused in other software. PD is a temporary host until PDP matures (or dies). Until that happens pdp will + probably stay tied fairly close to pd. Most of the + core functionality can be isolated from any pd bindings. There is one thing, however, that had a stamp on + the design of pdp: the fact that pd only supports unidirectional messaging. This creates the awkward concept + of a "passing packet" to eliminate excessive data copying. + +

In pd, the pdp messaging protocol is implemented as pd messages. The protocol is however 3 phase. + With a read only register phase, a read/write register phase and a process phase. This functionality + is part of the base class. + +

PDP API Overview

+ + The pdp public api contains only a single class. + The other calls can be thought of as messages to specific parts of pdp. + +

A packet is a class in pdp. The table below lists the supported methods. First argument is a packet id. + + +
pdp_packet_* +
new construct a raw packet (depreciated) +
new_* construct packet of specific type/subtype/... +
mark_unused release +
mark_passing conditional release (release on first copy ro/rw) +
copy_ro readonly (shared) copy +
copy_rw private copy +
clone_rw private copy (copies only meta data, not the content) +
header get the raw header (t_pdp *) +
data get the raw data (void *) +
pass_if_valid send a packet to pd outlet, if it is valid +
replace_if_valid delete packet and replace with new one, if new is valid +
copy_ro_or_drop copy readonly, or don't copy if dest slot is full + send drop notify +
copy_rw_or_drop same, but private copy +
get_description retrieve type info +
convert_ro same as copy_ro, but with an automatic conversion matching a type template +
convert_rw same as convert_ro, but producing a private copy +
+ + +

The pool object methods. All the packets are stored in a central packet pool. + + +
pdp_pool_* +
collect_garbage manually free all unused resources in packet pool +
+ +

The process queue object methods. PDP supports a separate processing thread. + + +
pdp_queue_* +
add add a process method + callback +
finish wait until a specific task is done +
wait wait until processing queue is done +
+ +

The control methods. General pdp control messages. + + +
pdp_control_* +
notify_drop notify that a packet has been dropped +
+ +

The type mediator methods. + +
pdp_type_* +
description_match check if two type templates match +
register_conversion register a type conversion program + + +
+ + +

NOTE: it is advised to derive your module from the pdp base class defined in pdp_base.h + instead of communicating directly with the pdp core + + + +

pdp_base class

+ If you want to write a pdp extern, you can derive it from the pdp_base class, instead of t_object. + +

pdp_imageproc_* modules

+ Most of the image processing code is organized as planar 16 bit signed processors. + This is crude and oversimplified, but it helps to keep the code size small and fast + at the same time (platform dependent code is reduced to a bare minimum). + + +

pdp_llconv call

+ Low level image conversion routines. (operating on raw data buffers). You probably won't need this. + + +
+
Tom Schouten
+ + +Last modified: Mon Apr 28 17:10:09 CEST 2003 + + + addfile ./pf/bitmap.h hunk ./pf/bitmap.h 1 +/* + * Pure Data Packet system implementation. 8 bit image packet interface + * Copyright (c) by Tom Schouten + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + + +/* + This file contains methods for the image packets + pdp_packet_new_* methods are several image packet constructors + + It also contains some pdp_type_ methods, for type checking + and conversion. + +*/ + +#ifndef PDP_BITMAP_H +#define PDP_BITMAP_H + + +/* all symbols are C style */ +#ifdef __cplusplus +extern "C" +{ +#endif + + + +/* bitmap constructors*/ +int pdp_packet_new_bitmap_yv12(u32 width, u32 height); +int pdp_packet_new_bitmap_grey(u32 width, u32 height); +int pdp_packet_new_bitmap_rgb(u32 width, u32 height); + + +/* get info */ +t_pdp_symbol *pdp_packet_bitmap_get_description(int packet); + + +#ifdef __cplusplus +} +#endif + +#endif hunk ./pf/image.h 52 -int pdp_packet_new_image_yv12(u32 width, u32 height); +int pdp_packet_new_image_YCrCb(u32 width, u32 height); hunk ./pf/image.h 54 +int pdp_packet_new_image_multi(u32 width, u32 height, u32 depth); hunk ./pf/packet.h 93 -/* a wrapper around malloc to keep track of pdp's memory usage */ +/* a wrapper around malloc and free to keep track of pdp's memory usage */ hunk ./pf/packet.h 95 +void pdp_dealloc(void *stuff); }