annotate libass/ass_render_api.c @ 34374:09f2662d11cb

cdda: set position to an actual EOF position when we set EOF. This avoids some inconsistency like the stream indicating EOF but a read still returning more data.
author reimar
date Fri, 23 Dec 2011 21:52:04 +0000
parents 6e7f60f6f9d4
children 49fc594fda43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
1 /*
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
3 * Copyright (C) 2010 Grigori Goronzy <greg@geekmind.org>
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
4 *
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
5 * This file is part of libass.
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
6 *
34011
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
7 * Permission to use, copy, modify, and distribute this software for any
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
8 * purpose with or without fee is hereby granted, provided that the above
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
9 * copyright notice and this permission notice appear in all copies.
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
10 *
34011
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
88eebbbbd6a0 Update included libass copy to 0.9.13 release.
reimar
parents: 31853
diff changeset
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
18 */
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
19
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
20 #include "config.h"
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
21 #include "ass_render.h"
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
22
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
23 static void ass_reconfigure(ASS_Renderer *priv)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
24 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
25 ASS_Settings *settings = &priv->settings;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
26
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
27 priv->render_id++;
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
28 ass_cache_empty(priv->cache.outline_cache, 0);
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
29 ass_cache_empty(priv->cache.bitmap_cache, 0);
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
30 ass_cache_empty(priv->cache.composite_cache, 0);
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
31 ass_free_images(priv->prev_images_root);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
32 priv->prev_images_root = 0;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
33
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
34 priv->width = settings->frame_width;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
35 priv->height = settings->frame_height;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
36 priv->orig_width = settings->frame_width - settings->left_margin -
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
37 settings->right_margin;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
38 priv->orig_height = settings->frame_height - settings->top_margin -
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
39 settings->bottom_margin;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
40 priv->orig_width_nocrop =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
41 settings->frame_width - FFMAX(settings->left_margin, 0) -
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
42 FFMAX(settings->right_margin, 0);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
43 priv->orig_height_nocrop =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
44 settings->frame_height - FFMAX(settings->top_margin, 0) -
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
45 FFMAX(settings->bottom_margin, 0);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
46 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
47
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
48 void ass_set_frame_size(ASS_Renderer *priv, int w, int h)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
49 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
50 if (priv->settings.frame_width != w || priv->settings.frame_height != h) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
51 priv->settings.frame_width = w;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
52 priv->settings.frame_height = h;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
53 if (priv->settings.aspect == 0.) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
54 priv->settings.aspect = ((double) w) / h;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
55 priv->settings.storage_aspect = ((double) w) / h;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
56 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
57 ass_reconfigure(priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
58 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
59 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
60
34295
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
61 void ass_set_shaper(ASS_Renderer *priv, ASS_ShapingLevel level)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
62 {
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
63 #ifdef CONFIG_HARFBUZZ
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
64 // select the complex shaper for illegal values
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
65 if (level == ASS_SHAPING_SIMPLE || level == ASS_SHAPING_COMPLEX)
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
66 priv->settings.shaper = level;
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
67 else
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
68 priv->settings.shaper = ASS_SHAPING_COMPLEX;
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
69 #endif
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
70 }
6e7f60f6f9d4 Update libass to 0.10 release.
reimar
parents: 34011
diff changeset
71
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
72 void ass_set_margins(ASS_Renderer *priv, int t, int b, int l, int r)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
73 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
74 if (priv->settings.left_margin != l || priv->settings.right_margin != r ||
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
75 priv->settings.top_margin != t || priv->settings.bottom_margin != b) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
76 priv->settings.left_margin = l;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
77 priv->settings.right_margin = r;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
78 priv->settings.top_margin = t;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
79 priv->settings.bottom_margin = b;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
80 ass_reconfigure(priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
81 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
82 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
83
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
84 void ass_set_use_margins(ASS_Renderer *priv, int use)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
85 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
86 priv->settings.use_margins = use;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
87 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
88
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
89 void ass_set_aspect_ratio(ASS_Renderer *priv, double dar, double sar)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
90 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
91 if (priv->settings.aspect != dar || priv->settings.storage_aspect != sar) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
92 priv->settings.aspect = dar;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
93 priv->settings.storage_aspect = sar;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
94 ass_reconfigure(priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
95 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
96 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
97
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
98 void ass_set_font_scale(ASS_Renderer *priv, double font_scale)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
99 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
100 if (priv->settings.font_size_coeff != font_scale) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
101 priv->settings.font_size_coeff = font_scale;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
102 ass_reconfigure(priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
103 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
104 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
105
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
106 void ass_set_hinting(ASS_Renderer *priv, ASS_Hinting ht)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
107 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
108 if (priv->settings.hinting != ht) {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
109 priv->settings.hinting = ht;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
110 ass_reconfigure(priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
111 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
112 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
113
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
114 void ass_set_line_spacing(ASS_Renderer *priv, double line_spacing)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
115 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
116 priv->settings.line_spacing = line_spacing;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
117 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
118
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
119 void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
120 const char *default_family, int fc, const char *config,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
121 int update)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
122 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
123 free(priv->settings.default_font);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
124 free(priv->settings.default_family);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
125 priv->settings.default_font = default_font ? strdup(default_font) : 0;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
126 priv->settings.default_family =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
127 default_family ? strdup(default_family) : 0;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
128
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
129 if (priv->fontconfig_priv)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
130 fontconfig_done(priv->fontconfig_priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
131 priv->fontconfig_priv =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
132 fontconfig_init(priv->library, priv->ftlibrary, default_family,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
133 default_font, fc, config, update);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
134 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
135
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
136 int ass_fonts_update(ASS_Renderer *render_priv)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
137 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
138 return fontconfig_update(render_priv->fontconfig_priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
139 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
140
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
141 void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
142 int bitmap_max)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
143 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
144 render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
145 render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
146 BITMAP_CACHE_MAX_SIZE;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
147 }