4 * Copyright (C) Georg Martius - June 2007
6 * This file is part of transcode, a video stream processing tool
8 * transcode is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
13 * transcode is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define DEFAULT_TRANS_FILE_NAME "transforms.dat"
28 /* structure to hold information about frame transformations
29 x,y are translations, alpha is a rotation around the center in RAD,
30 zoom is a percentage to zoom in and
31 extra is for additional information like scene cut (unused)
33 typedef struct _transform {
38 int extra; /* -1: ignore transform (only internal use);
39 0 for normal trans; 1 for inter scene cut (unused) */
42 /* helper functions to create and operate with transforms.
43 * all functions are non-destructive
44 * the "_" version uses non-pointer Transforms. This is slower
45 * but useful when cascading calculations like
46 * add_transforms_(mult_transform(&t1, 5.0), &t2)
48 Transform null_transform(void);
49 Transform new_transform(double x, double y, double alpha,
50 double zoom, int extra);
51 Transform add_transforms(const Transform* t1, const Transform* t2);
52 Transform add_transforms_(const Transform t1, const Transform t2);
53 Transform sub_transforms(const Transform* t1, const Transform* t2);
54 Transform mult_transform(const Transform* t1, double f);
55 Transform mult_transform_(const Transform t1, double f);
57 /* compares a transform with respect to x (for sort function) */
58 int cmp_trans_x(const void *t1, const void* t2);
59 /* compares a transform with respect to y (for sort function) */
60 int cmp_trans_y(const void *t1, const void* t2);
61 /* static int cmp_trans_alpha(const void *t1, const void* t2); */
63 /* compares two double values (for sort function)*/
64 int cmp_double(const void *t1, const void* t2);
66 /* calculates the median of an array of transforms,
67 * considering only x and y
69 Transform median_xy_transform(const Transform* transforms, int len);
70 /* median of a double array */
71 double median(double* ds, int len);
72 /* mean of a double array */
73 double mean(const double* ds, int len);
74 /* mean with cutted upper and lower pentile
75 * (min and max are optionally returned)
77 double cleanmean(double* ds, int len, double* minimum, double* maximum);
78 /* calculates the cleaned mean of an array of transforms,
79 * considering only x and y
81 Transform cleanmean_xy_transform(const Transform* transforms, int len);
83 /* calculates the cleaned (cutting of x-th percentil)
84 * maximum and minimum of an array of transforms,
85 * considerung only x and y
87 void cleanmaxmin_xy_transform(const Transform* transforms, int len,
89 Transform* min, Transform* max);
91 /* helper functions */
93 /* optimized round function */
94 inline static int myround(float x) {
102 /* optimized floor function
103 This does not give the correct value for negative integer values like -1.0. In this case
104 it will produce -2.0.
106 inline static int myfloor(float x) {
118 * c-file-style: "stroustrup"
119 * c-file-offsets: ((case-label . *) (statement-case-intro . *))
120 * indent-tabs-mode: nil
123 * vim: expandtab shiftwidth=4: