1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
2 // vim:ts=8:sw=8:noet:ai:
4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
6 * This file is part of libass.
8 * libass 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 of the License, or
11 * (at your option) any later version.
13 * libass 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 along
19 * with libass; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef LIBASS_UTILS_H
24 #define LIBASS_UTILS_H
28 int mystrtoi(char** p
, int* res
);
29 int mystrtoll(char** p
, long long* res
);
30 int mystrtou32(char** p
, int base
, uint32_t* res
);
31 int mystrtod(char** p
, double* res
);
32 int strtocolor(char** q
, uint32_t* res
);
34 static inline int d6_to_int(int x
) {
37 static inline int d16_to_int(int x
) {
38 return (x
+ 32768) >> 16;
40 static inline int int_to_d6(int x
) {
43 static inline int int_to_d16(int x
) {
46 static inline int d16_to_d6(int x
) {
47 return (x
+ 512) >> 10;
49 static inline int d6_to_d16(int x
) {
52 static inline double d6_to_double(int x
) {
55 static inline int double_to_d6(double x
) {
58 static inline double d16_to_double(int x
) {
59 return ((double)x
) / 0x10000;
61 static inline int double_to_d16(double x
) {
62 return (int)(x
* 0x10000);
65 #endif /* LIBASS_UTILS_H */