[encoder] Added 1/8th pel MV refinement
[schroedinger/research-port.git] / testsuite / extension.c
blobe2e852b3ee3951bd79b9a7a9d876a4627dfe0e51
2 #ifdef HAVE_CONFIG_H
3 #include "config.h"
4 #endif
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>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <math.h>
15 #include <liboil/liboilrandom.h>
16 #include <liboil/liboil.h>
18 #include "common.h"
20 void upsample_line (uint8_t *dest, int dstr, uint8_t *src, int sstr, int n);
21 void ref_h_upsample (SchroFrame *dest, SchroFrame *src);
22 void ref_v_upsample (SchroFrame *dest, SchroFrame *src);
24 void test (int width, int height);
26 int failed = 0;
28 int dump_all = FALSE;
30 int
31 main (int argc, char *argv[])
33 schro_init();
35 test (100, 100);
37 if (failed) {
38 printf("FAILED\n");
39 } else {
40 printf("SUCCESS\n");
43 return failed;
46 void
47 schro_upsampled_frame_get_subdata_prec1 (SchroUpsampledFrame *upframe,
48 int component, int x, int y, SchroFrameData *fd);
50 void test (int width, int height)
52 SchroFrame *frame;
53 SchroUpsampledFrame *upframe;
54 char name[TEST_PATTERN_NAME_SIZE];
55 SchroFrameData fd_ref;
56 SchroFrameData fd;
57 int x,y;
58 int ok;
60 fd_ref.data = schro_malloc (16 * 16);
61 fd_ref.stride = 16;
62 fd_ref.width = 16;
63 fd_ref.height = 16;;
65 fd.width = 16;
66 fd.height = 16;;
68 frame = schro_frame_new_and_alloc_extended (NULL, SCHRO_FRAME_FORMAT_U8_420,
69 width, height, 32);
71 test_pattern_generate (frame->components + 0, name, 0);
72 test_pattern_generate (frame->components + 1, name, 0);
73 test_pattern_generate (frame->components + 2, name, 0);
75 schro_frame_mc_edgeextend (frame);
77 upframe = schro_upsampled_frame_new (schro_frame_ref(frame));
78 schro_upsampled_frame_upsample (upframe);
80 #if 0
81 /* just the corners */
82 for(y=-10;y<-8;y++){
83 for(x=-10;x<-8;x++){
84 printf ("%d,%d\n", x, y);
86 schro_upsampled_frame_get_block_precN (upframe, 0, x, y, 1, &fd_ref);
87 schro_upsampled_frame_get_subdata_prec1 (upframe, 0, x, y, &fd);
88 frame_data_dump_full (&fd, &fd_ref, &fd_ref);
92 for(y=200-16;y<200-16+2;y++){
93 for(x=184;x<186;x++){
94 printf ("%d,%d\n", x, y);
96 schro_upsampled_frame_get_block_precN (upframe, 0, x, y, 1, &fd_ref);
97 schro_upsampled_frame_get_subdata_prec1 (upframe, 0, x, y, &fd);
98 frame_data_dump_full (&fd, &fd_ref, &fd_ref);
102 for(y=-10;y<-8;y++){
103 for(x=184;x<186;x++){
104 printf ("%d,%d\n", x, y);
106 schro_upsampled_frame_get_block_precN (upframe, 0, x, y, 1, &fd_ref);
107 schro_upsampled_frame_get_subdata_prec1 (upframe, 0, x, y, &fd);
108 frame_data_dump_full (&fd, &fd_ref, &fd_ref);
112 for(y=184;y<186;y++){
113 for(x=-10;x<-8;x++){
114 printf ("%d,%d\n", x, y);
116 schro_upsampled_frame_get_block_precN (upframe, 0, x, y, 1, &fd_ref);
117 schro_upsampled_frame_get_subdata_prec1 (upframe, 0, x, y, &fd);
118 frame_data_dump_full (&fd, &fd_ref, &fd_ref);
121 #endif
123 for(y=-32*2;y<100+32*2-16*2;y++) {
124 for(x=-32*2;x<100+32*2-16*2;x++) {
125 schro_upsampled_frame_get_block_precN (upframe, 0, x, y, 1, &fd_ref);
126 schro_upsampled_frame_get_subdata_prec1 (upframe, 0, x, y, &fd);
127 ok = frame_data_compare (&fd, &fd_ref);
128 if (dump_all || !ok) {
129 printf ("%d,%d\n", x, y);
130 frame_data_dump_full (&fd, &fd_ref, &fd_ref);
132 if (!ok) {
133 failed = TRUE;
138 schro_frame_unref (frame);