6 #include <schroedinger/schro.h>
7 #include <schroedinger/schromotion.h>
8 #include <schroedinger/schrodebug.h>
9 #include <schroedinger/schroutils.h>
14 #define OIL_ENABLE_UNSTABLE_API
15 #include <liboil/liboilrandom.h>
18 schro_frame_clear (SchroFrame
*frame
)
20 memset(frame
->components
[0].data
, 0, frame
->components
[0].length
);
21 memset(frame
->components
[1].data
, 0, frame
->components
[1].length
);
22 memset(frame
->components
[2].data
, 0, frame
->components
[2].length
);
26 schro_frame_create_pattern (SchroFrame
*frame
, int type
)
33 oil_random_u8 (frame
->components
[0].data
, frame
->components
[0].length
);
34 oil_random_u8 (frame
->components
[1].data
, frame
->components
[1].length
);
35 oil_random_u8 (frame
->components
[2].data
, frame
->components
[2].length
);
39 comp
= &frame
->components
[k
];
40 for(j
=0;j
<comp
->height
;j
++){
41 for(i
=0;i
<comp
->width
;i
++){
42 SCHRO_GET(comp
->data
, j
*comp
->stride
+ i
, uint8_t) = i
*4 + j
*2;
52 schro_frame_compare (SchroFrame
*a
, SchroFrame
*b
)
54 SchroFrameData
*comp_a
;
55 SchroFrameData
*comp_b
;
60 comp_a
= &a
->components
[k
];
61 comp_b
= &b
->components
[k
];
62 for(j
=0;j
<comp_a
->height
;j
++){
63 for(i
=0;i
<comp_a
->width
;i
++){
64 if (SCHRO_GET(comp_a
->data
, j
*comp_a
->stride
+ i
, uint8_t) !=
65 SCHRO_GET(comp_b
->data
, j
*comp_b
->stride
+ i
, uint8_t)) {
66 SCHRO_ERROR("difference comp=%d x=%d y=%d", k
, i
, j
);
77 schro_frame_dump (SchroFrame
*frame
)
82 comp
= &frame
->components
[0];
85 printf("%-3d ", SCHRO_GET(comp
->data
, j
*comp
->stride
+ i
, uint8_t));
92 main (int argc
, char *argv
[])
97 SchroUpsampledFrame
*uref
;
99 SchroVideoFormat video_format
;
100 SchroMotionVector
*motion_vectors
;
105 video_format
.width
= 720;
106 video_format
.height
= 480;
107 video_format
.chroma_format
= SCHRO_CHROMA_420
;
108 schro_video_format_validate (&video_format
);
110 params
.video_format
= &video_format
;
111 params
.xbsep_luma
= 8;
112 params
.ybsep_luma
= 8;
113 params
.xblen_luma
= 12;
114 params
.yblen_luma
= 12;
116 schro_params_calculate_mc_sizes(¶ms
);
118 dest
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_S16_420
,
119 video_format
.width
, video_format
.height
);
120 ref
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_U8_420
,
121 video_format
.width
, video_format
.height
);
122 dest_u8
= schro_frame_new_and_alloc (NULL
, SCHRO_FRAME_FORMAT_U8_420
,
123 video_format
.width
, video_format
.height
);
125 schro_frame_clear(dest
);
126 schro_frame_create_pattern(ref
,1);
128 motion_vectors
= malloc(sizeof(SchroMotionVector
) *
129 params
.x_num_blocks
* params
.y_num_blocks
);
130 memset (motion_vectors
, 0, sizeof(SchroMotionVector
) *
131 params
.x_num_blocks
* params
.y_num_blocks
);
133 printf("sizeof(SchroMotionVector) = %lu\n",(unsigned long) sizeof(SchroMotionVector
));
134 printf("num blocks %d x %d\n", params
.x_num_blocks
, params
.y_num_blocks
);
135 for(j
=0;j
<params
.y_num_blocks
;j
++){
137 jj
= j
* params
.x_num_blocks
;
138 for(i
=0;i
<params
.x_num_blocks
;i
++){
140 if (i
== 0 || i
== 2 || i
== params
.x_num_blocks
*2) {
141 motion_vectors
[jj
+i
].u
.dc
[0] = 100;
142 motion_vectors
[jj
+i
].u
.dc
[1] = 100;
143 motion_vectors
[jj
+i
].u
.dc
[2] = 0;
144 motion_vectors
[jj
+i
].pred_mode
= 0;
146 motion_vectors
[jj
+i
].u
.dc
[0] = 0;
147 motion_vectors
[jj
+i
].u
.dc
[1] = 0;
148 motion_vectors
[jj
+i
].u
.dc
[2] = 0;
149 motion_vectors
[jj
+i
].pred_mode
= 0;
152 motion_vectors
[jj
+i
].dx
[0] = 0;
153 motion_vectors
[jj
+i
].dy
[0] = -8*i
;
154 motion_vectors
[jj
+i
].pred_mode
= 1;
155 motion_vectors
[jj
+i
].split
= 2;
159 uref
= schro_upsampled_frame_new (ref
);
166 motion
.motion_vectors
= motion_vectors
;
167 motion
.params
= ¶ms
;
168 schro_motion_render (&motion
, dest
);
171 schro_frame_convert (dest_u8
, dest
);
172 schro_frame_dump (dest_u8
);
173 //schro_frame_compare (ref, dest_u8);
175 schro_upsampled_frame_free (uref
);
176 schro_frame_unref (dest
);
177 schro_frame_unref (dest_u8
);
178 free (motion_vectors
);