ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CV/CV.xs
(Generate patch)

Comparing CV/CV.xs (file contents):
Revision 1.17 by root, Wed Jul 20 06:20:36 2005 UTC vs.
Revision 1.21 by root, Sat Jul 23 03:25:51 2005 UTC

1#include "EXTERN.h" 1#include "EXTERN.h"
2#include "perl.h" 2#include "perl.h"
3#include "XSUB.h" 3#include "XSUB.h"
4 4
5#include <string.h>
5#include <setjmp.h> 6#include <setjmp.h>
6 7
7#include <jpeglib.h> 8#include <jpeglib.h>
8#include <gdk-pixbuf/gdk-pixbuf.h> 9#include <gdk-pixbuf/gdk-pixbuf.h>
9 10
224 { 225 {
225 cinfo.dct_method = JDCT_FASTEST; 226 cinfo.dct_method = JDCT_FASTEST;
226 cinfo.do_fancy_upsampling = FALSE; 227 cinfo.do_fancy_upsampling = FALSE;
227 228
228 while (cinfo.scale_denom < 8 229 while (cinfo.scale_denom < 8
229 && (cinfo.output_width >> 1) >= IW 230 && cinfo.output_width >= IW*4
230 && (cinfo.output_height >> 1) >= IH) 231 && cinfo.output_height >= IH*4)
231 { 232 {
232 cinfo.scale_denom <<= 1; 233 cinfo.scale_denom <<= 1;
233 jpeg_calc_output_dimensions (&cinfo); 234 jpeg_calc_output_dimensions (&cinfo);
234 } 235 }
235 } 236 }
268 269
269############################################################################# 270#############################################################################
270 271
271MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer 272MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Schnauzer
272 273
274SV *
275foldcase (SV *pathsv)
276 PROTOTYPE: $
277 CODE:
278{
279 STRLEN plen;
280 U8 *path = SvPVutf8 (pathsv, plen);
281 U8 *pend = path + plen;
282 U8 dst [plen * 6 * 3], *dstp = dst;
283
284 while (path < pend)
285 {
286 U8 ch = *path;
287
288 if (ch >= 'a' && ch <= 'z')
289 *dstp++ = *path++;
290 else if (ch >= '0' && ch <= '9')
291 {
292 STRLEN el, nl = 0;
293 while (*path >= '0' && *path <= '9' && path < pend)
294 path++, nl++;
295
296 for (el = nl; el < 6; el++)
297 *dstp++ = '0';
298
299 memcpy (dstp, path - nl, nl);
300 dstp += nl;
301 }
302 else
303 {
304 STRLEN cl;
305 to_utf8_fold (path, dstp, &cl);
306 dstp += cl;
307 path += is_utf8_char (path);
308 }
309 }
310
311 RETVAL = newSVpvn (dst, dstp - dst);
312}
313 OUTPUT:
314 RETVAL
315
273GdkPixbuf_noinc * 316GdkPixbuf_noinc *
274p7_to_pb (int w, int h, guchar *src) 317p7_to_pb (int w, int h, guchar *src)
318 PROTOTYPE: @
275 CODE: 319 CODE:
276{ 320{
277 int x, y; 321 int x, y;
278 guchar *dst, *d; 322 guchar *dst, *d;
279 int dstr; 323 int dstr;
351 } 395 }
352} 396}
353 OUTPUT: 397 OUTPUT:
354 RETVAL 398 RETVAL
355 399
356SV *
357make_histogram (SV *ar)
358 CODE:
359{
360 int i;
361 AV *av, *result;
362
363 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
364 croak ("Not an array ref as first argument to make_histogram");
365
366 av = (AV *) SvRV (ar);
367 result = newAV ();
368
369 for (i = 0; i <= av_len (av); ++i)
370 {
371 const int HISTSIZE = 64;
372
373 int j;
374 SV *sv = *av_fetch (av, i, 1);
375 STRLEN len;
376 char *buf = SvPVbyte (sv, len);
377
378 int tmphist[HISTSIZE];
379 float *hist;
380
381 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
382 SvPOK_on (histsv);
383 SvCUR_set (histsv, HISTSIZE * sizeof (float));
384 hist = (float *)SvPVX (histsv);
385
386 Zero (tmphist, sizeof (tmphist), char);
387
388 for (j = len; j--; )
389 {
390 unsigned int idx
391 = ((*buf & 0xc0) >> 2)
392 | ((*buf & 0x18) >> 1)
393 | (*buf & 0x03);
394
395 ++tmphist[idx];
396 ++buf;
397 }
398
399 for (j = 0; j < HISTSIZE; ++j)
400 hist[j] = (float)tmphist[j] / (len + 1e-30);
401
402 av_push (result, histsv);
403 }
404
405 RETVAL = newRV_noinc ((SV *)result);
406}
407 OUTPUT:
408 RETVAL
409
410############################################################################# 400#############################################################################
411 401
412MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript 402MODULE = Gtk2::CV PACKAGE = Gtk2::CV::PostScript
413 403
414void 404void
537 } 527 }
538} 528}
539 OUTPUT: 529 OUTPUT:
540 RETVAL 530 RETVAL
541 531
532#############################################################################
542 533
534MODULE = Gtk2::CV PACKAGE = Gtk2::CV::Plugin::RCluster
543 535
536SV *
537make_histograms (SV *ar)
538 CODE:
539{
540 int i;
541 AV *av, *result;
542
543 if (!SvROK (ar) || SvTYPE (SvRV (ar)) != SVt_PVAV)
544 croak ("Not an array ref as first argument to make_histogram");
545
546 av = (AV *) SvRV (ar);
547 result = newAV ();
548
549 for (i = 0; i <= av_len (av); ++i)
550 {
551 const int HISTSIZE = 64;
552
553 int j;
554 SV *sv = *av_fetch (av, i, 1);
555 STRLEN len;
556 char *buf = SvPVbyte (sv, len);
557
558 int tmphist[HISTSIZE];
559 float *hist;
560
561 SV *histsv = newSV (HISTSIZE * sizeof (float) + 1);
562 SvPOK_on (histsv);
563 SvCUR_set (histsv, HISTSIZE * sizeof (float));
564 hist = (float *)SvPVX (histsv);
565
566 Zero (tmphist, sizeof (tmphist), char);
567
568 for (j = len; j--; )
569 {
570 unsigned int idx
571 = ((*buf & 0xc0) >> 2)
572 | ((*buf & 0x18) >> 1)
573 | (*buf & 0x03);
574
575 ++tmphist[idx];
576 ++buf;
577 }
578
579 for (j = 0; j < HISTSIZE; ++j)
580 hist[j] = (float)tmphist[j] / (len + 1e-30);
581
582 av_push (result, histsv);
583 }
584
585 RETVAL = newRV_noinc ((SV *)result);
586}
587 OUTPUT:
588 RETVAL
589
590

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines