Mercurial > mplayer.hg
annotate libass/ass_utils.h @ 24127:faf9baa673c0
Use bitfield instead of manual bit fiddling in input.c
author | uau |
---|---|
date | Sat, 25 Aug 2007 04:28:04 +0000 |
parents | 3f0d00abc073 |
children | 3baf6a2283da |
rev | line source |
---|---|
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*- |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
2 // vim:ts=8:sw=8:noet:ai: |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
3 /* |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
5 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
8 the Free Software Foundation; either version 2 of the License, or |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
9 (at your option) any later version. |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
10 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
14 GNU General Public License for more details. |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
15 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
17 along with this program; if not, write to the Free Software |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
19 */ |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
18937
diff
changeset
|
20 |
23689
3f0d00abc073
Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents:
23299
diff
changeset
|
21 #ifndef ASS_UTILS_H |
3f0d00abc073
Do not use leading underscores in multiple inclusion guards, they are reserved.
diego
parents:
23299
diff
changeset
|
22 #define ASS_UTILS_H |
18937 | 23 |
24 int mystrtoi(char** p, int base, int* res); | |
25 int mystrtou32(char** p, int base, uint32_t* res); | |
26 int mystrtod(char** p, double* res); | |
27 int strtocolor(char** q, uint32_t* res); | |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
28 |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
29 static inline int d6_to_int(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
30 return (x + 32) >> 6; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
31 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
32 static inline int d16_to_int(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
33 return (x + 32768) >> 16; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
34 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
35 static inline int int_to_d6(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
36 return x << 6; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
37 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
38 static inline int int_to_d16(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
39 return x << 16; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
40 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
41 static inline int d16_to_d6(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
42 return (x + 512) >> 10; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
43 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
44 static inline int d6_to_d16(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
45 return x << 10; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
46 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
47 static inline double d6_to_double(int x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
48 return x / 64.; |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
49 } |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
50 static inline int double_to_d6(double x) { |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
51 return (int)(x * 64); |
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
52 } |
23299
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
53 static inline double d16_to_double(int x) { |
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
54 return ((double)x) / 0x10000; |
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
55 } |
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
56 static inline int double_to_d16(double x) { |
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
57 return (int)(x * 0x10000); |
0ee56ec36a40
Limit ass_font_set_transform to nonrotating transformations.
eugeni
parents:
22213
diff
changeset
|
58 } |
22213
66abe12ad374
Move conversions between 16.16, 26.6 fixed point and int, double to separate
eugeni
parents:
20503
diff
changeset
|
59 |
18937 | 60 #endif |
61 |