Mercurial > mplayer.hg
annotate libass/ass_utils.c @ 26194:341804eeb2f7
removed redundant wincfg.h.
author | vayne |
---|---|
date | Tue, 11 Mar 2008 18:47:46 +0000 |
parents | 8d8c52a169ad |
children | 0f892cd714b2 |
rev | line source |
---|---|
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
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:
19405
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:
19405
diff
changeset
|
3 /* |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
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:
19405
diff
changeset
|
5 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
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:
19405
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:
19405
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:
19405
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:
19405
diff
changeset
|
10 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
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:
19405
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:
19405
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:
19405
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:
19405
diff
changeset
|
15 |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
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:
19405
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:
19405
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:
19405
diff
changeset
|
19 */ |
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
diff
changeset
|
20 |
18937 | 21 #include "config.h" |
22 | |
23 #include <stdlib.h> | |
19405 | 24 #include <inttypes.h> |
26034 | 25 #include <ft2build.h> |
26 #include FT_GLYPH_H | |
18937 | 27 |
21026
d138463e820b
Collect all includes of mplayer headers in libass in a single file (mputils.h).
eugeni
parents:
20629
diff
changeset
|
28 #include "mputils.h" |
18937 | 29 #include "ass_utils.h" |
30 | |
31 int mystrtoi(char** p, int base, int* res) | |
32 { | |
33 char* start = *p; | |
34 *res = strtol(*p, p, base); | |
35 if (*p != start) return 1; | |
36 else return 0; | |
37 } | |
38 | |
39 int mystrtou32(char** p, int base, uint32_t* res) | |
40 { | |
41 char* start = *p; | |
42 *res = strtoll(*p, p, base); | |
43 if (*p != start) return 1; | |
44 else return 0; | |
45 } | |
46 | |
47 int mystrtod(char** p, double* res) | |
48 { | |
49 char* start = *p; | |
50 *res = strtod(*p, p); | |
51 if (*p != start) return 1; | |
52 else return 0; | |
53 } | |
54 | |
55 int strtocolor(char** q, uint32_t* res) | |
56 { | |
57 uint32_t color = 0; | |
58 int result; | |
59 char* p = *q; | |
60 | |
61 if (*p == '&') ++p; | |
20629
e8885ec63928
Introduce MSGT_ASS, use it for all libass messages.
eugeni
parents:
20503
diff
changeset
|
62 else mp_msg(MSGT_ASS, MSGL_DBG2, "suspicious color format: \"%s\"\n", p); |
18937 | 63 |
19003 | 64 if (*p == 'H' || *p == 'h') { |
18937 | 65 ++p; |
66 result = mystrtou32(&p, 16, &color); | |
67 } else { | |
19003 | 68 result = mystrtou32(&p, 0, &color); |
18937 | 69 } |
70 | |
71 { | |
72 unsigned char* tmp = (unsigned char*)(&color); | |
73 unsigned char b; | |
74 b = tmp[0]; tmp[0] = tmp[3]; tmp[3] = b; | |
75 b = tmp[1]; tmp[1] = tmp[2]; tmp[2] = b; | |
76 } | |
77 if (*p == '&') ++p; | |
78 *q = p; | |
79 | |
80 *res = color; | |
81 return result; | |
82 } | |
83 | |
26036
8d8c52a169ad
Comment out dump_glyph(): it is unused and, as it is now, breaks compilation.
eugeni
parents:
26034
diff
changeset
|
84 #if 0 |
26034 | 85 static void sprint_tag(uint32_t tag, char* dst) |
86 { | |
87 dst[0] = (tag >> 24) & 0xFF; | |
88 dst[1] = (tag >> 16) & 0xFF; | |
89 dst[2] = (tag >> 8) & 0xFF; | |
90 dst[3] = tag & 0xFF; | |
91 dst[4] = 0; | |
92 } | |
93 | |
94 void dump_glyph(FT_Glyph g) | |
95 { | |
96 char tag[5]; | |
97 int i; | |
98 FT_OutlineGlyph og = (FT_OutlineGlyph)g; | |
99 FT_Outline* o = &(og->outline); | |
100 sprint_tag(g->format, tag); | |
101 printf("glyph: %p \n", g); | |
102 printf("format: %s \n", tag); | |
103 printf("outline: %p \n", o); | |
104 printf("contours: %d, points: %d, points ptr: %p \n", o->n_contours, o->n_points, o->points); | |
105 for (i = 0; i < o->n_points; ++i) { | |
106 printf(" point %f, %f \n", d6_to_double(o->points[i].x), d6_to_double(o->points[i].y)); | |
107 } | |
108 } | |
26036
8d8c52a169ad
Comment out dump_glyph(): it is unused and, as it is now, breaks compilation.
eugeni
parents:
26034
diff
changeset
|
109 #endif |