aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorPablo Martín <caedesv@users.sourceforge.net>2003-09-07 20:01:24 +0000
committerPablo Martín <caedesv@users.sourceforge.net>2003-09-07 20:01:24 +0000
commite20d5ae3622d5d656dc28d7a090aee76b08158b0 (patch)
treede772d913888f4d5faf127414e2cb4ce486be3ca /system
parent69fab985ebfc5ea03228c92a859e4091fee1b28d (diff)
updating pdp to current version 0.12.2
svn path=/trunk/externals/pdp/; revision=936
Diffstat (limited to 'system')
-rw-r--r--system/Makefile30
-rw-r--r--system/Makefile.linux2
-rw-r--r--system/Makefile.linux_mmx4
-rw-r--r--system/pdp.c150
-rw-r--r--system/pdp_comm.c119
-rw-r--r--system/pdp_control.c162
-rw-r--r--system/pdp_imageproc_mmx.c584
-rw-r--r--system/pdp_imageproc_portable.c681
-rw-r--r--system/pdp_llconv.c293
-rw-r--r--system/pdp_llconv_mmx.c55
-rw-r--r--system/pdp_llconv_portable.c81
-rw-r--r--system/pdp_packet.c243
-rw-r--r--system/pdp_queue.c340
-rw-r--r--system/pdp_resample.c170
-rw-r--r--system/pdp_type.c143
-rw-r--r--system/pdp_ut.c195
16 files changed, 0 insertions, 3252 deletions
diff --git a/system/Makefile b/system/Makefile
deleted file mode 100644
index 227e72e..0000000
--- a/system/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-
-OBJECTS = pdp.o pdp_ut.o pdp_packet.o pdp_type.o pdp_queue.o pdp_comm.o \
- pdp_control.o pdp_llconv.o pdp_resample.o
-
-OBJECTS_MMX = pdp_imageproc_mmx.o pdp_llconv_mmx.o
-OBJECTS_PORTABLE = pdp_imageproc_portable.o pdp_llconv_portable.o
-
-
-
-include ../Makefile.config
-
-all: $(PDP_TARGET) common_objects
-
-
-linux_mmx: $(OBJECTS_MMX)
- make -C mmx
-
-linux: $(OBJECTS_PORTABLE)
-
-darwin: $(OBJECTS_PORTABLE)
-
-pdp_main_clean:
- rm -f pdp.o
-
-common_objects: pdp_main_clean $(OBJECTS)
-
-clean:
- rm -f *~
- rm -f *.o
- make -C mmx clean
diff --git a/system/Makefile.linux b/system/Makefile.linux
deleted file mode 100644
index 96660f7..0000000
--- a/system/Makefile.linux
+++ /dev/null
@@ -1,2 +0,0 @@
-platform_targets: pdp_imageproc_portable.o pdp_llconv_portable.o
-
diff --git a/system/Makefile.linux_mmx b/system/Makefile.linux_mmx
deleted file mode 100644
index a646e5e..0000000
--- a/system/Makefile.linux_mmx
+++ /dev/null
@@ -1,4 +0,0 @@
-platform_subtree:
- make -C mmx
-
-platform_targets: pdp_imageproc_mmx.o pdp_llconv_mmx.o platform_subtree
diff --git a/system/pdp.c b/system/pdp.c
deleted file mode 100644
index 5475c8d..0000000
--- a/system/pdp.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Pure Data Packet system implementation: setup code
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-
-#include "pdp_config.h"
-#include "pdp.h"
-#include <stdio.h>
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-/* module setup declarations (all C-style) */
-
-/* pdp system / internal stuff */
-void pdp_packet_setup(void);
-void pdp_ut_setup(void);
-void pdp_queue_setup(void);
-void pdp_control_setup(void);
-
-/* pdp modules */
-void pdp_xv_setup(void);
-void pdp_add_setup(void);
-void pdp_mul_setup(void);
-void pdp_mix_setup(void);
-void pdp_randmix_setup(void);
-void pdp_qt_setup(void);
-void pdp_v4l_setup(void);
-void pdp_reg_setup(void);
-void pdp_conv_setup(void);
-void pdp_bq_setup(void);
-void pdp_affine_setup(void);
-void pdp_del_setup(void);
-void pdp_snap_setup(void);
-void pdp_trigger_setup(void);
-void pdp_route_setup(void);
-void pdp_noise_setup(void);
-void pdp_gradient_setup(void);
-void pdp_gain_setup(void);
-void pdp_grey_setup(void);
-void pdp_chrot_setup(void);
-void pdp_scope_setup(void);
-void pdp_scale_setup(void);
-void pdp_zoom_setup(void);
-void pdp_scan_setup(void);
-void pdp_scanxy_setup(void);
-void pdp_sdl_setup(void);
-void pdp_cheby_setup(void);
-void pdp_grey2mask_setup(void);
-void pdp_constant_setup(void);
-void pdp_slice_cut_setup(void);
-void pdp_slice_glue_setup(void);
-
-
-
-/* library setup routine */
-void pdp_setup(void){
-
- /* babble */
- post ("PDP: pure data packet");
-
-#ifdef PDP_VERSION
- fprintf(stderr, "PDP: version " PDP_VERSION "\n");
-#endif
-
-
- /* setup pdp system */
- pdp_packet_setup();
- pdp_queue_setup();
- pdp_control_setup();
-
- /* setup utility toolkit */
- pdp_ut_setup();
-
- /* setup pdp modules*/
- pdp_add_setup();
- pdp_mul_setup();
- pdp_mix_setup();
- pdp_randmix_setup();
- pdp_reg_setup();
- pdp_conv_setup();
- pdp_bq_setup();
- pdp_affine_setup();
- pdp_del_setup();
- pdp_snap_setup();
- pdp_trigger_setup();
- pdp_route_setup();
- pdp_noise_setup();
- pdp_gradient_setup();
- pdp_gain_setup();
- pdp_grey_setup();
- pdp_chrot_setup();
- pdp_scope_setup();
- pdp_scale_setup();
- pdp_zoom_setup();
- pdp_scan_setup();
- pdp_scanxy_setup();
- pdp_cheby_setup();
- pdp_grey2mask_setup();
- pdp_constant_setup();
-
-
- /* experimental stuff */
- pdp_slice_cut_setup();
- pdp_slice_glue_setup();
-
-
- /* optional modules */
-
-#ifdef HAVE_PDP_QT
- pdp_qt_setup();
-#endif
-
-#ifdef HAVE_PDP_XV
- pdp_xv_setup();
-#endif
-
-#ifdef HAVE_PDP_SDL
- pdp_sdl_setup();
-#endif
-
-#ifdef HAVE_PDP_V4L
- pdp_v4l_setup();
-#endif
-
-}
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_comm.c b/system/pdp_comm.c
deleted file mode 100644
index 80cbaaa..0000000
--- a/system/pdp_comm.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Pure Data Packet system implementation.
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 misc communication methods */
-
-
-#include "pdp.h"
-#include "pdp_internals.h"
-#include <stdio.h>
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-/************** packet management and communication convenience functions ************/
-
-/* send a packet to an outlet */
-void outlet_pdp(t_outlet *out, int packetid)
-{
- t_atom atom[2];
- t_symbol *s = gensym("pdp");
- t_symbol *rro = gensym("register_ro");
- t_symbol *rrw = gensym("register_rw");
- t_symbol *proc = gensym("process");
-
-
- SETFLOAT(atom+1, (float)packetid);
-
- SETSYMBOL(atom+0, rro);
- outlet_anything(out, s, 2, atom);
-
- SETSYMBOL(atom+0, rrw);
- outlet_anything(out, s, 2, atom);
-
- /* this is not really necessary, it can be triggered by the rw message */
- SETSYMBOL(atom+0, proc);
- outlet_anything(out, s, 1, atom);
-
-}
-
-
-/* unregister a packet and send it to an outlet */
-void
-pdp_pass_if_valid(t_outlet *outlet, int *packet)
-{
- if (-1 != *packet){
- pdp_packet_mark_unused(*packet);
- outlet_pdp(outlet, *packet);
- *packet = -1;
- }
-}
-
-void
-pdp_replace_if_valid(int *dpacket, int *spacket)
-{
- if (-1 != *spacket){
- pdp_packet_mark_unused(*dpacket);
- *dpacket = *spacket;
- *spacket = -1;
- }
-
-}
-
-
-int
-pdp_packet_copy_ro_or_drop(int *dpacket, int spacket)
-{
- int drop = 0;
- if (*dpacket == -1) *dpacket = pdp_packet_copy_ro(spacket);
- else {
- /* send a notification there is a dropped packet */
- pdp_control_notify_drop(spacket);
- drop = 1;
- }
- return drop;
-}
-
-
-int
-pdp_packet_copy_rw_or_drop(int *dpacket, int spacket)
-{
- int drop = 0;
- if (*dpacket == -1) *dpacket = pdp_packet_copy_rw(spacket);
- else {
- /* send a notification there is a dropped packet */
- pdp_control_notify_drop(spacket);
- drop = 1;
- }
- return drop;
-}
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_control.c b/system/pdp_control.c
deleted file mode 100644
index 1053f6d..0000000
--- a/system/pdp_control.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Pure Data Packet system implementation: control object
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 is an actual pd class that is used for communication with the
- pdp framework */
-
-#include "pdp.h"
-#include "pdp_internals.h"
-#include <stdio.h>
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-static long dropped_packets;
-
-static t_class* pdp_control_class;
-
-
-/* pdp control instance data */
-
-struct pdp_control_struct;
-typedef struct pdp_control_struct
-{
- t_object x_obj;
- t_outlet *x_outlet0;
- struct pdp_control_struct *x_next;
-
-} t_pdp_control;
-
-typedef void (t_pdp_control_method_notify)(t_pdp_control *x);
-
-
-static t_pdp_control *pdp_control_list;
-
-static void pdp_control_info(t_pdp_control *x)
-{
-}
-
-static void pdp_control_thread(t_pdp_control *x, t_floatarg f)
-{
- int t = (int)f;
-
- if (t){
- post("pdp_control: pdp is now using its own processing thread");
- pdp_queue_use_thread(1);
- }
- else {
- post("pdp_control: pdp is now using the main pd thread");
- pdp_queue_use_thread(0);
- }
-}
-
-
-static void pdp_control_send_drop_message(t_pdp_control *x)
-{
- t_atom atom[1];
- t_symbol *s = gensym("pdp_drop");
-
- SETFLOAT(atom+0, (float)dropped_packets);
- outlet_anything(x->x_outlet0, s, 1, atom);
-}
-
-
-static void pdp_control_free(t_pdp_control *x)
-{
- /* remove from linked list */
- t_pdp_control *curr = pdp_control_list;
- if (pdp_control_list == x) pdp_control_list = x->x_next;
- else while (curr){
- if (curr->x_next == x) {
- curr->x_next = x->x_next;
- break;
- }
- else {
- curr = curr->x_next;
- }
-
- }
-}
-
-
-static void *pdp_control_new(void)
-{
- t_pdp_control *x = (t_pdp_control *)pd_new(pdp_control_class);
- x->x_outlet0 = outlet_new(&x->x_obj, &s_anything);
-
- /* add to list */
- x->x_next = pdp_control_list;
- pdp_control_list = x;
- return x;
-}
-
-/************************* class methods ***************************************/
-
-
-void pdp_control_setup(void)
-{
-
- pdp_control_list = 0;
- dropped_packets = 0;
-
- /* setup pd class data */
- pdp_control_class = class_new(gensym("pdp_control"), (t_newmethod)pdp_control_new,
- (t_method)pdp_control_free, sizeof(t_pdp_control), 0, A_NULL);
-
-
- class_addmethod(pdp_control_class, (t_method)pdp_control_info, gensym("info"), A_NULL);
- class_addmethod(pdp_control_class, (t_method)pdp_control_thread, gensym("thread"), A_DEFFLOAT, A_NULL);
-}
-
-
-
-void pdp_control_notify_broadcast(t_pdp_control_method_notify *notify)
-{
- t_pdp_control *curr = pdp_control_list;
- while (curr){
- (*notify)(curr);
- curr = curr->x_next;
- }
-}
-
-
-
-/************************* notify class methods *************************/
-
-void pdp_control_notify_drop(int packet)
-{
- dropped_packets++;
-
- /* send drop notify to controller class instances */
- pdp_control_notify_broadcast(pdp_control_send_drop_message);
- //post("dropped packet");
-}
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_imageproc_mmx.c b/system/pdp_imageproc_mmx.c
deleted file mode 100644
index fde790f..0000000
--- a/system/pdp_imageproc_mmx.c
+++ /dev/null
@@ -1,584 +0,0 @@
-/*
- * Pure Data Packet. c wrapper for mmx image processing routines.
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 is a c wrapper around platform specific (mmx) code */
-#include <stdlib.h>
-#include <math.h>
-#include "pdp_mmx.h"
-#include "pdp_imageproc.h"
-#include "m_pd.h"
-
-/* round image dims to next multiple of 8 */
-u32 pdp_imageproc_legalwidth(int i)
-{
- if (i>1024) return 1024;
- if (i>0) return ((((i-1)>>3)+1)<<3);
- return 8;
-
-}
-
-u32 pdp_imageproc_legalheight(int i)
-{
- if (i>1024) return 1024;
- if (i>0) return ((((i-1)>>3)+1)<<3);
- return 8;
-}
-u32 pdp_imageproc_legalwidth_round_down(int i)
-{
- if (i>1024) return 1024;
- if (i>8) return ((i>>3)<<3);
- return 8;
-
-}
-
-u32 pdp_imageproc_legalheight_round_down(int i)
-{
- if (i>1024) return 1024;
- if (i>8) return ((i>>3)<<3);
- return 8;
-}
-
-// utility stuff
-inline static s16 float2fixed(float f)
-{
- if (f > 1) f = 1;
- if (f < -1) f = -1;
- f *= 0x7fff;
- return (s16)f;
-}
-
-inline static void setvec(s16 *v, float f)
-{
- s16 a = float2fixed(f);
- v[0] = a;
- v[1] = a;
- v[2] = a;
- v[3] = a;
-}
-
-
-
-// add two images
-void pdp_imageproc_add_process(s16 *image, s16 *image2, u32 width, u32 height)
-{
- unsigned int totalnbpixels = width * height;
- pixel_add_s16(image, image2, totalnbpixels>>2);
-}
-
-// mul two images
-void pdp_imageproc_mul_process(s16 *image, s16 *image2, u32 width, u32 height)
-{
- unsigned int totalnbpixels = width * height;
- pixel_mul_s16(image, image2, totalnbpixels>>2);
-}
-
-// mix 2 images
-void *pdp_imageproc_mix_new(void){return malloc(8*sizeof(s16));}
-void pdp_imageproc_mix_delete(void *x) {free (x);}
-void pdp_imageproc_mix_setleftgain(void *x, float gain){setvec((s16 *)x, gain);}
-void pdp_imageproc_mix_setrightgain(void *x, float gain){setvec((s16 *)x + 4, gain);}
-void pdp_imageproc_mix_process(void *x, s16 *image, s16 *image2, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- unsigned int totalnbpixels = width * height;
- pixel_mix_s16(image, image2, totalnbpixels>>2, d, d+4);
-}
-
-
-// random mix 2 images
-void *pdp_imageproc_randmix_new(void){return malloc(8*sizeof(s16));}
-void pdp_imageproc_randmix_delete(void *x) {free (x);}
-void pdp_imageproc_randmix_setthreshold(void *x, float threshold){setvec((s16 *)x, 2*threshold-1);}
-void pdp_imageproc_randmix_setseed(void *x, float seed)
-{
- s16 *d = (s16 *)x;
- srandom((u32)seed);
- d[4] = (s16)random();
- d[5] = (s16)random();
- d[6] = (s16)random();
- d[7] = (s16)random();
-
-}
-void pdp_imageproc_randmix_process(void *x, s16 *image, s16 *image2, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- unsigned int totalnbpixels = width * height;
- pixel_randmix_s16(image, image2, totalnbpixels>>2, d+4, d);
-}
-
-// affine transformation (applies gain + adds offset)
-void *pdp_imageproc_affine_new(void){return malloc(8*sizeof(s16));}
-void pdp_imageproc_affine_delete(void *x){free(x);}
-void pdp_imageproc_affine_setgain(void *x, float gain){setvec((s16 *)x, gain);}
-void pdp_imageproc_affine_setoffset(void *x, float offset){setvec((s16 *)x+4, offset);}
-void pdp_imageproc_affine_process(void *x, s16 *image, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- pixel_affine_s16(image, (width*height)>>2, d, d+4);
-}
-
-// 3x1 or 1x3 in place convolution
-// orientation
-void *pdp_imageproc_conv_new(void){return(malloc(16*sizeof(s16)));}
-void pdp_imageproc_conv_delete(void *x){free(x);}
-void pdp_imageproc_conv_setmin1(void *x, float val){setvec((s16 *)x, val);}
-void pdp_imageproc_conv_setzero(void *x, float val){setvec((s16 *)x+4, val);}
-void pdp_imageproc_conv_setplus1(void *x, float val){setvec((s16 *)x+8, val);}
-void pdp_imageproc_conv_setbordercolor(void *x, float val){setvec((s16 *)x+12, val);}
-void pdp_imageproc_conv_process(void *x, s16 *image, u32 width, u32 height, u32 orientation, u32 nbp)
-{
- s16 *d = (s16 *)x;
- u32 i,j;
-
- if (orientation == PDP_IMAGEPROC_CONV_HORIZONTAL)
- {
- for(i=0; i<width*height; i+=width)
- for (j=0; j<nbp; j++)
- pixel_conv_hor_s16(image+i, width>>2, d+12, d);
- }
-
- else
- {
- for (j=0; j<nbp; j++)
- for(i=0; i<width; i +=4) pixel_conv_ver_s16(image+i, height, width, d+12, d);
- }
-
-
-
-}
-
-// apply a gain to an image
-void *pdp_imageproc_gain_new(void){return(malloc(8*sizeof(s16)));}
-void pdp_imageproc_gain_delete(void *x){free(x);}
-void pdp_imageproc_gain_setgain(void *x, float gain)
-{
- /* convert float to s16 + shift */
- s16 *d = (s16 *)x;
- s16 g;
- int i;
- float sign;
- int shift = 0;
-
- sign = (gain < 0) ? -1 : 1;
- gain *= sign;
-
- /* max shift = 16 */
- for(i=0; i<=16; i++){
- if (gain < 0x4000){
- gain *= 2;
- shift++;
- }
- else break;
- }
-
- gain *= sign;
- g = (s16) gain;
-
- //g = 0x4000;
- //shift = 14;
-
- d[0]=g;
- d[1]=g;
- d[2]=g;
- d[3]=g;
- d[4]=(s16)shift;
- d[5]=0;
- d[6]=0;
- d[7]=0;
-}
-void pdp_imageproc_gain_process(void *x, s16 *image, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- pixel_gain_s16(image, (width*height)>>2, d, (u64 *)(d+4));
-}
-
-// colour rotation for 2 colour planes
-void *pdp_imageproc_crot2d_new(void){return malloc(16*sizeof(s16));}
-void pdp_imageproc_crot2d_delete(void *x){free(x);}
-void pdp_imageproc_crot2d_setmatrix(void *x, float *matrix)
-{
- s16 *d = (s16 *)x;
- setvec(d, matrix[0]);
- setvec(d+4, matrix[1]);
- setvec(d+8, matrix[2]);
- setvec(d+12, matrix[3]);
-}
-void pdp_imageproc_crot2d_process(void *x, s16 *image, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- pixel_crot2d_s16(image, width*height >> 2, d);
-}
-
-// biquad and biquad time
-void *pdp_imageproc_bq_new(void){return malloc((5+2+2)*4*sizeof(s16));}//5xcoef, 2xstate, 2xsavestate
-void pdp_imageproc_bq_delete(void *x){free(x);}
-void pdp_imageproc_bq_setcoef(void *x, float *coef) // a0,-a1,-a2,b0,b1,b2,u0,u1
-{
- s16 *d = (s16 *)x;
- float ia0 = 1.0f / coef[0];
-
- /* all coefs are s1.14 fixed point */
- /* representing values -2 < x < 2 */
- /* so scale down before using the ordinary s0.15 float->fixed routine */
-
- ia0 *= 0.5f;
-
- // coef
- setvec(d, ia0*coef[1]);
- setvec(d+4, ia0*coef[2]);
- setvec(d+8, ia0*coef[3]);
- setvec(d+12, ia0*coef[4]);
- setvec(d+16, ia0*coef[5]);
-
- // state to reset too
- setvec(d+28, coef[6]);
- setvec(d+32, coef[7]);
-
-}
-void pdp_imageproc_bqt_process(void *x, s16 *image, s16 *state0, s16 *state1, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- pixel_biquad_time_s16(image, state0, state1, d, (width*height)>>2);
-}
-
-void pdp_imageproc_bq_process(void *x, s16 *image, u32 width, u32 height, u32 direction, u32 nbp)
-{
- s16 *d = (s16 *)x;
- unsigned int i,j;
-
-
-
- /* VERTICAL */
-
- if ((direction & PDP_IMAGEPROC_BIQUAD_TOP2BOTTOM)
- && (direction & PDP_IMAGEPROC_BIQUAD_BOTTOM2TOP)){
-
- for(i=0; i<width; i +=4){
- for (j=0; j<nbp; j++){
- pixel_biquad_vertb_s16(image+i, height>>2, width, d, d + (5*4));
- pixel_biquad_verbt_s16(image+i, height>>2, width, d, d + (5*4));
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_TOP2BOTTOM){
- for(i=0; i<width; i +=4){
- for (j=0; j<nbp; j++){
- pixel_biquad_vertb_s16(image+i, height>>2, width, d, d + (5*4));
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_BOTTOM2TOP){
- for(i=0; i<width; i +=4){
- for (j=0; j<nbp; j++){
- pixel_biquad_verbt_s16(image+i, height>>2, width, d, d + (5*4));
- }
- }
- }
-
- /* HORIZONTAL */
-
- if ((direction & PDP_IMAGEPROC_BIQUAD_LEFT2RIGHT)
- && (direction & PDP_IMAGEPROC_BIQUAD_RIGHT2LEFT)){
-
- for(i=0; i<(width*height); i +=(width<<2)){
- for (j=0; j<nbp; j++){
- pixel_biquad_horlr_s16(image+i, width>>2, width, d, d + (5*4));
- pixel_biquad_horrl_s16(image+i, width>>2, width, d, d + (5*4));
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_LEFT2RIGHT){
- for(i=0; i<(width*height); i +=(width<<2)){
- for (j=0; j<nbp; j++){
- pixel_biquad_horlr_s16(image+i, width>>2, width, d, d + (5*4));
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_RIGHT2LEFT){
- for(i=0; i<(width*height); i +=(width<<2)){
- for (j=0; j<nbp; j++){
- pixel_biquad_horrl_s16(image+i, width>>2, width, d, d + (5*4));
- }
- }
- }
-
-}
-
-// produce a random image
-// note: random number generator can be platform specific
-// however, it should be seeded. (same seed produces the same result)
-void *pdp_imageproc_random_new(void){return malloc(4*sizeof(s16));}
-void pdp_imageproc_random_delete(void *x){free(x);}
-void pdp_imageproc_random_setseed(void *x, float seed)
-{
- s16 *d = (s16 *)x;
- srandom((u32)seed);
- d[0] = (s16)random();
- d[1] = (s16)random();
- d[2] = (s16)random();
- d[3] = (s16)random();
-
-}
-void pdp_imageproc_random_process(void *x, s16 *image, u32 width, u32 height)
-{
- s16 *d = (s16 *)x;
- unsigned int totalnbpixels = width * height;
- pixel_rand_s16(image, totalnbpixels>>2, d);
-}
-
-
-/* resampling stuff
- this is quite a zoo of data structures
- the major point is this: the resampler mmx code is shared for all resampling code
- it uses data specified in t_resample_cbrd (Cooked Bilinear Resampler Data)
-
- then the there are several feeder algorithms. one is the linear mapper. it's
- data is specified in t_resample_clrd (Cooked Linear Remapper Data)
-
- for each feeder algorithm, there are several high level algorithms. like zoom,
- rotate, ...
-*/
-
-typedef struct
-{
- u32 lineoffset;
- s16 *image;
- u32 width;
- u32 height;
-
-} t_resample_id; // Image Data
-
-/* initialize image meta data (dimensions + location) */
-static void pdp_imageproc_resample_init_id(t_resample_id *x, u32 offset, s16* image, u32 w, u32 h)
-{
- x->lineoffset = offset;
- x->image = image;
- x->width = w;
- x->height = h;
-}
-
-// mmx resampling source image resampling data + coefs
-typedef struct
-{
- // vector data for resampling routine (resampling computation)
- u8 reserved[0x60]; //internal data
- s16 *address[2]; //64 bit splatted offset address
- s16 twowidthm1[4]; //64 bit splatted 2*(width-1)
- s16 twoheightm1[4]; //64 bit splatted 2*(height-1)
- s16 lineoffset[4]; //64 bit splatted line offset in pixels
-
-} t_resample_cid; // Cooked Image Data
-
-/* convert image meta data into a cooked format used by the resampler routine */
-static void pdp_imageproc_resample_init_cid(t_resample_cid *r, t_resample_id *i)
-{
- u32 twowm1 = (i->width-1)<<1;
- u32 twohm1 = (i->height-1)<<1;
- r->address[0] = i->image;
- r->address[1] = i->image;
- r->twowidthm1[0] = twowm1;
- r->twowidthm1[1] = twowm1;
- r->twowidthm1[2] = twowm1;
- r->twowidthm1[3] = twowm1;
- r->twoheightm1[0] = twohm1;
- r->twoheightm1[1] = twohm1;
- r->twoheightm1[2] = twohm1;
- r->twoheightm1[3] = twohm1;
- r->lineoffset[0] = i->lineoffset;
- r->lineoffset[1] = i->lineoffset;
- r->lineoffset[2] = i->lineoffset;
- r->lineoffset[3] = i->lineoffset;
-}
-
-// linear mapping data struct (zoom, scale, rotate, shear, ...)
-typedef struct
-{
- s32 rowstatex[2]; // row state x coord
- s32 rowstatey[2]; // row state y coord
- s32 colstatex[2]; // column state x coord
- s32 colstatey[2]; // column state y coord
- s32 rowincx[2]; // row inc vector x coord
- s32 rowincy[2]; // row inc vector y coord
- s32 colincx[2]; // column inc vector x coord
- s32 colincy[2]; // column inc vector y coord
-} t_resample_clmd; // Cooked Linear Mapping Data
-
-/* convert incremental linear remapping vectors to internal cooked format */
-static void pdp_imageproc_resample_cookedlinmap_init(t_resample_clmd *l, s32 sx, s32 sy, s32 rix, s32 riy, s32 cix, s32 ciy)
-{
- l->colstatex[0] = l->rowstatex[0] = sx;
- l->colstatex[1] = l->rowstatex[1] = sx + rix;
- l->colstatey[0] = l->rowstatey[0] = sy;
- l->colstatey[1] = l->rowstatey[1] = sy + riy;
- l->rowincx[0] = rix << 1;
- l->rowincx[1] = rix << 1;
- l->rowincy[0] = riy << 1;
- l->rowincy[1] = riy << 1;
- l->colincx[0] = cix;
- l->colincx[1] = cix;
- l->colincy[0] = ciy;
- l->colincy[1] = ciy;
-}
-
-
-/* this struct contains all the data necessary for
- bilin interpolation from src -> dst image
- (src can be == dst) */
-typedef struct
-{
- t_resample_cid csrc; //cooked src image meta data for bilinear interpolator
- t_resample_id src; //src image meta
- t_resample_id dst; //dst image meta
-} t_resample_cbrd; //Bilinear Resampler Data
-
-
-/* this struct contains high level zoom parameters,
- all image relative */
-typedef struct
-{
- float centerx;
- float centery;
- float zoomx;
- float zoomy;
- float angle;
-} t_resample_zrd;
-
-
-/* convert floating point center and zoom data to incremental linear remapping vectors */
-static void pdp_imageproc_resample_clmd_init_from_id_zrd(t_resample_clmd *l, t_resample_id *i, t_resample_zrd *z)
-{
- double izx = 1.0f / (z->zoomx);
- double izy = 1.0f / (z->zoomy);
- double scale = (double)0xffffffff;
- double scalew = scale / ((double)(i->width - 1));
- double scaleh = scale / ((double)(i->height - 1));
- double cx = ((double)z->centerx) * ((double)(i->width - 1));
- double cy = ((double)z->centery) * ((double)(i->height - 1));
- double angle = z->angle * (-M_PI / 180.0);
- double c = cos(angle);
- 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));}
-
- u32 tl_x = (u32)(scalew * mapx(0,0));
- u32 tl_y = (u32)(scaleh * mapy(0,0));
-
-
- u32 row_inc_x = (u32)(scalew * (mapx(1,0)-mapx(0,0)));
- u32 row_inc_y = (u32)(scaleh * (mapy(1,0)-mapy(0,0)));
- u32 col_inc_x = (u32)(scalew * (mapx(0,1)-mapx(0,0)));
- u32 col_inc_y = (u32)(scaleh * (mapy(0,1)-mapy(0,0)));
-
-
- pdp_imageproc_resample_cookedlinmap_init(l, tl_x, tl_y, row_inc_x, row_inc_y, col_inc_x, col_inc_y);
-}
-
-/* this struct contains all data for the zoom object */
-typedef struct
-{
- t_resample_cbrd cbrd; // Bilinear Resampler Data
- t_resample_clmd clmd; // Cooked Linear Mapping data
- t_resample_zrd zrd; // Zoom / Rotate Data
-} t_resample_zoom_rotate;
-
-// zoom + rotate
-void *pdp_imageproc_resample_affinemap_new(void)
-{
- t_resample_zoom_rotate *z = (t_resample_zoom_rotate *)malloc(sizeof(t_resample_zoom_rotate));
- z->zrd.centerx = 0.5;
- z->zrd.centery = 0.5;
- z->zrd.zoomx = 1.0;
- z->zrd.zoomy = 1.0;
- z->zrd.angle = 0.0f;
- return (void *)z;
-}
-void pdp_imageproc_resample_affinemap_delete(void *x){free(x);}
-void pdp_imageproc_resample_affinemap_setcenterx(void *x, float f){((t_resample_zoom_rotate *)x)->zrd.centerx = f;}
-void pdp_imageproc_resample_affinemap_setcentery(void *x, float f){((t_resample_zoom_rotate *)x)->zrd.centery = f;}
-void pdp_imageproc_resample_affinemap_setzoomx(void *x, float f){((t_resample_zoom_rotate *)x)->zrd.zoomx = f;}
-void pdp_imageproc_resample_affinemap_setzoomy(void *x, float f){((t_resample_zoom_rotate *)x)->zrd.zoomy = f;}
-void pdp_imageproc_resample_affinemap_setangle(void *x, float f){((t_resample_zoom_rotate *)x)->zrd.angle = f;}
-void pdp_imageproc_resample_affinemap_process(void *x, s16 *srcimage, s16 *dstimage, u32 width, u32 height)
-{
- t_resample_zoom_rotate *z = (t_resample_zoom_rotate *)x;
-
- /* setup resampler image meta data */
- pdp_imageproc_resample_init_id(&(z->cbrd.src), width, srcimage, width, height);
- pdp_imageproc_resample_init_id(&(z->cbrd.dst), width, dstimage, width, height);
- pdp_imageproc_resample_init_cid(&(z->cbrd.csrc),&(z->cbrd.src));
-
- /* setup linmap data from zoom_rotate parameters */
- pdp_imageproc_resample_clmd_init_from_id_zrd(&(z->clmd), &(z->cbrd.src), &(z->zrd));
-
-
- /* call assembler routine */
- pixel_resample_linmap_s16(z);
-}
-
-
-
-// polynomials
-
-
-typedef struct
-{
- u32 order;
- u8 pad[4];
- s16 coefs[0];
-} t_cheby;
-
-void *pdp_imageproc_cheby_new(int order)
-{
- t_cheby *z;
- int i;
- if (order < 2) order = 2;
- z = (t_cheby *)malloc(sizeof(t_cheby) + (order + 1) * sizeof(s16[4]));
- z->order = order;
- setvec(z->coefs + 0*4, 0);
- setvec(z->coefs + 1*4, 0.25);
- for (i=2; i<=order; i++) setvec(z->coefs + i*4, 0);
-
- return z;
-}
-void pdp_imageproc_cheby_delete(void *x){free(x);}
-void pdp_imageproc_cheby_setcoef(void *x, u32 n, float f)
-{
- t_cheby *z = (t_cheby *)x;
- if (n <= z->order){
- setvec(z->coefs + n*4, f * 0.25); // coefs are in s2.13 format
- }
-}
-void pdp_imageproc_cheby_process(void *x, s16 *image, u32 width, u32 height, u32 iterations)
-{
- t_cheby *z = (t_cheby *)x;
- u32 i,j;
- for (j=0; j < (height*width); j += width)
- for (i=0; i<iterations; i++)
- pixel_cheby_s16_3plus(image+j, width>>2, z->order+1, z->coefs);
-
- //pixel_cheby_s16_3plus(image, (width*height)>>2, z->order+1, z->coefs);
-}
diff --git a/system/pdp_imageproc_portable.c b/system/pdp_imageproc_portable.c
deleted file mode 100644
index 86b91b8..0000000
--- a/system/pdp_imageproc_portable.c
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Pure Data Packet. portable image processing routines.
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-
-
-
-#include <stdlib.h>
-#include <math.h>
-#include "pdp_imageproc.h"
-
-/* all image dims are legal */
-u32 pdp_imageproc_legalwidth(int i)
-{
- if (i>1024) return 1024;
- if (i>0) return i;
- return 1;
-}
-
-u32 pdp_imageproc_legalheight(int i)
-{
- if (i>1024) return 1024;
- if (i>0) return i;
- return 1;
-}
-u32 pdp_imageproc_legalwidth_round_down(int i) {return pdp_imageproc_legalwidth(i);}
-u32 pdp_imageproc_legalheight_round_down(int i) {return pdp_imageproc_legalheight(i);}
-
-
-// utility stuff
-inline static s32 float2fixed(float f)
-{
- if (f > 1) f = 1;
- if (f < -1) f = -1;
- f *= 0x7fff;
- return (s32)f;
-}
-
-
-
-#define CLAMP16(x) (((x) > 0x7fff) ? 0x7fff : (((x) < -0x7fff) ? -0x7fff : (x)))
-
-// add two images
-void pdp_imageproc_add_process(s16 *image, s16 *image2, u32 width, u32 height)
-{
- int a, b;
- unsigned int i;
- for (i=0; i<width*height; i++){
- a = (int)image[i];
- b = (int)image2[i];
- image[i] = (s16)(CLAMP16(a+b));
- }
-
-}
-
-// mul two images
-void pdp_imageproc_mul_process(s16 *image, s16 *image2, u32 width, u32 height)
-{
- int a, b;
- unsigned int i;
- for (i=0; i<width*height; i++){
- a = (int)image[i];
- b = (int)image2[i];
- image[i] = (s16)((a*b)>>15);
- }
-
-}
-
-// mix 2 images
-void *pdp_imageproc_mix_new(void){return malloc(2*sizeof(s32));}
-void pdp_imageproc_mix_delete(void *x) {free (x);}
-void pdp_imageproc_mix_setleftgain(void *x, float gain)
-{
- s32 *d = (s32 *)x;
- d[0] = float2fixed(gain);
-}
-void pdp_imageproc_mix_setrightgain(void *x, float gain)
-{
- s32 *d = (s32 *)x;
- d[1] = float2fixed(gain);
-}
-void pdp_imageproc_mix_process(void *x, s16 *image, s16 *image2, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i;
- s32 a,b;
-
- for(i=0; i<width*height; i++){
- a = (s32)image[i];
- b = (s32)image2[i];
- a = (a*d[0] + b*d[1]) >> 15;
- image[i] = (s16)CLAMP16(a);
- }
-
-}
-
-
-// random mix 2 images
-void *pdp_imageproc_randmix_new(void){return malloc(2*sizeof(s32));;}
-void pdp_imageproc_randmix_delete(void *x) {free(x);}
-void pdp_imageproc_randmix_setthreshold(void *x, float threshold)
-{
- s32 *d = (s32 *)x;
- if (threshold > 1.0f) threshold = 1.0f;
- if (threshold < 0.0f) threshold = 0.0f;
- d[0] = float2fixed(threshold);
-}
-void pdp_imageproc_randmix_setseed(void *x, float seed)
-{
- s32 *d = (s32 *)x;
- d[1] = float2fixed(seed);
-}
-void pdp_imageproc_randmix_process(void *x, s16 *image, s16 *image2, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i;
- s16 r;
- srandom((u32)d[1]);
-
-
- for(i=0; i<width*height; i++){
- // get a random val between 0 and 0x7fff
- r = (s16)(random() & 0x7fff);
- if (r < d[0]) image[i] = image2[i];
- }
-}
-
-// affine transformation (applies gain + adds offset)
-void *pdp_imageproc_affine_new(void){return malloc(2*sizeof(s32));}
-void pdp_imageproc_affine_delete(void *x){free(x);}
-void pdp_imageproc_affine_setgain(void *x, float gain)
-{
- s32 *d = (s32 *)x;
- d[0] = float2fixed(gain);
-}
-
-void pdp_imageproc_affine_setoffset(void *x, float offset)
-{
- s32 *d = (s32 *)x;
- d[1] = float2fixed(offset);
-}
-void pdp_imageproc_affine_process(void *x, s16 *image, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i;
- s32 a;
-
- for(i=0; i<width*height; i++){
- a = (s32)image[i];
- a = (a*d[0]) >> 15;
- a += d[1];
- image[i] = (s16)CLAMP16(a);
- }
-}
-
-// 3x1 or 1x3 in place convolution
-// orientation
-void *pdp_imageproc_conv_new(void){return(malloc(4*sizeof(s32)));}
-void pdp_imageproc_conv_delete(void *x){free(x);}
-void pdp_imageproc_conv_setmin1(void *x, float val)
-{
- s32 *d = (s32 *)x;
- d[0] = float2fixed(val);
-}
-void pdp_imageproc_conv_setzero(void *x, float val)
-{
- s32 *d = (s32 *)x;
- d[1] = float2fixed(val);
-}
-void pdp_imageproc_conv_setplus1(void *x, float val)
-{
- s32 *d = (s32 *)x;
- d[2] = float2fixed(val);
-}
-void pdp_imageproc_conv_setbordercolor(void *x, float val)
-{
- s32 *d = (s32 *)x;
- d[3] = float2fixed(val);
-}
-
-static inline void pdp_imageproc_conv_scanline(void *x, s16 *data, u32 count, s32 stride)
-{
- s32 *d = (s32 *)x;
- s32 a,b,c,r;
- u32 i;
-
- a = d[3]; //border
- b = data[0];
- c = data[stride];
-
- for(i = 0; i < count-2; i++){
- r = a*d[0] + b*d[1] + c*d[2];
- a = data[0];
- b = data[stride];
- c = data[stride<<1];
- data[0] = (s16)CLAMP16(r>>15);
- data += stride;
- }
- r = a*d[0] + b*d[1] + c*d[2];
- a = data[0];
- b = data[stride];
- c = d[3]; //border
- data[0] = (s16)CLAMP16(r>>15);
- r = a*d[0] + b*d[1] + c*d[2];
- data[stride] = (s16)CLAMP16(r>>15);
-
-}
-
-void pdp_imageproc_conv_process(void *x, s16 *image, u32 width, u32 height, u32 orientation, u32 nbp)
-{
- s32 *d = (s32 *)x;
- u32 i, j;
-
- if (orientation == PDP_IMAGEPROC_CONV_HORIZONTAL){
- for(i=0; i<width*height; i+=width)
- for(j=0; j<nbp; j++)
- pdp_imageproc_conv_scanline(x, image+i, width, 1);
-
- }
-
- if (orientation == PDP_IMAGEPROC_CONV_VERTICAL){
- for(i=0; i<width; i++)
- for(j=0; j<nbp; j++)
- pdp_imageproc_conv_scanline(x, image+i, height, width);
-
- }
-
-
-
-
-}
-
-// apply a gain to an image
-void *pdp_imageproc_gain_new(void){return(malloc(2*sizeof(s32)));}
-void pdp_imageproc_gain_delete(void *x){free(x);}
-void pdp_imageproc_gain_setgain(void *x, float gain)
-{
- /* convert float to s16 + shift */
- s32 *d = (s32 *)x;
- s32 g;
- int i;
- float sign;
- s32 shift = 0;
-
- sign = (gain < 0) ? -1 : 1;
- gain *= sign;
-
- /* max shift = 16 */
- for(i=0; i<=16; i++){
- if (gain < 0x4000){
- gain *= 2;
- shift++;
- }
- else break;
- }
-
- gain *= sign;
- g = (s32) gain;
-
- //g = 0x4000;
- //shift = 14;
-
- d[0]=g;
- d[1]=shift;
-}
-void pdp_imageproc_gain_process(void *x, s16 *image, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- s32 a;
- u32 i;
- for (i=0; i<width*height; i++){
- a = (s32)image[i];
- image[i] = (s16)(CLAMP16((a * d[0]) >> d[1]));
- }
-}
-
-// colour rotation for 2 colour planes
-void *pdp_imageproc_crot2d_new(void){return malloc(4*sizeof(s32));}
-void pdp_imageproc_crot2d_delete(void *x){free(x);}
-void pdp_imageproc_crot2d_setmatrix(void *x, float *matrix)
-{
- s32 *d = (s32 *)x;
- d[0] = float2fixed(matrix[0]);
- d[1] = float2fixed(matrix[1]);
- d[2] = float2fixed(matrix[2]);
- d[3] = float2fixed(matrix[3]);
-
-}
-void pdp_imageproc_crot2d_process(void *x, s16 *image, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i,j;
- s32 a1,a2,c1,c2;
-
- for(i=0, j=width*height; i<width*height; i++, j++){
- c1 = (s32)image[i];
- c2 = (s32)image[j];
-
- a1 = d[0] * c1;
- a2 = d[1] * c1;
- a1+= d[2] * c2;
- a2+= d[3] * c2;
-
- a1 >>= 15;
- a2 >>= 15;
-
- image[i] = (s16)CLAMP16(a1);
- image[j] = (s16)CLAMP16(a2);
- }
-}
-
-// biquad and biquad time
-void *pdp_imageproc_bq_new(void){return malloc((5+2+2)*sizeof(s32));}//5xcoef, 2xstate, 2xsavestate
-void pdp_imageproc_bq_delete(void *x){free(x);}
-void pdp_imageproc_bq_setcoef(void *x, float *coef) // a0,-a1,-a2,b0,b1,b2,u0,u1
-{
- s32 *d = (s32 *)x;
- float ia0 = 1.0f / coef[0];
-
- /* all coefs are s1.14 fixed point */
- /* representing values -2 < x < 2 */
- /* so scale down before using the ordinary s0.15 float->fixed routine */
-
- ia0 *= 0.5f;
-
- // coef
- d[0] = float2fixed(ia0*coef[1]); // -a1
- d[1] = float2fixed(ia0*coef[2]); // -a2
- d[2] = float2fixed(ia0*coef[3]); // b0
- d[3] = float2fixed(ia0*coef[4]); // b1
- d[4] = float2fixed(ia0*coef[5]); // b2
-
-
- // state to reset too
- d[5] = float2fixed(coef[6]);
- d[6] = float2fixed(coef[7]);
-
-}
-
-#define A1 d[0]
-#define A2 d[1]
-#define B0 d[2]
-#define B1 d[3]
-#define B2 d[4]
-/*
- # DIRECT FORM II BIQUAD (from pixel_biquad_s16.s)
- #
- # y[k] = b0 * x[k] + u1[k-1]
- # u1[k] = b1 * x[k] + u2[k-1] - a1 * y[k]
- # u2[k] = b2 * x[k] - a2 * y[k]
-*/
-
-/* remark A1 and A2 are already negated) */
-
-
-static inline void pdp_imageproc_bq_scanline(void *x, s16 *data, u32 count, s32 stride)
-{
-
- s32 *d = (s32 *)x;
- s32 u1,u2, xx, yy;
-
- u32 i;
-
- u1 = d[7];
- u2 = d[8];
-
- for(i = 0; i < count; i++){
-
- xx = (s32)data[0];
-
- yy = ((B0 * xx)>>14) + u1;
- u1 = ((B1 * xx)>>14) + u2 + ((A1 * yy)>>14);
- u2 = ((B2 * xx)>>14) + ((A2 * yy)>>14);
-
- data[0] = (s16)CLAMP16(yy);
-
- data += stride;
-
- }
-
- d[7] = u1;
- d[8] = u2;
-
-}
-
-void pdp_imageproc_bqt_process(void *x, s16 *image, s16 *state1, s16 *state2, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i;
- s32 u1, u2, xx, yy;
-
- for (i=0; i<width*height; i++){
-
- xx = (s32)image[i];
- u1 = (s32)state1[i];
- u2 = (s32)state2[i];
-
- yy = ((B0 * xx)>>14) + u1;
- u1 = ((B1 * xx)>>14) + u2 + ((A1 * yy)>>14);
- u2 = ((B2 * xx)>>14) + ((A2 * yy)>>14);
-
- image[i] = (s16)CLAMP16(yy);
- state1[i] = (s16)CLAMP16(u1);
- state2[i] = (s16)CLAMP16(u2);
- }
-
-
-}
-
-void pdp_imageproc_bq_process(void *x, s16 *data, u32 width, u32 height, u32 direction, u32 nbp)
-{
- s32 *d = (s32 *)x;
- unsigned int i,j, offset;
-
- /* VERTICAL */
- offset = (height-1)*width;
-
- if ((direction & PDP_IMAGEPROC_BIQUAD_TOP2BOTTOM)
- && (direction & PDP_IMAGEPROC_BIQUAD_BOTTOM2TOP)){
-
- for(i=0; i<width; i++){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+i, height, width); //T->B
- pdp_imageproc_bq_scanline(x, data+offset+i, height, -width); //B->T
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_TOP2BOTTOM){
- for(i=0; i<width; i++){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+i, height, width); //T->B
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_BOTTOM2TOP){
- for(i=0; i<width; i++){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+offset+i, height, -width); //B->T
- }
- }
- }
-
- /* HORIZONTAL */
-
- offset = width-1;
- if ((direction & PDP_IMAGEPROC_BIQUAD_LEFT2RIGHT)
- && (direction & PDP_IMAGEPROC_BIQUAD_RIGHT2LEFT)){
-
- for(i=0; i<(width*height); i += width){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+i, width, 1); //L->R
- pdp_imageproc_bq_scanline(x, data+offset+i, width, -1); //R->L
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_LEFT2RIGHT){
- for(i=0; i<(width*height); i += width){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+i, width, 1); //L->R
- }
- }
- }
-
- else if (direction & PDP_IMAGEPROC_BIQUAD_RIGHT2LEFT){
- for(i=0; i<(width*height); i += width){
- for (j=0; j<nbp; j++){
- pdp_imageproc_bq_scanline(x, data+offset+i, width, -1); //R->L
-
- }
- }
- }
-
-}
-
-// produce a random image
-// note: random number generator can be platform specific
-// however, it should be seeded. (same seed produces the same result)
-void *pdp_imageproc_random_new(void){return malloc(sizeof(s32));}
-void pdp_imageproc_random_delete(void *x){free(x);}
-void pdp_imageproc_random_setseed(void *x, float seed)
-{
- s32 *d = (s32 *)x;
- d[0] = float2fixed(seed);
-}
-void pdp_imageproc_random_process(void *x, s16 *image, u32 width, u32 height)
-{
- s32 *d = (s32 *)x;
- u32 i;
- srandom((u32)d[0]);
- for (i=0; i<width*height; i++) image[i] = (s16)(random() & 0xffff);
-
-}
-
-
-
-/* resampling code */
-// zoom + rotate
-
-/* bilinear resampling core routine */
-/* virtual coordinates are the lowest 16 bits in virt_x and virt_y*/
-static inline s32 pdp_resample_bilin(s16 *image, s32 width, s32 height, s32 virt_x, s32 virt_y)
-{
-
- s32 fp_x, fp_y, frac_x, frac_y, f, offset, r_1, r_2;
-
- //virt_x &= 0xffff;
- //virt_y &= 0xffff;
-
- fp_x = virt_x * (width - 1);
- fp_y = virt_y * (height - 1);
-
- frac_x = fp_x & (0xffff);
- frac_y = fp_y & (0xffff);
-
- offset = (fp_x >> 16) + (fp_y >> 16) * width;
- image += offset;
-
- f = 0x10000 - frac_x;
-
- r_1 = ((f * (s32)(image[0]) + frac_x * (s32)(image[1])))>>16;
-
- image += width;
-
- r_2 = ((f * (s32)(image[0]) + frac_x * (s32)(image[1])))>>16;
-
- f = 0x10000 - frac_y;
-
- return ((f * r_1 + frac_y * r_2)>>16);
-
-}
-
-typedef struct
-{
- float centerx;
- float centery;
- float zoomx;
- float zoomy;
- float angle;
-} t_affine_map;
-
-
-void *pdp_imageproc_resample_affinemap_new(void)
-{
-
- t_affine_map *a = (t_affine_map *)malloc(sizeof(t_affine_map));
- a->centerx = 0.5;
- a->centery = 0.5;
- a->zoomx = 1.0;
- a->zoomy = 1.0;
- a->angle = 0.0f;
- return (void *)a;
-}
-void pdp_imageproc_resample_affinemap_delete(void *x){free(x);}
-void pdp_imageproc_resample_affinemap_setcenterx(void *x, float f){((t_affine_map *)x)->centerx = f;}
-void pdp_imageproc_resample_affinemap_setcentery(void *x, float f){((t_affine_map *)x)->centery = f;}
-void pdp_imageproc_resample_affinemap_setzoomx(void *x, float f){((t_affine_map *)x)->zoomx = f;}
-void pdp_imageproc_resample_affinemap_setzoomy(void *x, float f){((t_affine_map *)x)->zoomy = f;}
-void pdp_imageproc_resample_affinemap_setangle(void *x, float f){((t_affine_map *)x)->angle = f;}
-void pdp_imageproc_resample_affinemap_process(void *x, s16 *src_image, s16 *dst_image, u32 width, u32 height)
-{
- t_affine_map *a = (t_affine_map *)x;
- double izx = 1.0f / (a->zoomx);
- double izy = 1.0f / (a->zoomy);
- double scale = (double)0xffffffff;
- double scalew = scale / ((double)(width - 1));
- double scaleh = scale / ((double)(height - 1));
- double cx = ((double)a->centerx) * ((double)(width - 1));
- double cy = ((double)a->centery) * ((double)(height - 1));
- double angle = a->angle * (-M_PI / 180.0);
- double c = cos(angle);
- 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));}
-
- u32 colstate_x = (u32)(scalew * mapx(0,0));
- u32 colstate_y = (u32)(scaleh * mapy(0,0));
- u32 rowstate_x = colstate_x;
- u32 rowstate_y = colstate_y;
-
- u32 row_inc_x = (u32)(scalew * (mapx(1,0)-mapx(0,0)));
- u32 row_inc_y = (u32)(scaleh * (mapy(1,0)-mapy(0,0)));
- u32 col_inc_x = (u32)(scalew * (mapx(0,1)-mapx(0,0)));
- u32 col_inc_y = (u32)(scaleh * (mapy(0,1)-mapy(0,0)));
-
- u32 i,j;
-
- for (j=0; j<height; j++){
- for (i=0; i<width; i++){
- *dst_image++ = pdp_resample_bilin(src_image, width, height, rowstate_x>>16, rowstate_y>>16);
- rowstate_x += row_inc_x;
- rowstate_y += row_inc_y;
- }
- colstate_x += col_inc_x;
- colstate_y += col_inc_y;
- rowstate_x = colstate_x;
- rowstate_y = colstate_y;
- }
-
-}
-
-
-
-
-
-// polynomials
-
-
-
-
-typedef struct
-{
- u32 order;
- s32 coefs[0];
-} t_cheby;
-
-void *pdp_imageproc_cheby_new(int order)
-{
- t_cheby *z;
- int i;
- if (order < 2) order = 2;
- z = (t_cheby *)malloc(sizeof(t_cheby) + (order + 1) * sizeof(s32));
- z->order = order;
- z->coefs[0] = 0;
- z->coefs[1] = 0x7fff;
- for (i=2; i<=order; i++) z->coefs[i] = 0;
- return z;
-}
-void pdp_imageproc_cheby_delete(void *x){free(x);}
-void pdp_imageproc_cheby_setcoef(void *x, u32 n, float f)
-{
-
- t_cheby *z = (t_cheby *)x;
- if (n <= z->order){
- z->coefs[n] = (s32)(f * 32767.0f); // coefs are in s16.15 format
- }
-
-}
-void pdp_imageproc_cheby_process(void *x, s16 *image, u32 width, u32 height, u32 iterations)
-{
-
- t_cheby *z = (t_cheby *)x;
- u32 i,j,k;
- s32 *c = z->coefs;
- for (j=0; j < (height*width); j++){
- s32 acc = (s32)image[j];
- for (i=0; i<iterations; i++){
- s32 T2 = 0x7fff; /* 1 */
- s32 T1 = acc;
- s32 t;
- s32 in = acc;
- acc = c[0] + ((in*c[1])>>15);
- for (k=2; k<=z->order; k++){
- t = ((T1*in)>>14) - T2; /* T_n = 2 x T_n-1 - T_n-2 */
- T2 = T1;
- T1 = t;
- acc += ((c[k] * t)>>15);
- }
- }
- image[j] = (s16)(CLAMP16(acc));
- }
-}
diff --git a/system/pdp_llconv.c b/system/pdp_llconv.c
deleted file mode 100644
index 93d2934..0000000
--- a/system/pdp_llconv.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Pure Data Packet system implementation. : low level format conversion code
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 low level image conversion code
- nominated as "the ugliest part of pdp"
- some code is mmx, most is not. */
-
-#include "pdp_llconv.h"
-#include "pdp_mmx.h"
-
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#define CLAMP(x) (((x)<0) ? 0 : ((x>255)? 255 : (x)))
-#define CLAMP16(x) (((x)<-0x7fff) ? -0x7fff : ((x>0x7fff) ? 0x7fff : (x)))
-#define FP(x) ((int)(((float)(x)) * 256.0f))
-
-
-/* some prototypes for functions defined elsewhere */
-void llconv_yvu_planar_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels);
-void llconv_yuv_planar_u8s16(unsigned char* source, short int *dest, int nbpixels);
-void llconv_grey_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels);
-void llconv_yvu_planar_u8s16(unsigned char* source, short int *dest, int nbpixels);
-
-
-static inline int rgb2y(int r, int g, int b){return (FP(0.257) * r) + (FP(0.504) * g) + (FP(0.098) * b) + FP(16);}
-static inline int rgb2v(int r, int g, int b){return (FP(0.439) * r) - (FP(0.368) * g) - (FP(0.071) * b) + FP(128);}
-static inline int rgb2u(int r, int g, int b){return -(FP(0.148) * r) - (FP(0.291) * g) + (FP(0.439) * b) + FP(128);}
-
-
-/* "standard" 8 bit conversion routine */
-static void llconv_rgb2yvu(unsigned char* src, unsigned char* dst, int nbpixels)
-{
- int r,g,b,y,v,u,i;
- for (i=0; i<nbpixels; i++){
- r = src[0];
- g = src[1];
- b = src[2];
-
- y = rgb2y(r,g,b);
- v = rgb2v(r,g,b);
- u = rgb2u(r,g,b);
-
- dst[0] = CLAMP(y>>8);
- dst[1] = CLAMP(v>>8);
- dst[2] = CLAMP(u>>8);
-
- src += 3;
- dst += 3;
- }
-}
-
-
-
-/* 8 bit rgb to 16 bit planar subsampled yvu */
-static void llconv_rgb2yvu_planar16sub(unsigned char* src, short int* dst, int w, int h)
-{
- int r,g,b,y,v,u,i,j,k;
- int size = w*h;
-
- int voffset = size;
- int uoffset = size + (size>>2);
-
-
- int loffset = w * 3;
-
- k=0;
- for (j=0; j<w*h; j+=(w<<1)){
- k = 3 * j;
- for (i=0; i<w; i+=2){
-
-
- // well, this seems to work... strange though
- b = src[k];
- g = src[k+1];
- r = src[k+2];
-
- y = (FP(0.257) * r) + (FP(0.504) * g) + (FP(0.098) * b) + FP(16);
- v = (FP(0.439) * r) - (FP(0.368) * g) - (FP(0.071) * b);
- u = -(FP(0.148) * r) - (FP(0.291) * g) + (FP(0.439) * b);
-
- dst[i+j] = CLAMP16(y >> 1);
-
- b = src[k+3];
- g = src[k+4];
- r = src[k+5];
-
- y = (FP(0.257) * r) + (FP(0.504) * g) + (FP(0.098) * b) + FP(16);
- v += (FP(0.439) * r) - (FP(0.368) * g) - (FP(0.071) * b);
- u += -(FP(0.148) * r) - (FP(0.291) * g) + (FP(0.439) * b);
-
- dst[i+j+1] = CLAMP16(y >> 1);
-
-
-
- b = src[loffset + k];
- g = src[loffset + k+1];
- r = src[loffset + k+2];
-
- y = (FP(0.257) * r) + (FP(0.504) * g) + (FP(0.098) * b) + FP(16);
- v = (FP(0.439) * r) - (FP(0.368) * g) - (FP(0.071) * b);
- u = -(FP(0.148) * r) - (FP(0.291) * g) + (FP(0.439) * b);
-
- dst[w+i+j] = CLAMP16(y >> 1);
-
- b = src[loffset + k+3];
- g = src[loffset + k+4];
- r = src[loffset + k+5];
-
- k += 6;
-
- y = (FP(0.257) * r) + (FP(0.504) * g) + (FP(0.098) * b) + FP(16);
- v += (FP(0.439) * r) - (FP(0.368) * g) - (FP(0.071) * b);
- u += -(FP(0.148) * r) - (FP(0.291) * g) + (FP(0.439) * b);
-
- dst[w+i+j+1] = CLAMP16(y >> 1);
-
- dst[uoffset+ (i>>1) + (j>>2)] = (CLAMP16(u >> 1));
- dst[voffset+ (i>>1) + (j>>2)] = (CLAMP16(v >> 1));
- }
- }
-}
-
-/* these seem to be pretty slow */
-
-static void llconv_yvu2rgb(unsigned char* src, unsigned char* dst, int nbpixels)
-{
- int r,g,b,y,v,u,i;
- for (i=0; i<nbpixels; i++){
- y = src[0];
- v = src[1];
- u = src[2];
-
-
- b = FP(1.164) * (y - 16) + FP(2.018) * (u - 128);
- g = FP(1.164) * (y - 16) - FP(0.813) * (v - 128) - FP(0.391) * (u - 128);
- r = FP(1.164) * (y - 16) + FP(1.596) * (v - 128);
-
- dst[0] = CLAMP(r>>8);
- dst[1] = CLAMP(g>>8);
- dst[2] = CLAMP(b>>8);
-
- src += 3;
- dst += 3;
- }
-}
-
-
-
-/* convert yvu to yuyv */
-static void llconv_yvu2yuyv(unsigned char *src, unsigned char *dst, unsigned int nbpixels)
-{
- unsigned int y1, y2, u, v, i;
-
- for (i = 0; i < nbpixels/2; i++){
-
- y1 = src[0];
- y2 = src[3];
- v = (src[1] + src[4]) >> 1;
- u = (src[2] + src[5]) >> 1;
- dst[0] = y1;
- dst[1] = u;
- dst[2] = y2;
- dst[3] = v;
-
- src += 6;
- dst += 4;
-
- }
-
-}
-
-
-
-/* convert yuvu packed 8 bit unsigned to yv12 planar 16bit signed */
-static void llconv_yuyv_packed_u8s16(unsigned char* ucsource, short int *sidest, unsigned int w, unsigned int h)
-{
- unsigned int i, j;
- unsigned int *source = (unsigned int *)ucsource;
-
- unsigned int *dest = (unsigned int *)sidest;
- unsigned int uoffset = (w*h)>>1;
- unsigned int voffset = (w*h + ((w*h) >> 2)) >> 1;
-
- for(j=0; j < (h*w)>>1; j +=(w)){
- for(i=0; i< (w>>1); i+=2){
- unsigned int y,u,v;
- unsigned int v00, v01, v10, v11;
- v00 = source[i+j];
- v01 = source[i+j+1];
- v10 = source[i+j+(w>>1)];
- v11 = source[i+j+(w>>1)+1];
-
- // save luma
- dest[i+j] = ((v00 & 0x00ff00ff) << 7);
- dest[i+j+1] = ((v01 & 0x00ff00ff) << 7);
- dest[i+j+(w>>1)] = ((v10 & 0x00ff00ff) << 7);
- dest[i+j+(w>>1)+1] = ((v11 & 0x00ff00ff) << 7);
-
- // compute chroma
-
- // mask out luma & shift right
- v00 = (v00 & 0xff00ff00)>>1;
- v01 = (v01 & 0xff00ff00)>>1;
- v10 = (v10 & 0xff00ff00)>>1;
- v11 = (v11 & 0xff00ff00)>>1;
-
- // average 2 scan lines
- v00 += v10;
- v01 += v11;
-
- // combine
- v = (v01 << 16) | (v00 & 0x0000ffff);
- u = (v01 & 0xffff0000) | (v00 >> 16);
-
- // flip sign bits for u,v
- u ^= 0x80008000;
- v ^= 0x80008000;
-
- // save chroma
- dest[uoffset + (i>>1) + (j>>2)] = u;
- dest[voffset + (i>>1) + (j>>2)] = v;
- }
- }
-
-
-}
-
-#define CONVERT(x,y) ((x) + ((y)<<16))
-
-void pdp_llconv(void *src, int stype, void *dst, int dtype, int w, int h)
-{
- int conversion = CONVERT(stype, dtype);
- void *tmpbuf;
-
- switch(CONVERT(stype, dtype)){
-
- case CONVERT( RIF_YVU__P411_U8, RIF_YVU__P411_S16 ):
- llconv_yvu_planar_u8s16((unsigned char*)src, (short int *)dst, w*h);
- break;
-
- case CONVERT( RIF_YUV__P411_U8, RIF_YVU__P411_S16 ):
- llconv_yuv_planar_u8s16((unsigned char*)src, (short int *)dst, w*h);
- break;
-
- case CONVERT( RIF_YUYV_P____U8, RIF_YVU__P411_S16 ):
- llconv_yuyv_packed_u8s16((unsigned char*)src, (short int *)dst, w, h);
- break;
-
- case CONVERT( RIF_RGB__P____U8, RIF_YVU__P411_S16 ):
- llconv_rgb2yvu_planar16sub((unsigned char*) src, (short int*) dst, w, h);
- break;
-
- case CONVERT( RIF_YVU__P411_S16, RIF_YVU__P411_U8 ):
- llconv_yvu_planar_s16u8((short int*)src, (unsigned char*)dst, w*h);
- break;
-
- case CONVERT( RIF_GREY______S16, RIF_GREY______U8 ):
- llconv_grey_s16u8((short int*)src, (unsigned char*)dst, w*h);
- break;
- default:
- post("pdp_llconv: WARNING: no conversion routine defined for (%d)->(%d)", stype, dtype);
-
- }
-
-}
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_llconv_mmx.c b/system/pdp_llconv_mmx.c
deleted file mode 100644
index 8070bac..0000000
--- a/system/pdp_llconv_mmx.c
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/*
- * Pure Data Packet system implementation. : wrapper for mmx low level format conversion code
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-
-
-#include "pdp_mmx.h"
-
-
-
-/* convert greyscale 8 bit unsigned to 16bit signed */
-void llconv_grey_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- pixel_pack_s16u8_y(src, dst, nbpixels>>3);
-}
-
-/* convert yvu planar 411 16 bit signed to 8 bit unsigned */
-void llconv_yvu_planar_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- pixel_pack_s16u8_y(src, dst, nbpixels>>3);
- pixel_pack_s16u8_uv(src + nbpixels, dst + nbpixels, nbpixels>>4);
-}
-
-
-/* convert yvu planar 411 8 bit unsigned to yv12 planar 16bit signed */
-void llconv_yvu_planar_u8s16(unsigned char* source, short int *dest, int nbpixels)
-{
- pixel_unpack_u8s16_y(source, dest, nbpixels>>3);
- pixel_unpack_u8s16_uv(&source[nbpixels], &dest[nbpixels], nbpixels>>4);
-}
-
-/* convert yuv planar 411 8 bit unsigned to yv12 planar 16bit signed */
-void llconv_yuv_planar_u8s16(unsigned char* source, short int *dest, int nbpixels)
-{
- pixel_unpack_u8s16_y(source, dest, nbpixels>>3);
- pixel_unpack_u8s16_uv(&source[nbpixels], &dest[nbpixels + (nbpixels>>2)], nbpixels>>5);
- pixel_unpack_u8s16_uv(&source[nbpixels + (nbpixels>>2)], &dest[nbpixels], nbpixels>>5);
-}
-
diff --git a/system/pdp_llconv_portable.c b/system/pdp_llconv_portable.c
deleted file mode 100644
index de65ef5..0000000
--- a/system/pdp_llconv_portable.c
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/*
- * Pure Data Packet system implementation. : portable low level format conversion code
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-
-#define CLAMP(x) (((x)<0) ? 0 : ((x>255)? 255 : (x)))
-#define FP(x) ((int)(((float)(x)) * 256.0f))
-
-void pixel_unpack_portable_u8s16_y(unsigned char *src ,short int *dst, unsigned int nbpixels)
-{
- unsigned int i;
- for (i=0; i<nbpixels; i++) dst[i] = ((short int)(src[i])) << 7;
-}
-
-void pixel_unpack_portable_u8s16_uv(unsigned char *src ,short int *dst, unsigned int nbpixels)
-{
- unsigned int i;
- for (i=0; i<nbpixels; i++) dst[i] = (((short int)(src[i])) << 8) ^ 0x8000;
-}
-
-
-void pixel_pack_portable_s16u8_y(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- unsigned int i;
- for (i=0; i<nbpixels; i++) dst[i] = (unsigned char)(CLAMP(src[i]>>7));
-}
-
-void pixel_pack_portable_s16u8_uv(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- unsigned int i;
- for (i=0; i<nbpixels; i++) dst[i] = (unsigned char)((src[i]^0x8000)>>8);
-}
-
-
-/* convert greyscale 8 bit unsigned to 16bit signed */
-void llconv_grey_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- pixel_pack_portable_s16u8_y(src, dst, nbpixels);
-}
-
-/* convert yvu planar 411 16 bit signed to 8 bit unsigned */
-void llconv_yvu_planar_s16u8(short int *src, unsigned char *dst, unsigned int nbpixels)
-{
- pixel_pack_portable_s16u8_y(src, dst, nbpixels);
- pixel_pack_portable_s16u8_uv(src + nbpixels, dst + nbpixels, nbpixels>>1);
-
-}
-
-
-/* convert yvu planar 411 8 bit unsigned to yv12 planar 16bit signed */
-void llconv_yvu_planar_u8s16(unsigned char* source, short int *dest, int nbpixels)
-{
- pixel_unpack_portable_u8s16_y(source, dest, nbpixels);
- pixel_unpack_portable_u8s16_uv(&source[nbpixels], &dest[nbpixels], nbpixels>>1);
-}
-
-/* convert yuv planar 411 8 bit unsigned to yv12 planar 16bit signed */
-void llconv_yuv_planar_u8s16(unsigned char* source, short int *dest, int nbpixels)
-{
- pixel_unpack_portable_u8s16_y(source, dest, nbpixels);
- pixel_unpack_portable_u8s16_uv(&source[nbpixels], &dest[nbpixels + (nbpixels>>2)], nbpixels>>2);
- pixel_unpack_portable_u8s16_uv(&source[nbpixels + (nbpixels>>2)], &dest[nbpixels], nbpixels>>2);
-}
-
-
diff --git a/system/pdp_packet.c b/system/pdp_packet.c
deleted file mode 100644
index 894c443..0000000
--- a/system/pdp_packet.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Pure Data Packet system implementation:
- * code for allocation/deallocation/copying/...
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-#include "pdp.h"
-#include <stdio.h>
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* this needs to be able to grow dynamically, think about it later */
-#define PDP_OBJECT_ARRAY_SIZE 1024
-static t_pdp* pdp_stack[PDP_OBJECT_ARRAY_SIZE];
-
-
-/* some global vars */
-static t_symbol* pdp_sym_register_rw;
-static t_symbol* pdp_sym_register_ro;
-static t_symbol* pdp_sym_process;
-
-
-/* setup methods */
-
-void
-pdp_packet_setup(void)
-{
- bzero(pdp_stack, PDP_OBJECT_ARRAY_SIZE * sizeof(t_pdp *));
- pdp_sym_register_rw = gensym("register_rw");
- pdp_sym_register_ro = gensym("register_ro");
- pdp_sym_process = gensym("process");
-}
-
-void
-pdp_packet_destroy(void)
-{
- int i = 0;
- /* dealloc all the data in object stack */
- while ((i < PDP_OBJECT_ARRAY_SIZE) && (pdp_stack[i])) free(pdp_stack[i++]);
-}
-
-
-/* private pdp_mem methods */
-
-
-/* public object manips */
-
-
-/* alloc method: alloc time is linear in the number of used packets */
-/* think about a better (tree) method when this number grows large */
-int
-pdp_packet_new(unsigned int datatype, unsigned int datasize /*without header*/)
-{
- unsigned int totalsize = datasize + PDP_HEADER_SIZE;
- int i = 0;
- unsigned int align;
- t_pdp* p;
- for (i=0; i < PDP_OBJECT_ARRAY_SIZE; i++){
- p = pdp_stack[i];
- /* check if we can reuse this one if it is already allocated */
- if (p) {
- /* remark: if p->size >= totalsize we can give away the packet */
- /* but that would lead to unefficient use if we have a lot of packets */
- /* of different sizes */
- if ((p->users == 0) && (p->size == totalsize)){
- //post("pdp_new_object: can reuse %d", i);
- memset(p, 0, PDP_HEADER_SIZE); //initialize header to 0
- p->type = datatype;
- p->size = totalsize;
- p->users = 1;
- return i;
- }
- else{
- //post("pdp_new_object: can't reuse %d, (%d users)", i, p->users);
- //post("size:%d, newsize:%d, type:%d, newtype:%d", p->size, totalsize, p->type, datatype);
- }
- }
- /* allocate new one */
- else {
- p = (t_pdp *)malloc(totalsize);
- align = ((unsigned int)p) & (PDP_ALIGN - 1);
- if (align) post("pdp_new_object: warning data misaligned by %x", align);
- pdp_stack[i] = p;
- memset(p, 0, PDP_HEADER_SIZE); //initialize header to 0
- p->type = datatype;
- p->size = totalsize;
- p->users = 1;
- //post("pdp_new_object: allocating new (%d)", i);
- return i;
- }
- }
- post("pdp_new_object: WARNING: out of memory");
-
- return -1;
-
-}
-
-
-t_pdp*
-pdp_packet_header(int handle)
-{
- if ((handle >= 0) && (handle < PDP_OBJECT_ARRAY_SIZE)) return pdp_stack[handle];
- else return 0;
-}
-
-void*
-pdp_packet_data(int handle)
-{
- if ((handle >= 0) && (handle < PDP_OBJECT_ARRAY_SIZE))
- return (char *)(pdp_stack[handle]) + PDP_HEADER_SIZE;
- else return 0;
-}
-
-
-
-int
-pdp_packet_copy_ro(int handle)
-{
- int out_handle;
-
- t_pdp* p;
- if ((handle >= 0)
- && (handle < PDP_OBJECT_ARRAY_SIZE)
- && (p = pdp_stack[handle])){
- /* increase the number of users and return */
- p->users++;
- out_handle = handle;
- }
- else out_handle = -1;
-
- //post("pdp_copy_ro: outhandle:%d", out_handle);
-
- return out_handle;
-}
-
-int
-pdp_packet_copy_rw(int handle)
-{
- int out_handle;
-
- t_pdp* p;
- if ((handle >= 0)
- && (handle < PDP_OBJECT_ARRAY_SIZE)
- && (p = pdp_stack[handle])){
- /* if there are other users, copy the object otherwize return the same handle */
- if (p->users){
- int new_handle = pdp_packet_new(p->type, p->size - PDP_HEADER_SIZE);
- t_pdp* new_p = pdp_packet_header(new_handle);
- memcpy(new_p, p, p->size);
- new_p->users = 1;
- out_handle = new_handle;
- }
- else {
- p->users++;
- out_handle = handle;
- }
- //post("pdp_copy_rw: inhandle:%d outhandle:%d", handle, out_handle);
-
- }
- else out_handle = -1;
-
- return out_handle;
-}
-
-int
-pdp_packet_clone_rw(int handle)
-{
- int out_handle;
-
- t_pdp* p;
- if ((handle >= 0)
- && (handle < PDP_OBJECT_ARRAY_SIZE)
- && (p = pdp_stack[handle])){
-
- /* clone the packet header, don't copy the data */
- int new_handle = pdp_packet_new(p->type, p->size - PDP_HEADER_SIZE);
- t_pdp* new_p = pdp_packet_header(new_handle);
- memcpy(new_p, p, PDP_HEADER_SIZE);
- new_p->users = 1;
- out_handle = new_handle;
- }
-
- else out_handle = -1;
-
- return out_handle;
-}
-
-void
-pdp_packet_mark_unused(int handle)
-{
- t_pdp* p;
- if ((handle >= 0) && (handle < PDP_OBJECT_ARRAY_SIZE)){
- if (p = pdp_stack[handle]) {
- if (p->users) {
- p->users--;
- //post("pdp_mark_unused: handle %d, users left %d", handle, p->users);
- }
- else {
- post("pdp_mark_unused: WARNING: handle %d has zero users (duplicate pdp_mark_unused ?)", handle);
- }
- }
- else {
- post("pdp_mark_unused: WARNING: invalid handle %d: no associated object", handle);
- }
- }
-
- else {
- /* -1 is the only invalid handle that doesn't trigger a warning */
- if (handle != -1) post("pdp_mark_unused: WARNING: invalid handle %d: out of bound", handle);
- }
-
-
-}
-
-/* remark. if an owner frees a rw copy, he can still pass it along to clients.
-the first copy instruction revives the object. maybe free should not be called free but unregister.
-as long as no new_object method is called, or no copy on another object is performed,
-the "undead" copy can be revived. this smells a bit, i know...*/
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_queue.c b/system/pdp_queue.c
deleted file mode 100644
index fe3748e..0000000
--- a/system/pdp_queue.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Pure Data Packet - processor queue module.
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 is a the processor queue pdp system module
- it receives tasks from objects that are schedules to
- be computed in another thread. the object is signalled back
- when the task is completed.
-
- this is not a standard pd class. it is a sigleton class
- using a standard pd clock to poll for compleded methods on
- every scheduler run. this is a hack to do thread synchronization
- in a thread unsafe pd.
-
- */
-
-#include "pdp.h"
-#include <pthread.h>
-#include <unistd.h>
-#include <stdio.h>
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#define PDP_QUEUE_SIZE 1024
-#define PDP_QUEUE_DELTIME 1.0f;
-
-
-
-
-/********************* pdp process queue data *********************/
-
-typedef void (*t_pdpmethod)(void *client);
-
-/* the process queue data record */
-typedef struct process_queue_struct
-{
- void *x_owner; /* the object we are dealing with */
- t_pdpmethod x_process; /* the process method */
- t_pdpmethod x_callback; /* the function to be called when finished */
- int *x_queue_id; /* place to store the queue id for task */
-} t_process_queue;
-
-
-
-/* clock members */
-static t_clock *pdp_clock;
-static double deltime;
-
-/* some bookkeeping vars */
-static long long ticks;
-static long long packets;
-
-/* queue members */
-static t_process_queue *q; /* queue */
-static int mask;
-static int head; /* last entry in queue + 1 */
-static int tail; /* first entry in queque */
-static int curr; /* the object currently processed in other thread */
-
-/* pthread vars */
-static pthread_mutex_t mut;
-static pthread_cond_t cond_dataready;
-static pthread_cond_t cond_processingdone;
-static pthread_t thread_id;
-
-/* synchro pipes */
-static int pipe_fd[2];
-
-/* toggle for thread usage */
-static int use_thread;
-
-
-
-/* the methods */
-void pdp_queue_wait()
-{
- //post("pdp_pq_wait: waiting for pdp_queue_thread to finish processing");
- pthread_mutex_lock(&mut);
- while(((curr - head) & mask) != 0){
-
- pthread_cond_wait(&cond_processingdone, &mut);
- }
- pthread_mutex_unlock(&mut);
- //post("pdp_pq_wait: pdp_queue_thread has finished processing");
-
-}
-void pdp_queue_finish(int index)
-{
-
- if (-1 == index) {
- //post("pdp_pq_remove: index == -1");
- return;
- }
- /* wait for processing thread to finish*/
- pdp_queue_wait();
-
- /* invalidate callback at index */
- q[index & mask].x_callback = 0;
- q[index & mask].x_queue_id = 0;
-
-}
-
-static void pdp_queue_signal_processor(void)
-{
-
- pthread_mutex_lock(&mut);
- //post("signalling process thread");
- pthread_cond_signal(&cond_dataready);
- pthread_mutex_unlock(&mut);
- //post("signalling process thread done");
-
-}
-
-static void pdp_queue_wait_for_feeder(void)
-{
-
-
- /* only use locking when there is no data */
- if(((curr - head) & mask) == 0){
- pthread_mutex_lock(&mut);
-
- /* signal processing done */
- //post("pdp_queue_thread: signalling processing is done");
- pthread_cond_signal(&cond_processingdone);
-
- /* wait until there is an item in the queue */
- while(((curr - head) & mask) == 0){
- //post("waiting for feeder");
- pthread_cond_wait(&cond_dataready, &mut);
- //post("waiting for feeder done");
- }
-
- pthread_mutex_unlock(&mut);
-
- }
-}
-
-void pdp_queue_add(void *owner, void *process, void *callback, int *queue_id)
-{
- int i;
-
- /* if processing is in not in thread, just call the funcs */
- if (!use_thread){
- //post("pdp_queue_add: calling processing routine directly");
- *queue_id = -1;
- ((t_pdpmethod) process)(owner);
- ((t_pdpmethod) callback)(owner);
- return;
- }
-
-
-
- /* schedule method in thread queue */
- if (1 == ((tail - head) & mask)) {
- post("pdp_queue_add: WARNING: processing queue is full.\n");
- post("pdp_queue_add: WARNING: skipping process method, calling callback directly.\n");
- *queue_id = -1;
- ((t_pdpmethod) callback)(owner);
- }
-
-
-
- i = head & mask;
- q[i].x_owner = owner;
- q[i].x_process = process;
- q[i].x_callback = callback;
- q[i].x_queue_id = queue_id;
- *queue_id = i;
- //post("pdp_queue_add: added method to queue, index %d", i);
-
-
- // increase the packet count
- packets++;
-
- // move head forward
- head++;
-
- pdp_queue_signal_processor();
-
-}
-
-
-/* processing thread */
-static void *pdp_queue_thread(void *dummy)
-{
- while(1){
-
-
- /* wait until there is data available */
- pdp_queue_wait_for_feeder();
-
-
- //post("pdp_queue_thread: processing %d", curr);
-
-
- /* call the process routine */
- (q[curr & mask].x_process)(q[curr & mask].x_owner);
-
- /* advance */
- curr++;
-
-
- }
-}
-
-
-/* call back all the callbacks */
-static void pdp_queue_callback (void)
-{
-
- /* call callbacks for finished packets */
- while(0 != ((curr - tail) & mask))
- {
- int i = tail & mask;
- /* invalidate queue id */
- if(q[i].x_queue_id) *q[i].x_queue_id = -1;
- /* call callback */
- if(q[i].x_callback) (q[i].x_callback)(q[i].x_owner);
- //else post("pdp_pq_tick: callback %d is disabled",i );
- tail++;
- }
-
-}
-
-/* the clock method */
-static void pdp_queue_tick (void)
-{
- /* do work */
- //if (!(ticks % 1000)) post("pdp tick %d", ticks);
-
- if (!use_thread) return;
-
- /* call callbacks */
- pdp_queue_callback();
-
- /* increase counter */
- ticks++;
-
- /* set clock for next update */
- clock_delay(pdp_clock, deltime);
-}
-
-
-void pdp_queue_use_thread(int t)
-{
- /* if thread usage is being disabled,
- wait for thread to finish processing first */
- if (t == 0) {
- pdp_queue_wait();
- use_thread = 0;
- pdp_queue_callback();
- clock_unset(pdp_clock);
- }
- else {
- clock_unset(pdp_clock);
- clock_delay(pdp_clock, deltime);
- use_thread = 1;
- }
-
-}
-
-void pdp_queue_setup(void)
-{
- pthread_attr_t attr;
-
- /* setup pdp queue processor object */
- ticks = 0;
- deltime = PDP_QUEUE_DELTIME;
-
- /* setup queue data */
- mask = PDP_QUEUE_SIZE - 1;
- head = 0;
- tail = 0;
- curr = 0;
- q = getbytes(PDP_QUEUE_SIZE * sizeof(*q));
-
- /* enable threads */
- use_thread = 1;
-
- /* setup synchro stuff */
- pthread_mutex_init(&mut, NULL);
- pthread_cond_init(&cond_dataready, NULL);
- pthread_cond_init(&cond_processingdone, NULL);
-
-
- /* allocate the clock */
- pdp_clock = clock_new(0, (t_method)pdp_queue_tick);
-
- /* set the clock */
- clock_delay(pdp_clock, 0);
-
- /* start processing thread */
-
- /* glibc doc says SCHED_OTHER is default,
- but it seems not to be when initiated from a RT thread
- so we explicitly set it here */
- pthread_attr_init (&attr);
- //pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
- pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
- pthread_create(&thread_id, &attr, pdp_queue_thread, (void *)0);
-
-
-
- /* set default disable/enable thread here */
- pdp_queue_use_thread(0);
-
-}
-
-
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_resample.c b/system/pdp_resample.c
deleted file mode 100644
index 16a34df..0000000
--- a/system/pdp_resample.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Pure Data Packet system file. - image resampling routines
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-
-
-#include "pdp_resample.h"
-#include "pdp.h"
-
-/*
-
-efficient bilinear resampling ??
-performance: how to eliminate divides? -> virtual coordinates 2^k x 2^k (conf. opengl)
-
-i.e. 16 bit virtual coordinates: easy modular addressing
-
-*/
-
-
-/* code in this file should go out to be replaced by code in pdp_imageproc */
-
-static s32 pdp_resample_bilin(s16 *image, s32 width, s32 height, s32 virt_x, s32 virt_y)
-{
-
- s32 fp_x, fp_y, frac_x, frac_y, f, offset, r_1, r_2;
-
- virt_x &= 0xffff;
- virt_y &= 0xffff;
-
- fp_x = virt_x * (width - 1);
- fp_y = virt_y * (height - 1);
-
- frac_x = fp_x & (0xffff);
- frac_y = fp_y & (0xffff);
-
- offset = (fp_x >> 16) + (fp_y >> 16) * width;
- image += offset;
-
- f = 0x10000 - frac_x;
-
- r_1 = ((f * (s32)(image[0]) + frac_x * (s32)(image[1])))>>16;
-
- image += width;
-
- r_2 = ((f * (s32)(image[0]) + frac_x * (s32)(image[1])))>>16;
-
- f = 0x10000 - frac_y;
-
- return ((f * r_1 + frac_y * r_2)>>16);
-
-}
-
-
-void pdp_resample_scale_bilin(s16 *src_image, s16 *dst_image, s32 src_w, s32 src_h, s32 dst_w, s32 dst_h)
-{
- s32 i,j;
- s32 virt_x=0;
- s32 virt_y=0; /* virtual coordinates in 30 bit */
- s32 scale_x = 0x40000000 / dst_w;
- s32 scale_y = 0x40000000 / dst_h;
-
- for (j=0; j<dst_h; j++){
- for (i=0; i<dst_w; i++){
- *dst_image++ = pdp_resample_bilin(src_image, src_w, src_h, virt_x>>14, virt_y>>14);
- virt_x += scale_x;
- }
- virt_x = 0;
- virt_y += scale_y;
- }
-
-}
-
-void pdp_resample_scale_nn(s16 *src_image, s16 *dst_image, s32 src_w, s32 src_h, s32 dst_w, s32 dst_h)
-{
- s32 i,j;
- s32 x=0;
- s32 y=0;
- s32 frac_x=0;
- s32 frac_y=0;
- s32 scale_x = (src_w << 20 ) / dst_w;
- s32 scale_y = (src_h << 20 ) / dst_h;
-
- for (j=0; j<dst_h; j++){
- for (i=0; i<dst_w; i++){
- *dst_image++ = src_image[x+y];
- frac_x += scale_x;
- x = frac_x >> 20;
- }
- x = 0;
- frac_x = 0;
- frac_y += scale_y;
- y = (frac_y >> 20) * src_w;
- }
-
-}
-
-/* USE pdp_resample_affinemap
-void pdp_resample_zoom_tiled_bilin(s16 *src_image, s16 *dst_image, s32 w, s32 h,
- float zoom_x, float zoom_y, float center_x_relative, float center_y_relative)
-{
- float izx = 1.0f / zoom_x;
- float izy = 1.0f / zoom_y;
- s32 scale_x = (s32)((float)0x100000 * izx / (float)w);
- s32 scale_y = (s32)((float)0x100000 * izy / (float)h);
-
- s32 top_virt_x = (s32)((1.0f - izx) * (float)0x100000 * center_x_relative);
- s32 top_virt_y = (s32)((1.0f - izy) * (float)0x100000 * center_y_relative);
-
- s32 virt_x = top_virt_x;
- s32 virt_y = top_virt_y;
-
- s32 i,j;
-
- for (j=0; j<h; j++){
- for (i=0; i<w; i++){
- *dst_image++ = pdp_resample_bilin(src_image, w, h, virt_x>>4, virt_y>>4);
- virt_x += scale_x;
- }
- virt_x = top_virt_x;
- virt_y += scale_y;
- }
-
-}
-*/
-
-
-void pdp_resample_halve(s16 *src_image, s16 *dst_image, s32 src_w, s32 src_h)
-{
-
- int dst_x,dst_y;
- int src_x = 0;
- int src_y = 0;
- int dst_w = src_w >> 1;
- int dst_h = src_h >> 1;
- s32 tmp1,tmp2,tmp3,tmp4;
-
- for(dst_y = 0; dst_y < dst_h * dst_w; dst_y += dst_w){
- for (dst_x = 0; dst_x < dst_w; dst_x++){
-
- tmp1 = (s32)src_image[src_y + src_x];
- tmp2 = (s32)src_image[src_y + src_x + 1];
- tmp3 = (s32)src_image[src_y + src_x + src_w];
- tmp4 = (s32)src_image[src_y + src_x + src_w + 1];
-
- tmp1 += tmp2;
- tmp3 += tmp4;
-
- src_x += 2;
-
- dst_image[dst_x+dst_y] = (s16)((tmp1 + tmp3)>>2);
- }
- src_y += src_w << 1;
- src_x = 0;
- }
-}
diff --git a/system/pdp_type.c b/system/pdp_type.c
deleted file mode 100644
index b23b9cd..0000000
--- a/system/pdp_type.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Pure Data Packet system implementation. : code for handling different packet types
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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.
- *
- */
-#include "pdp.h"
-#include <stdio.h>
-
-/* all symbols are C style */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-/****************** packet type checking methods ********************/
-
-
-/* check if two packets are allocated and of the same type */
-int pdp_type_compat(int packet0, int packet1)
-{
-
- t_pdp *header0 = pdp_packet_header(packet0);
- t_pdp *header1 = pdp_packet_header(packet1);
-
- if (!(header1)){
- //post("pdp_type_compat: invalid header packet1");
- return 0;
- }
- if (!(header0)){
- //post("pdp_type_compat: invalid header packet 0");
- return 0;
- }
- if (header0->type != header1->type){
- //post("pdp_type_compat: types do not match");
- return 0;
- }
-
- return 1;
-}
-
-/* check if two image packets are allocated and of the same type */
-int pdp_type_compat_image(int packet0, int packet1)
-{
- t_pdp *header0 = pdp_packet_header(packet0);
- t_pdp *header1 = pdp_packet_header(packet1);
-
-
- if (!(pdp_type_compat(packet0, packet1))) return 0;
- if (header0->type != PDP_IMAGE){
- //post("pdp_type_compat_image: not a PDP_IMAGE");
- return 0;
- }
- if (header0->info.image.encoding != header1->info.image.encoding){
- //post("pdp_type_compat_image: encodings differ");
- return 0;
- }
- if (header0->info.image.width != header1->info.image.width){
- //post("pdp_type_compat_image: image withs differ");
- return 0;
- }
- if (header0->info.image.height != header1->info.image.height){
- //post("pdp_type_compat_image: image heights differ");
- return 0;
- }
- return 1;
-}
-
-/* check if packet is a valid image packet */
-int pdp_type_isvalid_image(int packet)
-{
- t_pdp *header = pdp_packet_header(packet);
- if (!header) return 0;
- if (PDP_IMAGE != header->type) return 0;
- if ((PDP_IMAGE_YV12 != header->info.image.encoding)
- && (PDP_IMAGE_GREY != header->info.image.encoding)) return 0;
-
- return 1;
-
-}
-
-
-
-int pdp_packet_new_image_yv12(u32 w, u32 h)
-{
- t_pdp *header;
- int packet;
-
-
- u32 size = w*h;
- u32 totalnbpixels = size + (size >> 1);
- u32 packet_size = totalnbpixels << 1;
-
- packet = pdp_packet_new(PDP_IMAGE, packet_size);
- header = pdp_packet_header(packet);
-
- header->info.image.encoding = PDP_IMAGE_YV12;
- header->info.image.width = w;
- header->info.image.height = h;
-
- return packet;
-}
-
-int pdp_packet_new_image_grey(u32 w, u32 h)
-{
- t_pdp *header;
- int packet;
-
-
- u32 size = w*h;
- u32 totalnbpixels = size;
- u32 packet_size = totalnbpixels << 1;
-
- packet = pdp_packet_new(PDP_IMAGE, packet_size);
- header = pdp_packet_header(packet);
-
- header->info.image.encoding = PDP_IMAGE_GREY;
- header->info.image.width = w;
- header->info.image.height = h;
-
- return packet;
-}
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/system/pdp_ut.c b/system/pdp_ut.c
deleted file mode 100644
index 83b4cb0..0000000
--- a/system/pdp_ut.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Pure Data Packet - Utility toolkit objects.
- * Copyright (c) by Tom Schouten <pdp@zzz.kotnet.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
- * 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 some small utility pd objects that make working with
- pdp objects a lot easier. Mainly as glue to be used in the abstractions
- in the distro. */
-
-#include "pdp.h"
-#include <math.h>
-
-/* this object does an add, scale, clip operation */
-
-t_class *pdp_ut_addscaleclip_class;
-
-typedef struct pdp_ut_addscaleclip_struct
-{
- t_object x_obj;
- t_outlet *x_outlet0;
- t_float x_min;
- t_float x_max;
- t_float x_offset;
- t_float x_scale;
-} t_pdp_ut_addscaleclip;
-
-
-static void pdp_ut_addscaleclip_float(t_pdp_ut_addscaleclip *x, t_floatarg f)
-{
- f += x->x_offset;
- f *= x->x_scale;
- f = (f < x->x_min) ? x->x_min : f;
- f = (f > x->x_max) ? x->x_max : f;
- outlet_float(x->x_outlet0, f);
-}
-
-static void pdp_ut_addscaleclip_free(t_pdp_ut_addscaleclip *x){}
-
-void *pdp_ut_addscaleclip_new(t_floatarg offset, t_floatarg scale, t_floatarg min, t_floatarg max)
-{
- t_pdp_ut_addscaleclip *x = (t_pdp_ut_addscaleclip *)pd_new(pdp_ut_addscaleclip_class);
- x->x_outlet0 = outlet_new(&x->x_obj, &s_float);
- x->x_offset = offset;
- x->x_scale = scale;
- x->x_min = min;
- x->x_max = max;
- return (void *)x;
-}
-
-void pdp_ut_addscaleclip_setup(void)
-{
- pdp_ut_addscaleclip_class = class_new(gensym("pdp_ut_addscaleclip"), (t_newmethod)pdp_ut_addscaleclip_new,
- (t_method)pdp_ut_addscaleclip_free, sizeof(t_pdp_ut_addscaleclip), 0,
- A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL);
- class_addfloat(pdp_ut_addscaleclip_class, pdp_ut_addscaleclip_float);
-}
-
-
-/* pdp_ut_logmap does a logarithmic parameter mapping [0->1] x -> min(max/min)^x max an add, scale, clip operation */
-/* pdp_ut_logmap_comp does x -> min(max/min)^(1-x) */
-/* pdp_ut_linmap dos x -> min + (max - min * x */
-
-t_class *pdp_ut_linmap_class;
-t_class *pdp_ut_logmap_class;
-t_class *pdp_ut_logmap_comp_class;
-
-typedef struct pdp_ut_map_struct
-{
- t_object x_obj;
- t_outlet *x_outlet0;
- t_float x_min;
- t_float x_max;
-} t_pdp_ut_map;
-
-
-static void pdp_ut_logmap_float(t_pdp_ut_map *x, t_floatarg f)
-{
- f = (f < 0.0f) ? 0.0f : f;
- f = (f > 1.0f) ? 1.0f : f;
-
- f = x->x_min * pow((x->x_max / x->x_min), f);
-
- outlet_float(x->x_outlet0, f);
-}
-
-static void pdp_ut_linmap_float(t_pdp_ut_map *x, t_floatarg f)
-{
- f = (f < 0.0f) ? 0.0f : f;
- f = (f > 1.0f) ? 1.0f : f;
-
- f = x->x_min + ((x->x_max - x->x_min) * f);
-
- outlet_float(x->x_outlet0, f);
-}
-
-static void pdp_ut_logmap_comp_float(t_pdp_ut_map *x, t_floatarg f)
-{
- f = (f < 0.0f) ? 0.0f : f;
- f = (f > 1.0f) ? 1.0f : f;
-
- f = x->x_min * pow((x->x_max / x->x_min), (1.0f - f));
-
- outlet_float(x->x_outlet0, f);
-}
-
-static void pdp_ut_map_free(t_pdp_ut_map *x){}
-
-
-void pdp_ut_map_init(t_pdp_ut_map *x, t_floatarg min, t_floatarg max)
-{
- x->x_outlet0 = outlet_new(&x->x_obj, &s_float);
- x->x_min = min;
- x->x_max = max;
-}
-
-void *pdp_ut_logmap_new(t_floatarg min, t_floatarg max)
-{
- t_pdp_ut_map *x = (t_pdp_ut_map *)pd_new(pdp_ut_logmap_class);
- pdp_ut_map_init(x, min, max);
- return (void *)x;
-}
-
-void *pdp_ut_linmap_new(t_floatarg min, t_floatarg max)
-{
- t_pdp_ut_map *x = (t_pdp_ut_map *)pd_new(pdp_ut_linmap_class);
- pdp_ut_map_init(x, min, max);
- return (void *)x;
-}
-
-void *pdp_ut_logmap_comp_new(t_floatarg min, t_floatarg max)
-{
- t_pdp_ut_map *x = (t_pdp_ut_map *)pd_new(pdp_ut_logmap_comp_class);
- pdp_ut_map_init(x, min, max);
- return (void *)x;
-}
-
-void pdp_ut_logmap_setup(void)
-{
- pdp_ut_logmap_class = class_new(gensym("pdp_ut_logmap"), (t_newmethod)pdp_ut_logmap_new,
- (t_method)pdp_ut_map_free, sizeof(t_pdp_ut_map), 0,
- A_FLOAT, A_FLOAT, A_NULL);
- class_addfloat(pdp_ut_logmap_class, pdp_ut_logmap_float);
-}
-
-void pdp_ut_logmap_comp_setup(void)
-{
- pdp_ut_logmap_comp_class = class_new(gensym("pdp_ut_logmap_comp"), (t_newmethod)pdp_ut_logmap_comp_new,
- (t_method)pdp_ut_map_free, sizeof(t_pdp_ut_map), 0,
- A_FLOAT, A_FLOAT, A_NULL);
- class_addfloat(pdp_ut_logmap_comp_class, pdp_ut_logmap_comp_float);
-}
-
-void pdp_ut_linmap_setup(void)
-{
- pdp_ut_linmap_class = class_new(gensym("pdp_ut_linmap"), (t_newmethod)pdp_ut_linmap_new,
- (t_method)pdp_ut_map_free, sizeof(t_pdp_ut_map), 0,
- A_FLOAT, A_FLOAT, A_NULL);
- class_addfloat(pdp_ut_linmap_class, pdp_ut_linmap_float);
-}
-
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-void pdp_ut_setup(void)
-{
- pdp_ut_addscaleclip_setup();
- pdp_ut_logmap_setup();
- pdp_ut_logmap_comp_setup();
- pdp_ut_linmap_setup();
-}
-
-
-#ifdef __cplusplus
-}
-#endif