Update of /cvsroot/pure-data/externals/pdp/system/type In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2628/system/type
Modified Files: pdp_bitmap.c pdp_image.c Log Message: pdp current darcs merge
Index: pdp_image.c =================================================================== RCS file: /cvsroot/pure-data/externals/pdp/system/type/pdp_image.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** pdp_image.c 16 Dec 2005 01:05:40 -0000 1.3 --- pdp_image.c 1 Sep 2006 13:45:31 -0000 1.4 *************** *** 90,93 **** --- 90,94 ---- u32 totalnbpixels = size; u32 packet_size = totalnbpixels << 1; + //pdp_post("grey %d x %d = %d bytes", w,h,packet_size);
_checkdim(w,h); *************** *** 530,536 **** } if (p != -1){ ! t_pdp *h = pdp_packet_header(p); /* if type is not exact, delete the packet */ ! if (type != h->desc) { pdp_packet_delete(p); p = -1; --- 531,537 ---- } if (p != -1){ ! t_pdp *header = pdp_packet_header(p); /* if type is not exact, delete the packet */ ! if (type != header->desc) { pdp_packet_delete(p); p = -1;
Index: pdp_bitmap.c =================================================================== RCS file: /cvsroot/pure-data/externals/pdp/system/type/pdp_bitmap.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** pdp_bitmap.c 21 Jul 2006 15:33:30 -0000 1.4 --- pdp_bitmap.c 1 Sep 2006 13:45:31 -0000 1.5 *************** *** 72,75 **** --- 72,76 ---- 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; *************** *** 111,114 **** --- 112,126 ---- }
+ 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) { *************** *** 190,193 **** --- 202,206 ---- 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); *************** *** 445,448 **** --- 458,494 ---- }
+ 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) { *************** *** 464,472 **** }
- 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) { --- 510,513 ---- *************** *** 481,484 **** --- 522,531 ---- 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; *************** *** 555,561 ****
if (p != -1){ ! t_pdp *h = pdp_packet_header(p); /* if type is not exact, delete the packet */ ! if (type != h->desc) { pdp_packet_delete(p); p = -1; --- 602,608 ----
if (p != -1){ ! t_pdp *header = pdp_packet_header(p); /* if type is not exact, delete the packet */ ! if (type != header->desc) { pdp_packet_delete(p); p = -1; *************** *** 588,591 **** --- 635,641 ---- 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); *************** *** 605,608 **** --- 655,663 ----
+ /* 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); *************** *** 612,615 **** --- 667,671 ----
+ /* fallback rgb convertor */ program = pdp_conversion_program_new(_pdp_packet_bitmap_convert_rgb8_to_YCrCb, 0);