6 #include <schroedinger/schro.h>
7 #include <schroedinger/schromotion.h>
8 #include <schroedinger/schrodebug.h>
9 #include <schroedinger/schroutils.h>
10 #include <schroedinger/schrooil.h>
16 #define OIL_ENABLE_UNSTABLE_API
17 #include <liboil/liboilrandom.h>
18 #include <liboil/liboil.h>
22 void ref_frame_downsample (SchroFrame
*dest
, SchroFrame
*src
);
24 void frame_create_test_pattern(SchroFrame
*frame
, int type
);
29 test (int width
, int height
)
32 SchroFrame
*frame_ref
;
33 SchroFrame
*frame_test
;
34 char name
[TEST_PATTERN_NAME_SIZE
];
37 printf("size %dx%d\n", width
, height
);
39 frame
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_U8_420
, width
, height
);
40 frame_ref
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_U8_420
,
41 ROUND_UP_SHIFT(width
, 1), ROUND_UP_SHIFT(height
, 1));
42 frame_test
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_U8_420
,
43 ROUND_UP_SHIFT(width
, 1), ROUND_UP_SHIFT(height
, 1));
45 for(i
=0;i
<test_pattern_get_n_generators();i
++){
46 test_pattern_generate (frame
->components
+ 0, name
, i
);
48 ref_frame_downsample (frame_ref
, frame
);
49 schro_frame_downsample (frame_test
, frame
);
51 if (frame_compare (frame_ref
, frame_test
)) {
52 printf(" pattern %s: OK\n", name
);
54 printf(" pattern %s: broken\n", name
);
55 frame_data_dump_full (frame_test
->components
+ 0,
56 frame_ref
->components
+ 0, frame
->components
+ 0);
61 schro_frame_unref (frame_ref
);
62 schro_frame_unref (frame_test
);
63 schro_frame_unref (frame
);
67 main (int argc
, char *argv
[])
74 for(width
=10;width
<40;width
++){
75 for(height
=10;height
<40;height
++){
91 component_get (SchroFrameData
*src
, int i
, int j
)
95 i
= CLAMP(i
,0,src
->width
-1);
96 j
= CLAMP(j
,0,src
->height
-1);
97 data
= OFFSET(src
->data
, j
*src
->stride
);
103 ref_frame_component_downsample (SchroFrameData
*dest
,
106 static const int taps
[4] = { 6, 26, 26, 6 };
111 for(j
=0;j
<dest
->height
;j
++){
112 ddata
= OFFSET(dest
->data
, dest
->stride
* j
);
113 for(i
=0;i
<dest
->width
;i
++){
118 y
+= component_get (src
, (i
*2-1) + l
, (j
*2-1) + k
) * taps
[k
];
120 x
+= CLAMP((y
+ 32) >> 6,0,255) * taps
[l
];
122 ddata
[i
] = CLAMP((x
+ 32) >> 6,0,255);
128 ref_frame_downsample (SchroFrame
*dest
, SchroFrame
*src
)
130 ref_frame_component_downsample (dest
->components
+0, src
->components
+0);
131 ref_frame_component_downsample (dest
->components
+1, src
->components
+1);
132 ref_frame_component_downsample (dest
->components
+2, src
->components
+2);
136 frame_create_test_pattern(SchroFrame
*frame
, int type
)
142 for(j
=0;j
<frame
->components
[k
].height
;j
++){
143 data
= OFFSET(frame
->components
[k
].data
,j
*frame
->components
[k
].stride
);
144 for(i
=0;i
<frame
->components
[k
].width
;i
++) {
148 data
[i
] = oil_rand_u8();