Mercurial > mplayer.hg
annotate libass/ass_utils.c @ 26954:305674cf4e92
Document VIDIXIVTVALPHA environment variable.
author | diego |
---|---|
date | Wed, 04 Jun 2008 11:38:44 +0000 |
parents | 588ce97b44f2 |
children | 7bbe6626f0e0 |
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 /* |
26723 | 4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> |
5 * | |
26738
588ce97b44f2
Speak of libass instead of MPlayer in the libass license headers.
diego
parents:
26723
diff
changeset
|
6 * This file is part of libass. |
26723 | 7 * |
26738
588ce97b44f2
Speak of libass instead of MPlayer in the libass license headers.
diego
parents:
26723
diff
changeset
|
8 * libass is free software; you can redistribute it and/or modify |
26723 | 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. | |
12 * | |
26738
588ce97b44f2
Speak of libass instead of MPlayer in the libass license headers.
diego
parents:
26723
diff
changeset
|
13 * libass is distributed in the hope that it will be useful, |
26723 | 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. | |
17 * | |
18 * You should have received a copy of the GNU General Public License along | |
26738
588ce97b44f2
Speak of libass instead of MPlayer in the libass license headers.
diego
parents:
26723
diff
changeset
|
19 * with libass; if not, write to the Free Software Foundation, Inc., |
26723 | 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 */ | |
20008
fa122b7c71c6
Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents:
19405
diff
changeset
|
22 |
18937 | 23 #include "config.h" |
24 | |
25 #include <stdlib.h> | |
19405 | 26 #include <inttypes.h> |
26034 | 27 #include <ft2build.h> |
28 #include FT_GLYPH_H | |
18937 | 29 |
21026
d138463e820b
Collect all includes of mplayer headers in libass in a single file (mputils.h).
eugeni
parents:
20629
diff
changeset
|
30 #include "mputils.h" |
18937 | 31 #include "ass_utils.h" |
32 | |
33 int mystrtoi(char** p, int base, int* res) | |
34 { | |
35 char* start = *p; | |
36 *res = strtol(*p, p, base); | |
37 if (*p != start) return 1; | |
38 else return 0; | |
39 } | |
40 | |
41 int mystrtou32(char** p, int base, uint32_t* res) | |
42 { | |
43 char* start = *p; | |
44 *res = strtoll(*p, p, base); | |
45 if (*p != start) return 1; | |
46 else return 0; | |
47 } | |
48 | |
49 int mystrtod(char** p, double* res) | |
50 { | |
51 char* start = *p; | |
52 *res = strtod(*p, p); | |
53 if (*p != start) return 1; | |
54 else return 0; | |
55 } | |
56 | |
57 int strtocolor(char** q, uint32_t* res) | |
58 { | |
59 uint32_t color = 0; | |
60 int result; | |
61 char* p = *q; | |
62 | |
63 if (*p == '&') ++p; | |
20629
e8885ec63928
Introduce MSGT_ASS, use it for all libass messages.
eugeni
parents:
20503
diff
changeset
|
64 else mp_msg(MSGT_ASS, MSGL_DBG2, "suspicious color format: \"%s\"\n", p); |
18937 | 65 |
19003 | 66 if (*p == 'H' || *p == 'h') { |
18937 | 67 ++p; |
68 result = mystrtou32(&p, 16, &color); | |
69 } else { | |
19003 | 70 result = mystrtou32(&p, 0, &color); |
18937 | 71 } |
72 | |
73 { | |
74 unsigned char* tmp = (unsigned char*)(&color); | |
75 unsigned char b; | |
76 b = tmp[0]; tmp[0] = tmp[3]; tmp[3] = b; | |
77 b = tmp[1]; tmp[1] = tmp[2]; tmp[2] = b; | |
78 } | |
79 if (*p == '&') ++p; | |
80 *q = p; | |
81 | |
82 *res = color; | |
83 return result; | |
84 } | |
85 | |
26036
8d8c52a169ad
Comment out dump_glyph(): it is unused and, as it is now, breaks compilation.
eugeni
parents:
26034
diff
changeset
|
86 #if 0 |
26034 | 87 static void sprint_tag(uint32_t tag, char* dst) |
88 { | |
89 dst[0] = (tag >> 24) & 0xFF; | |
90 dst[1] = (tag >> 16) & 0xFF; | |
91 dst[2] = (tag >> 8) & 0xFF; | |
92 dst[3] = tag & 0xFF; | |
93 dst[4] = 0; | |
94 } | |
95 | |
96 void dump_glyph(FT_Glyph g) | |
97 { | |
98 char tag[5]; | |
99 int i; | |
100 FT_OutlineGlyph og = (FT_OutlineGlyph)g; | |
101 FT_Outline* o = &(og->outline); | |
102 sprint_tag(g->format, tag); | |
103 printf("glyph: %p \n", g); | |
104 printf("format: %s \n", tag); | |
105 printf("outline: %p \n", o); | |
106 printf("contours: %d, points: %d, points ptr: %p \n", o->n_contours, o->n_points, o->points); | |
107 for (i = 0; i < o->n_points; ++i) { | |
108 printf(" point %f, %f \n", d6_to_double(o->points[i].x), d6_to_double(o->points[i].y)); | |
109 } | |
110 } | |
26036
8d8c52a169ad
Comment out dump_glyph(): it is unused and, as it is now, breaks compilation.
eugeni
parents:
26034
diff
changeset
|
111 #endif |