tests: fix build on os/x
[schroedinger.git] / testsuite / ssim.c
blob57e68c3c7d8f8b9636af46ef0440488d97d350fc
2 #ifdef HAVE_CONFIG_H
3 #include "config.h"
4 #endif
6 #include <stdio.h>
7 #include <string.h>
8 #include <stdlib.h>
9 #include <schroedinger/schro.h>
10 #include <schroedinger/schrodebug.h>
11 #include <schroedinger/schroutils.h>
13 void
14 create_pattern (SchroFrame *frame)
16 int i,j;
17 uint8_t *data;
19 for(j=0;j<frame->height;j++){
20 data = OFFSET(frame->components[0].data, j*frame->components[0].stride);
21 for(i=0;i<frame->width;i++){
22 data[i] = (((i>>4)&1) ^ ((j>>4)&1)) * 255;
25 memset (frame->components[1].data, 0, frame->components[1].length);
26 memset (frame->components[2].data, 0, frame->components[2].length);
27 schro_frame_filter_lowpass2 (frame, 5.0);
30 void
31 distort (SchroFrame *frame)
33 int i,j;
34 uint8_t *data;
36 for(j=0;j<frame->height;j++){
37 data = OFFSET(frame->components[0].data, j*frame->components[0].stride);
38 for(i=0;i<frame->width;i++){
39 data[i] &= 0xfc;
45 void
46 test (void)
48 SchroFrame *frame1;
49 SchroFrame *frame2;
51 frame1 = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_U8_420, 256, 256);
52 frame2 = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_U8_420, 256, 256);
54 create_pattern (frame1);
55 create_pattern (frame2);
57 distort (frame2);
59 schro_frame_ssim (frame1, frame2);
61 schro_frame_unref (frame1);
62 schro_frame_unref (frame2);
65 int
66 main (int argc, char *argv[])
68 schro_init();
70 test();
72 return 0;