2008/07/28

cairo 1.6.4 jpeg I/O support patch


Hello all,

This is an unofficial patch to cairo 1.6.4 that addes jpeg I/O support to cairo.

The original patch( to an older version of cairo) is not mine.
Please take a look at src/cairo-jpeg.c for credit(s).

Installation:
1. ./configure --enable-jpeg; make; make install as usual, or better
2. autoreconf to adapt the changes in configure.in to your enviroment.

For more information, please use diff against the standard release cairo-1.6.4

ABIs added ( similar to PNG ) :
cairo_get_default_jpeg_parameter
cairo_surface_write_to_jpeg
cairo_image_surface_create_from_jpeg
cairo_image_surface_create_from_jpeg_stream

To download, click the link below:
http://www.hn.is.uec.ac.jp/~vuhung/patches/cairo-1.6.4.jpeg-patch.tar.gz

2008/07/23

A better average


double variance(long long *x, int n)
{
double m = x[0];
double s = 0;
int i;
for (i=0; i double m_new = m + (x[i] - m)/(i+1);
s = s + (x[i] - m)*(x[i] - m_new);
m = m_new;
}
return s / (n - 1);
}

double mean(long long *x, int n)
{
double m = x[0];
int i;
for (i=0; i m = m + (x[i] - m)/(i+1);
}
return m;
}

double stddev(long long *x, int n)
{
return sqrt(variance(x, n));
}

long long times[30];

printf("mean: %f stddev: %f\n", mean(times, 20), stddev(times, 20));