remove more unused stuff
[sparrow.git] / test-jpeg.c
blob10ccdeb320676dd0be502a8c6bd4410b5f6d7e84
1 #include "gstsparrow.h"
2 #include "sparrow.h"
3 #include <string.h>
4 #include <math.h>
5 #include <sys/time.h>
7 #include <stdio.h>
9 //#include "jpeg_src.c"
11 static const int INSIZE = 100000;
12 static const int OUTSIZE = 800 * 600 * 4;
13 static const char *FN_IN = "test.jpg";
14 static const char *FN_OUT = "test.ppm";
17 int main(int argc, char **argv)
19 guint8* inbuffer = malloc_aligned_or_die(INSIZE);
20 guint8* outbuffer = malloc_aligned_or_die(OUTSIZE);
22 FILE *in = fopen(FN_IN, "r");
23 int size = fread(inbuffer, INSIZE, 1, in);
25 struct timeval tv1, tv2;
26 guint32 t;
27 int width, height;
29 GstSparrow sparrow;
30 init_jpeg_src(&sparrow);
33 for (int i = 0; i < 5; i++){
34 gettimeofday(&tv1, NULL);
36 decompress_buffer(sparrow.cinfo, inbuffer, size, outbuffer,
37 &width, &height);
39 gettimeofday(&tv2, NULL);
40 t = ((tv2.tv_sec - tv1.tv_sec) * 1000000 +
41 tv2.tv_usec - tv1.tv_usec);
42 printf("took %u microseconds (%0.5f of a frame)\n",
43 t, (double)t * (25.0 / 1000000.0));
46 sparrow_format rgb;
47 rgb.rshift = 24;
48 rgb.gshift = 16;
49 rgb.bshift = 8;
51 ppm_dump(&rgb, outbuffer, width, height, FN_OUT);
53 finalise_jpeg_src(&sparrow);