File: ssim.c

package info (click to toggle)
schroedinger 1.0.11-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,480 kB
  • sloc: ansic: 97,380; sh: 11,238; xml: 6,509; makefile: 386
file content (75 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <schroedinger/schro.h>
#include <schroedinger/schrodebug.h>
#include <schroedinger/schroutils.h>

void
create_pattern (SchroFrame *frame)
{
  int i,j;
  uint8_t *data;

  for(j=0;j<frame->height;j++){
    data = OFFSET(frame->components[0].data, j*frame->components[0].stride);
    for(i=0;i<frame->width;i++){
      data[i] = (((i>>4)&1) ^ ((j>>4)&1)) * 255;
    }
  }
  memset (frame->components[1].data, 0, frame->components[1].length);
  memset (frame->components[2].data, 0, frame->components[2].length);
  schro_frame_filter_lowpass2 (frame, 5.0);
}

void
distort (SchroFrame *frame)
{
  int i,j;
  uint8_t *data;

  for(j=0;j<frame->height;j++){
    data = OFFSET(frame->components[0].data, j*frame->components[0].stride);
    for(i=0;i<frame->width;i++){
      data[i] &= 0xfc;
    }
  }
}


void
test (void)
{
  SchroFrame *frame1;
  SchroFrame *frame2;

  frame1 = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_U8_420, 256, 256);
  frame2 = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_U8_420, 256, 256);

  create_pattern (frame1);
  create_pattern (frame2);

  distort (frame2);

  schro_frame_ssim (frame1, frame2);

  schro_frame_unref (frame1);
  schro_frame_unref (frame2);
}

int
main (int argc, char *argv[])
{
  schro_init();

  test();

  return 0;
}