annotate libass/ass_render_api.c @ 35609:4e76a7f64810

Fix compilation with current FFmpeg.
author cehoyos
date Sat, 22 Dec 2012 10:53:51 +0000
parents 49fc594fda43
children c3aaaf17c721
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
35262
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
119 void ass_set_line_position(ASS_Renderer *priv, double line_position)
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
120 {
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
121 if (priv->settings.line_position != line_position) {
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
122 priv->settings.line_position = line_position;
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
123 ass_reconfigure(priv);
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
124 }
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
125 }
49fc594fda43 Updated libass to 0.10.1
SubJunk
parents: 34295
diff changeset
126
31853
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
127 void ass_set_fonts(ASS_Renderer *priv, const char *default_font,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
128 const char *default_family, int fc, const char *config,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
129 int update)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
130 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
131 free(priv->settings.default_font);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
132 free(priv->settings.default_family);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
133 priv->settings.default_font = default_font ? strdup(default_font) : 0;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
134 priv->settings.default_family =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
135 default_family ? strdup(default_family) : 0;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
136
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
137 if (priv->fontconfig_priv)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
138 fontconfig_done(priv->fontconfig_priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
139 priv->fontconfig_priv =
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
140 fontconfig_init(priv->library, priv->ftlibrary, default_family,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
141 default_font, fc, config, update);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
142 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
143
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
144 int ass_fonts_update(ASS_Renderer *render_priv)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
145 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
146 return fontconfig_update(render_priv->fontconfig_priv);
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
147 }
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
148
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
149 void ass_set_cache_limits(ASS_Renderer *render_priv, int glyph_max,
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
150 int bitmap_max)
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
151 {
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
152 render_priv->cache.glyph_max = glyph_max ? glyph_max : GLYPH_CACHE_MAX;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
153 render_priv->cache.bitmap_max_size = bitmap_max ? 1048576 * bitmap_max :
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
154 BITMAP_CACHE_MAX_SIZE;
e64df5862cea Import libass 0.9.10
greg
parents:
diff changeset
155 }