aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
committerTom Schouten <doelie@users.sourceforge.net>2006-09-01 13:45:31 +0000
commit7591a024f184bd385d35583d19d86c1d5f2531ba (patch)
tree77aa0c44ccb700eb9a2b16e1b246e3c8026c40ed /system
parent91dd6b68f0f209ad015a303095bb1df018dca71e (diff)
pdp current darcs merge
svn path=/trunk/externals/pdp/; revision=5816
Diffstat (limited to 'system')
-rw-r--r--system/image/pdp_imageproc_portable.c6
-rw-r--r--system/kernel/pdp_list.c4
-rw-r--r--system/kernel/pdp_mem.c19
-rw-r--r--system/kernel/pdp_packet.c38
-rw-r--r--system/kernel/pdp_post.c4
-rw-r--r--system/kernel/pdp_type.c2
-rw-r--r--system/mmx/pixel_biquad_s16.s4
-rw-r--r--system/pdp.c13
-rw-r--r--system/png/pdp_png.c6
-rw-r--r--system/type/pdp_bitmap.c70
-rw-r--r--system/type/pdp_image.c5
11 files changed, 145 insertions, 26 deletions
diff --git a/system/image/pdp_imageproc_portable.c b/system/image/pdp_imageproc_portable.c
index 112f729..facb2c8 100644
--- a/system/image/pdp_imageproc_portable.c
+++ b/system/image/pdp_imageproc_portable.c
@@ -494,7 +494,7 @@ void pdp_imageproc_random_setseed(void *x, float seed)
void pdp_imageproc_random_process(void *x, u32 width, u32 height, short int *image)
{
- s32 *d = (u32 *)x;
+ u32 *d = (u32 *)x;
u32 i;
s32 r;
srandom(d[0]);
@@ -586,8 +586,8 @@ void pdp_imageproc_resample_affinemap_process(void *x, u32 width, u32 height, s1
double s = sin(angle);
/* affine x, y mappings in screen coordinates */
- double mapx(double x, double y){return cx + izx * ( c * (x-cx) + s * (y-cy));}
- double mapy(double x, double y){return cy + izy * (-s * (x-cx) + c * (y-cy));}
+ double mapx(double _x, double _y){return cx + izx * ( c * (_x-cx) + s * (_y-cy));}
+ double mapy(double _x, double _y){return cy + izy * (-s * (_x-cx) + c * (_y-cy));}
u32 colstate_x = (u32)(scalew * mapx(0,0));
u32 colstate_y = (u32)(scaleh * mapy(0,0));
diff --git a/system/kernel/pdp_list.c b/system/kernel/pdp_list.c
index deeb7f1..8558e35 100644
--- a/system/kernel/pdp_list.c
+++ b/system/kernel/pdp_list.c
@@ -760,10 +760,10 @@ void pdp_list_pop_push(t_pdp_list *source, t_pdp_list *dest)
/* return element at index */
-t_pdp_word pdp_list_index(t_pdp_list *l, int index)
+t_pdp_word pdp_list_index(t_pdp_list *l, int indx)
{
t_pdp_atom *a;
- for (a = l->first; index--; a = a->next);
+ for (a = l->first; indx--; a = a->next);
return a->w;
}
diff --git a/system/kernel/pdp_mem.c b/system/kernel/pdp_mem.c
index 33822ef..93c7122 100644
--- a/system/kernel/pdp_mem.c
+++ b/system/kernel/pdp_mem.c
@@ -19,9 +19,14 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include "pdp_mem.h"
#include "pdp_debug.h"
+// defined here so we don't need to rebuild when changing it (deps for headers are broken)
+#define PDP_FASTALLOC_BLOCK_ELEMENTS 4096
+//#define PDP_FASTALLOC_BLOCK_ELEMENTS 1
+#define D if (0)
/* malloc wrapper that calls garbage collector */
void *pdp_alloc(int size)
@@ -30,6 +35,8 @@ void *pdp_alloc(int size)
PDP_ASSERT(ptr);
+ D fprintf(stderr, "alloc %p %d\n", ptr, size);
+
return ptr;
//TODO: REPAIR THIS
@@ -41,6 +48,7 @@ void *pdp_alloc(int size)
void pdp_dealloc(void *stuff)
{
+ D fprintf(stderr, "dealloc %p\n", stuff);
free (stuff);
}
@@ -87,6 +95,10 @@ static void _pdp_fastalloc_refill_freelist(t_pdp_fastalloc *x)
}
+#define USE_FASTALLOC 1
+
+#if USE_FASTALLOC
+
void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x)
{
t_fastalloc *atom;
@@ -127,3 +139,10 @@ t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size)
return x;
}
+#else
+
+void *pdp_fastalloc_new_atom(t_pdp_fastalloc *x) {return pdp_alloc(12);}
+void pdp_fastalloc_save_atom(t_pdp_fastalloc *x, void *atom) {pdp_dealloc(atom);}
+t_pdp_fastalloc *pdp_fastalloc_new(unsigned int size) {return 0;}
+
+#endif
diff --git a/system/kernel/pdp_packet.c b/system/kernel/pdp_packet.c
index 0eb569a..e5f1a1f 100644
--- a/system/kernel/pdp_packet.c
+++ b/system/kernel/pdp_packet.c
@@ -32,6 +32,8 @@
#include "pdp_debug.h"
+#define D if(0)
+
/* packet implementation. contains class and packet (instance) handling
some notes on packet operations.
@@ -152,6 +154,7 @@ int pdp_factory_newpacket(t_pdp_symbol *type)
/* call class constructor */
while(a){
+ D pdp_post("new: %s", type->s_name);
c = (t_pdp_class *)(a->w.w_pointer);
if (c->type && pdp_type_description_match(type, c->type)){
//pdp_post("method %x, type %s", c->create, type->s_name);
@@ -287,6 +290,15 @@ pdp_packet_create(unsigned int datatype, unsigned int datasize /*without header*
*/
+/* NEW DOES NOT USE THE REUSE FIFO !!!!
+ this is a true and genuine mess:
+ the reuse fifo can grow indefinitely with garbage elements if it's never used,
+ while it points to stale packets.. backdoor access = BAD.
+
+ if i recall, this is mainly a compatibility issue..
+
+*/
+
int
pdp_packet_new(unsigned int datatype, unsigned int datasize)
{
@@ -327,6 +339,9 @@ pdp_packet_new(unsigned int datatype, unsigned int datasize)
void
_pdp_packet_save_nolock(int packet)
{
+
+
+
t_pdp *header = pdp_packet_header(packet);
t_pdp_symbol *s;
PDP_ASSERT(header);
@@ -334,7 +349,30 @@ _pdp_packet_save_nolock(int packet)
PDP_ASSERT(header->desc);
s = header->desc;
if (!s->s_reusefifo) s->s_reusefifo = pdp_list_new(0);
+
+
+ /* big o hack: since pdp_packet_new can reap packets behind our back,
+ we won't add a packet if it's already in here */
+
+ if (1) {
+ t_pdp_atom *a = s->s_reusefifo->first;
+ while (a){
+ if (a->w.w_packet == packet) goto found;
+ a = a->next;
+ }
+ }
+
pdp_list_add(s->s_reusefifo, a_packet, (t_pdp_word)packet);
+
+ found:
+
+
+
+ if (PDP_DEBUG){
+ int el = s->s_reusefifo->elements;
+ int maxel = 100;
+ if (el > maxel) pdp_post("WARNING: %s reuse fifo has %d elements.", s->s_name, el);
+ }
}
/* this will revive a packet matching a certain type description
diff --git a/system/kernel/pdp_post.c b/system/kernel/pdp_post.c
index fb761d0..b75283b 100644
--- a/system/kernel/pdp_post.c
+++ b/system/kernel/pdp_post.c
@@ -29,14 +29,14 @@
/* list printing should be moved here too */
/* write a message to log (console) */
-void pdp_post_n(char *fmt, ...)
+void _pdp_post_n(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
}
-void pdp_post(char *fmt, ...)
+void _pdp_post(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
diff --git a/system/kernel/pdp_type.c b/system/kernel/pdp_type.c
index 0216d07..57edc00 100644
--- a/system/kernel/pdp_type.c
+++ b/system/kernel/pdp_type.c
@@ -342,7 +342,7 @@ int _pdp_packet_convert(int packet, t_pdp_symbol *dest_template)
return -1;
}
if (program_last == program_tail){
- pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
+ //pdp_post("ERROR: pdp_packet_convert: conversion loop detected");
}
program_last = program_tail;
diff --git a/system/mmx/pixel_biquad_s16.s b/system/mmx/pixel_biquad_s16.s
index 844b041..ef48c87 100644
--- a/system/mmx/pixel_biquad_s16.s
+++ b/system/mmx/pixel_biquad_s16.s
@@ -124,7 +124,7 @@
# %mm0 == {a0 b0 c0 d0}
- .macro antitranspose_4x4:
+ .macro antitranspose_4x4
movq %mm3, %mm4
punpcklwd %mm1, %mm4 # mm4 <- {b2 d2 b3 d3}
movq %mm3, %mm5
@@ -163,7 +163,7 @@
# %mm0 == {d0 c0 b0 a0}
- .macro transpose_4x4:
+ .macro transpose_4x4
movq %mm0, %mm4
punpcklwd %mm2, %mm4 # mm4 <- {c1 a1 c0 a0}
movq %mm0, %mm5
diff --git a/system/pdp.c b/system/pdp.c
index d74323b..4f8962d 100644
--- a/system/pdp.c
+++ b/system/pdp.c
@@ -22,6 +22,7 @@
#include "pdp_config.h"
#include "pdp_post.h"
+static int initialized = 0;
/* all symbols are C style */
#ifdef __cplusplus
@@ -91,6 +92,7 @@ void pdp_udp_send_setup(void);
void pdp_udp_receive_setup(void);
void pdp_rawin_setup(void);
void pdp_rawout_setup(void);
+void pdp_metro_setup(void);
/* hacks */
@@ -105,11 +107,13 @@ void pdp_dpd_test_setup(void);
/* library setup routine */
void pdp_setup(void){
- /* babble */
- pdp_post ("PDP: pure data packet");
+ if (initialized) return;
+ /* babble */
#ifdef PDP_VERSION
- pdp_post("PDP: version " PDP_VERSION );
+ pdp_post("PDP: pure data packet version " PDP_VERSION );
+#else
+ pdp_post ("PDP: pure data packet");
#endif
@@ -175,6 +179,7 @@ void pdp_setup(void){
pdp_array_setup();
pdp_rawin_setup();
pdp_rawout_setup();
+ pdp_metro_setup();
/* experimental stuff */
@@ -220,7 +225,7 @@ void pdp_setup(void){
pdp_glx_setup();
#endif
-
+ initialized++;
}
diff --git a/system/png/pdp_png.c b/system/png/pdp_png.c
index f751912..9ac2825 100644
--- a/system/png/pdp_png.c
+++ b/system/png/pdp_png.c
@@ -88,7 +88,7 @@ static int _cleanup(t_png_image *x)
static int _open_read(t_png_image* x, char *file)
{
- char header[SIG_BYTES];
+ unsigned char header[SIG_BYTES];
int is_png;
x->x_fp = fopen(file, "r");
@@ -243,7 +243,7 @@ static int _buildstruct_write(t_png_image *x)
static int _getimagedata(t_png_image *x)
{
int nbchans = 0;
- char *image_data;
+ unsigned char *image_data;
png_bytep row_pointers[x->x_height];
png_uint_32 i;
@@ -277,7 +277,7 @@ static int _saveimagedata(t_png_image *x, int packet)
png_uint_32 i;
int nbchans;
t_pdp *h = pdp_packet_header(packet);
- char *image_data = (char *)pdp_packet_data(packet);
+ unsigned char *image_data = (unsigned char *)pdp_packet_data(packet);
if (!h) return 0;
if (PDP_BITMAP != h->type) return 0;
diff --git a/system/type/pdp_bitmap.c b/system/type/pdp_bitmap.c
index 8a30d3e..9265879 100644
--- a/system/type/pdp_bitmap.c
+++ b/system/type/pdp_bitmap.c
@@ -71,6 +71,7 @@ t_pdp_symbol *pdp_packet_bitmap_get_description(int packet)
case PDP_BITMAP_RGBA: c += sprintf(c, "/rgba"); break;
case PDP_BITMAP_GREY: c += sprintf(c, "/grey"); break;
case PDP_BITMAP_YV12: c += sprintf(c, "/yv12"); break;
+ case PDP_BITMAP_I420: c += sprintf(c, "/i420"); break;
default:
c += sprintf(c, "/unknown"); goto exit;
}
@@ -110,6 +111,17 @@ int pdp_packet_new_bitmap_yv12(u32 w, u32 h)
return packet;
}
+int pdp_packet_new_bitmap_i420(u32 w, u32 h){
+ int p = pdp_packet_new_bitmap_yv12(w,h);
+ if (-1 == p) return -1;
+ t_pdp *header = pdp_packet_header(p);
+ t_bitmap *bitmap = pdp_packet_subheader(p);
+ bitmap->encoding = PDP_BITMAP_I420;
+ header->desc = 0; // structured programming.. ha!
+ header->desc = pdp_packet_bitmap_get_description(p);
+ return p;
+}
+
int pdp_packet_new_bitmap_grey(u32 w, u32 h)
{
t_pdp *header;
@@ -189,6 +201,7 @@ int pdp_packet_new_bitmap(int type, u32 w, u32 h)
switch(type){
case PDP_BITMAP_GREY: return pdp_packet_new_bitmap_grey(w,h);
case PDP_BITMAP_YV12: return pdp_packet_new_bitmap_yv12(w,h);
+ case PDP_BITMAP_I420: return pdp_packet_new_bitmap_i420(w,h);
case PDP_BITMAP_RGB: return pdp_packet_new_bitmap_rgb(w,h);
case PDP_BITMAP_RGBA: return pdp_packet_new_bitmap_rgba(w,h);
default: return -1;
@@ -444,6 +457,39 @@ static int _pdp_packet_bitmap_convert_rgb8_to_mchp(int packet, t_pdp_symbol *des
return new_p;
}
+static int _pdp_packet_bitmap_convert_yv12_tofrom_i420(int packet, t_pdp_symbol *dest_template)
+{
+ t_pdp *header = pdp_packet_header(packet);
+ t_bitmap *in = pdp_packet_bitmap_info(packet);
+ int w = in->width;
+ int h = in->height;
+ int out_encoding;
+ if (in->encoding == PDP_BITMAP_YV12) out_encoding = PDP_BITMAP_I420;
+ else if (in->encoding == PDP_BITMAP_I420) out_encoding = PDP_BITMAP_YV12;
+ else return -1;
+
+ int new_p = pdp_packet_new_bitmap(out_encoding, w,h);
+ // t_pdp *out_h = pdp_packet_header(new_p);
+ // pdp_post("%x %s", out_encoding, out_h->desc->s_name);
+
+
+ if (-1 == new_p) return -1;
+ unsigned char *in_d = pdp_packet_data(packet);
+ unsigned char *out_d = pdp_packet_data(new_p);
+ int plane = w*h;
+ memcpy(out_d, in_d, plane);
+ out_d += plane;
+ in_d += plane;
+ plane /= 4;
+ memcpy(out_d, in_d+plane, plane);
+ memcpy(out_d+plane, in_d, plane);
+
+
+
+ return new_p;
+}
+
+
static int _pdp_packet_bitmap_convert_yv12_to_image(int packet, t_pdp_symbol *dest_template)
{
t_pdp *header = pdp_packet_header(packet);
@@ -463,11 +509,6 @@ static int _pdp_packet_bitmap_convert_yv12_to_image(int packet, t_pdp_symbol *de
return new_p;
}
-static inline u8 _map(s32 pixel){
- s32 mask = ~(pixel>>16);
- return ((pixel >> 7) & mask);
-}
-
static int _pdp_packet_bitmap_convert_mchp_to_rgb8(int packet, t_pdp_symbol *dest_template)
{
t_pdp *header = pdp_packet_header(packet);
@@ -480,6 +521,12 @@ static int _pdp_packet_bitmap_convert_mchp_to_rgb8(int packet, t_pdp_symbol *des
int nb_channels = image->depth;
int new_p, i;
+ // static inline u8 _map(s32 pixel){
+ inline u8 _map(s32 pixel){
+ s32 mask = ~(pixel>>16);
+ return ((pixel >> 7) & mask);
+ }
+
switch(nb_channels){
default: return -1;
case 1:
@@ -554,9 +601,9 @@ static int pdp_bitmap_factory(t_pdp_symbol *type)
p = pdp_packet_new_bitmap(t,w,h);
if (p != -1){
- t_pdp *h = pdp_packet_header(p);
+ t_pdp *header = pdp_packet_header(p);
/* if type is not exact, delete the packet */
- if (type != h->desc) {
+ if (type != header->desc) {
pdp_packet_delete(p);
p = -1;
}
@@ -587,6 +634,9 @@ void pdp_bitmap_setup(void)
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_image_to_yv12, 0);
pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/yv12/*"), program);
pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/yv12/*"), program);
+ pdp_type_register_conversion(pdp_gensym("image/YCrCb/*"), pdp_gensym("bitmap/*"), program);
+ pdp_type_register_conversion(pdp_gensym("image/grey/*"), pdp_gensym("bitmap/*"), program);
+
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_to_image, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("image/YCrCb/*"), program);
@@ -604,6 +654,11 @@ void pdp_bitmap_setup(void)
pdp_type_register_conversion(pdp_gensym("image/multi/*"), pdp_gensym("bitmap/*/*"), program);
+ /* yv12 <-> i420 */
+ program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_yv12_tofrom_i420, 0);
+ pdp_type_register_conversion(pdp_gensym("bitmap/yv12/*"), pdp_gensym("bitmap/i420/*"), program);
+ pdp_type_register_conversion(pdp_gensym("bitmap/i420/*"), pdp_gensym("bitmap/yv12/*"), program);
+
/* rgb <-> rgba */
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_rgba8, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("bitmap/rgba/*"), program);
@@ -611,6 +666,7 @@ void pdp_bitmap_setup(void)
pdp_type_register_conversion(pdp_gensym("bitmap/rgba/*"), pdp_gensym("bitmap/rgb/*"), program);
+
/* fallback rgb convertor */
program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_YCrCb, 0);
pdp_type_register_conversion(pdp_gensym("bitmap/rgb/*"), pdp_gensym("image/*/*"), program);
diff --git a/system/type/pdp_image.c b/system/type/pdp_image.c
index 66fe22b..29d2976 100644
--- a/system/type/pdp_image.c
+++ b/system/type/pdp_image.c
@@ -89,6 +89,7 @@ int pdp_packet_new_image_grey(u32 w, u32 h)
u32 size = w*h;
u32 totalnbpixels = size;
u32 packet_size = totalnbpixels << 1;
+ //pdp_post("grey %d x %d = %d bytes", w,h,packet_size);
_checkdim(w,h);
@@ -529,9 +530,9 @@ static int pdp_image_factory(t_pdp_symbol *type)
break;
}
if (p != -1){
- t_pdp *h = pdp_packet_header(p);
+ t_pdp *header = pdp_packet_header(p);
/* if type is not exact, delete the packet */
- if (type != h->desc) {
+ if (type != header->desc) {
pdp_packet_delete(p);
p = -1;
}