summaryrefslogtreecommitdiffstats
path: root/libass/ass_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'libass/ass_utils.c')
-rw-r--r--libass/ass_utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index 03900f2..8cd639d 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <limits.h>
#include <inttypes.h>
#include "ass_library.h"
@@ -327,6 +328,28 @@ int parse_ycbcr_matrix(char *str)
return YCBCR_UNKNOWN;
}
+/**
+ * \brief converts numpad-style align to align.
+ */
+int numpad2align(int val)
+{
+ if (val < -INT_MAX)
+ // Pick an alignment somewhat arbitrarily. VSFilter handles
+ // INT32_MIN as a mix of 1, 2 and 3, so prefer one of those values.
+ val = 2;
+ else if (val < 0)
+ val = -val;
+
+ int res = ((val - 1) % 3) + 1; // horizontal alignment
+ if (val <= 3)
+ res |= VALIGN_SUB;
+ else if (val <= 6)
+ res |= VALIGN_CENTER;
+ else
+ res |= VALIGN_TOP;
+ return res;
+}
+
void ass_msg(ASS_Library *priv, int lvl, const char *fmt, ...)
{
va_list va;