From 14586a1b2f3ae784ee2f29957b4d01207cc6c2a0 Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Fri, 3 Feb 2017 21:36:23 +0200 Subject: Reuse numpad2align in parse_tag --- libass/ass_utils.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libass/ass_utils.c') 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 #include #include +#include #include #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; -- cgit v1.2.3