To calculate the aspect ratio what we need to do is to calculate the gcd
of width and height, dividing by it. We use the simple Euclidean
algorithm. Besides of being simple it's pretty fast.
return str;
}
+/* Euclidean algorithm
+ * http://en.wikipedia.org/wiki/Euclidean_algorithm */
+static unsigned int gcd(unsigned int a, unsigned int b)
+{
+ unsigned int t;
+
+ while (b) {
+ t = b;
+ b = a % t;
+ a = t;
+ }
+
+ return a;
+}
+
+void reduce_gcd(unsigned int w, unsigned int h, unsigned int *dw,
+ unsigned int *dh)
+{
+ unsigned int f;
+
+ *dw = w;
+ *dh = h;
+
+ if (!w || !h)
+ return;
+
+ f = gcd(w, h);
+ *dw /= f;
+ *dh /= f;
+}
struct lms_string_size str_extract_name_from_path(
const char *path, unsigned int pathlen, unsigned int baselen,
const struct lms_string_size *ext, struct lms_charset_conv *cs_conv);
+
+void reduce_gcd(unsigned int w, unsigned int h, unsigned int *dw,
+ unsigned int *dh);