[encoder] New scene change detection algorithm
[schroedinger/research-port.git] / testsuite / motion.c
blobd62852d9d6364794ba4ae67dd6ddfd47d4b5311e
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 <stdio.h>
10 #include <stdlib.h>
11 #include <string.h>
13 #define OIL_ENABLE_UNSTABLE_API
14 #include <liboil/liboilprofile.h>
16 void
17 schro_frame_clear (SchroFrame *frame)
19 memset(frame->components[0].data, 0, frame->components[0].length);
20 memset(frame->components[1].data, 0, frame->components[1].length);
21 memset(frame->components[2].data, 0, frame->components[2].length);
24 int
25 main (int argc, char *argv[])
27 SchroFrame *dest;
28 SchroFrame *ref;
29 SchroUpsampledFrame *uref;
30 SchroParams params;
31 SchroVideoFormat video_format;
32 SchroMotionVector *motion_vectors;
33 int i;
34 int j;
35 OilProfile prof;
36 double ave, std;
38 schro_init();
40 video_format.width = 720;
41 video_format.height = 480;
42 video_format.chroma_format = SCHRO_CHROMA_420;
43 schro_video_format_validate (&video_format);
45 params.video_format = &video_format;
46 params.xbsep_luma = 8;
47 params.ybsep_luma = 8;
48 params.xblen_luma = 12;
49 params.yblen_luma = 12;
51 schro_params_calculate_mc_sizes(&params);
53 dest = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_S16_420,
54 video_format.width, video_format.height);
55 schro_frame_clear(dest);
57 ref = schro_frame_new_and_alloc (NULL, SCHRO_FRAME_FORMAT_U8_420,
58 video_format.width, video_format.height);
59 schro_frame_clear(ref);
61 uref = schro_upsampled_frame_new (ref);
63 schro_upsampled_frame_upsample (uref);
65 motion_vectors = malloc(sizeof(SchroMotionVector) *
66 params.x_num_blocks * params.y_num_blocks);
67 memset (motion_vectors, 0, sizeof(SchroMotionVector) *
68 params.x_num_blocks * params.y_num_blocks);
70 printf("sizeof(SchroMotionVector) = %lu\n",(unsigned long) sizeof(SchroMotionVector));
71 printf("num blocks %d x %d\n", params.x_num_blocks, params.y_num_blocks);
72 for(i=0;i<params.x_num_blocks*params.y_num_blocks;i++){
73 motion_vectors[i].dx[0] = 0;
74 motion_vectors[i].dy[0] = 0;
75 motion_vectors[i].pred_mode = 1;
76 motion_vectors[i].split = 2;
79 for(i=0;i<10;i++){
80 oil_profile_init (&prof);
81 for(j=0;j<10;j++){
82 SchroMotion motion;
84 motion.src1 = uref;
85 motion.src2 = NULL;
86 motion.motion_vectors = motion_vectors;
87 motion.params = &params;
88 oil_profile_start(&prof);
89 schro_motion_render (&motion, dest);
90 oil_profile_stop(&prof);
92 oil_profile_get_ave_std (&prof, &ave, &std);
93 printf("cycles %g %g\n", ave, std);
98 schro_upsampled_frame_free (uref);
99 schro_frame_unref (dest);
100 free (motion_vectors);
102 return 0;