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 base
, int* res
);
29 int mystrtou32(char** p
, int base
, uint32_t* res
);
30 int mystrtod(char** p
, double* res
);
31 int strtocolor(char** q
, uint32_t* res
);
33 static inline int d6_to_int(int x
) {
36 static inline int d16_to_int(int x
) {
37 return (x
+ 32768) >> 16;
39 static inline int int_to_d6(int x
) {
42 static inline int int_to_d16(int x
) {
45 static inline int d16_to_d6(int x
) {
46 return (x
+ 512) >> 10;
48 static inline int d6_to_d16(int x
) {
51 static inline double d6_to_double(int x
) {
54 static inline int double_to_d6(double x
) {
57 static inline double d16_to_double(int x
) {
58 return ((double)x
) / 0x10000;
60 static inline int double_to_d16(double x
) {
61 return (int)(x
* 0x10000);
64 #endif /* LIBASS_UTILS_H */