Mercurial > mplayer.hg
annotate libass/ass_library.c @ 23444:4a9e6efb8200
Remove some useless code
author | reimar |
---|---|
date | Mon, 04 Jun 2007 13:05:26 +0000 |
parents | 4a4af5271542 |
children | f00333e3facf |
rev | line source |
---|---|
20477 | 1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*- |
2 // vim:ts=8:sw=8:noet:ai: | |
3 /* | |
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com> | |
5 | |
6 This program is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 2 of the License, or | |
9 (at your option) any later version. | |
10 | |
11 This program is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with this program; if not, write to the Free Software | |
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 */ | |
20 | |
21 #include <inttypes.h> | |
22 #include <stdio.h> | |
23 #include <stdlib.h> | |
24 #include <string.h> | |
25 | |
26 #include "ass.h" | |
27 #include "ass_library.h" | |
28 | |
29 | |
30 ass_library_t* ass_library_init(void) | |
31 { | |
32 return calloc(1, sizeof(ass_library_t)); | |
33 } | |
34 | |
35 void ass_library_done(ass_library_t* priv) | |
36 { | |
21497
4a4af5271542
Also free ass_library_t members in ass_library_done
reimar
parents:
21458
diff
changeset
|
37 if (priv) { |
4a4af5271542
Also free ass_library_t members in ass_library_done
reimar
parents:
21458
diff
changeset
|
38 ass_set_fonts_dir(priv, NULL); |
4a4af5271542
Also free ass_library_t members in ass_library_done
reimar
parents:
21458
diff
changeset
|
39 ass_set_style_overrides(priv, NULL); |
4a4af5271542
Also free ass_library_t members in ass_library_done
reimar
parents:
21458
diff
changeset
|
40 free(priv); |
4a4af5271542
Also free ass_library_t members in ass_library_done
reimar
parents:
21458
diff
changeset
|
41 } |
20477 | 42 } |
43 | |
44 void ass_set_fonts_dir(ass_library_t* priv, const char* fonts_dir) | |
45 { | |
46 if (priv->fonts_dir) | |
47 free(priv->fonts_dir); | |
48 | |
49 priv->fonts_dir = fonts_dir ? strdup(fonts_dir) : 0; | |
50 } | |
51 | |
52 void ass_set_extract_fonts(ass_library_t* priv, int extract) | |
53 { | |
54 priv->extract_fonts = !!extract; | |
55 } | |
56 | |
57 void ass_set_style_overrides(ass_library_t* priv, char** list) | |
58 { | |
59 char** p; | |
60 char** q; | |
61 int cnt; | |
62 | |
63 if (priv->style_overrides) { | |
64 for (p = priv->style_overrides; *p; ++p) | |
65 free(*p); | |
66 free(priv->style_overrides); | |
67 } | |
68 | |
69 if (!list) return; | |
70 | |
71 for (p = list, cnt = 0; *p; ++p, ++cnt) {} | |
72 | |
20722
2edba6772316
Bugfix: when copying ass_force_style_list, ending 0 was left out.
eugeni
parents:
20477
diff
changeset
|
73 priv->style_overrides = malloc((cnt + 1) * sizeof(char*)); |
20477 | 74 for (p = list, q = priv->style_overrides; *p; ++p, ++q) |
75 *q = strdup(*p); | |
20722
2edba6772316
Bugfix: when copying ass_force_style_list, ending 0 was left out.
eugeni
parents:
20477
diff
changeset
|
76 priv->style_overrides[cnt] = NULL; |
20477 | 77 } |
21458
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
78 |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
79 static void grow_array(void **array, int nelem, size_t elsize) |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
80 { |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
81 if (!(nelem & 31)) |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
82 *array = realloc(*array, (nelem + 32) * elsize); |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
83 } |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
84 |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
85 void ass_add_font(ass_library_t* priv, char* name, char* data, int size) |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
86 { |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
87 grow_array((void**)&priv->fontdata, priv->num_fontdata, sizeof(*priv->fontdata)); |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
88 priv->fontdata[priv->num_fontdata].name = name; |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
89 priv->fontdata[priv->num_fontdata].data = data; |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
90 priv->fontdata[priv->num_fontdata].size = size; |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
91 priv->num_fontdata ++; |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
92 } |
7af6c25a0cfc
Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents:
20722
diff
changeset
|
93 |