/src/vlc/modules/codec/substext.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * subsdec.c : text subtitle decoder |
3 | | ***************************************************************************** |
4 | | * Copyright © 2011-2015 VLC authors and VideoLAN |
5 | | * |
6 | | * Authors: Laurent Aimer <fenrir@videolan.org> |
7 | | * Jean-Baptiste Kempf <jb@videolan.org> |
8 | | * |
9 | | * This program is free software; you can redistribute it and/or modify it |
10 | | * under the terms of the GNU Lesser General Public License as published by |
11 | | * the Free Software Foundation; either version 2.1 of the License, or |
12 | | * (at your option) any later version. |
13 | | * |
14 | | * This program is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | * GNU Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with this program; if not, write to the Free Software Foundation, |
21 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
22 | | *****************************************************************************/ |
23 | | |
24 | | #include <vlc_strings.h> |
25 | | #include <vlc_text_style.h> |
26 | | #include <vlc_subpicture.h> |
27 | | |
28 | | #include <stdint.h> |
29 | | |
30 | | typedef struct substext_updater_region_t substext_updater_region_t; |
31 | | |
32 | | enum substext_updater_region_flags_e |
33 | | { |
34 | | UPDT_REGION_ORIGIN_X_IS_RATIO = 1 << 0, |
35 | | UPDT_REGION_ORIGIN_Y_IS_RATIO = 1 << 1, |
36 | | UPDT_REGION_EXTENT_X_IS_RATIO = 1 << 2, |
37 | | UPDT_REGION_EXTENT_Y_IS_RATIO = 1 << 3, |
38 | | UPDT_REGION_IGNORE_BACKGROUND = 1 << 4, |
39 | | UPDT_REGION_USES_GRID_COORDINATES = 1 << 5, |
40 | | UPDT_REGION_USES_16_9_GRID = 1 << 6, |
41 | | UPDT_REGION_FIXED_DONE = 1 << 31, |
42 | | }; |
43 | | |
44 | | struct substext_updater_region_t |
45 | | { |
46 | | struct |
47 | | { |
48 | | float x; |
49 | | float y; |
50 | | } origin, extent; |
51 | | /* store above percentile meanings as modifier flags */ |
52 | | int flags; /* subpicture_updater_sys_region_flags_e */ |
53 | | int align; /* alignment of the region itself */ |
54 | | bool b_absolute; /**< position is absolute in the movie */ |
55 | | bool b_in_window; /**< position the region in whole window */ |
56 | | int inner_align; /* alignment of content inside the region */ |
57 | | text_style_t *p_region_style; |
58 | | text_segment_t *p_segments; |
59 | | substext_updater_region_t *p_next; |
60 | | }; |
61 | | |
62 | | typedef struct |
63 | | { |
64 | | /* a min of one region */ |
65 | | substext_updater_region_t region; |
66 | | uint64_t scaling_modes_flags; /* see #29965 */ |
67 | | |
68 | | /* styling */ |
69 | | text_style_t *p_default_style; /* decoder (full or partial) defaults */ |
70 | | float margin_ratio; |
71 | | vlc_tick_t i_next_update; |
72 | | bool b_blink_even; |
73 | | } subtext_updater_sys_t; |
74 | | |
75 | | static inline void SubpictureUpdaterSysRegionClean(substext_updater_region_t *p_updtregion) |
76 | 519k | { |
77 | 519k | text_segment_ChainDelete( p_updtregion->p_segments ); |
78 | 519k | text_style_Delete( p_updtregion->p_region_style ); |
79 | 519k | } substtml.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 44.8k | { | 77 | 44.8k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 44.8k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 44.8k | } |
subsvtt.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 48.5k | { | 77 | 48.5k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 48.5k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 48.5k | } |
cc.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 19.2k | { | 77 | 19.2k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 19.2k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 19.2k | } |
Unexecuted instantiation: cea708.c:SubpictureUpdaterSysRegionClean Unexecuted instantiation: scte18.c:SubpictureUpdaterSysRegionClean stl.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 4.38k | { | 77 | 4.38k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 4.38k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 4.38k | } |
subsdec.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 397k | { | 77 | 397k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 397k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 397k | } |
Unexecuted instantiation: textst.c:SubpictureUpdaterSysRegionClean substx3g.c:SubpictureUpdaterSysRegionClean Line | Count | Source | 76 | 5.14k | { | 77 | 5.14k | text_segment_ChainDelete( p_updtregion->p_segments ); | 78 | 5.14k | text_style_Delete( p_updtregion->p_region_style ); | 79 | 5.14k | } |
|
80 | | |
81 | | static inline void SubpictureUpdaterSysRegionInit(substext_updater_region_t *p_updtregion) |
82 | 519k | { |
83 | 519k | memset(p_updtregion, 0, sizeof(*p_updtregion)); |
84 | 519k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; |
85 | 519k | p_updtregion->b_absolute = false; |
86 | 519k | p_updtregion->b_in_window = false; |
87 | 519k | p_updtregion->inner_align = 0 ; // centered |
88 | 519k | } substtml.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 44.8k | { | 83 | 44.8k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 44.8k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 44.8k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 44.8k | p_updtregion->inner_align = 0 ; // centered | 88 | 44.8k | } |
subsvtt.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 48.5k | { | 83 | 48.5k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 48.5k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 48.5k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 48.5k | p_updtregion->inner_align = 0 ; // centered | 88 | 48.5k | } |
cc.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 19.2k | { | 83 | 19.2k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 19.2k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 19.2k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 19.2k | p_updtregion->inner_align = 0 ; // centered | 88 | 19.2k | } |
Unexecuted instantiation: cea708.c:SubpictureUpdaterSysRegionInit Unexecuted instantiation: scte18.c:SubpictureUpdaterSysRegionInit stl.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 4.38k | { | 83 | 4.38k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 4.38k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 4.38k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 4.38k | p_updtregion->inner_align = 0 ; // centered | 88 | 4.38k | } |
subsdec.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 397k | { | 83 | 397k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 397k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 397k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 397k | p_updtregion->inner_align = 0 ; // centered | 88 | 397k | } |
Unexecuted instantiation: textst.c:SubpictureUpdaterSysRegionInit substx3g.c:SubpictureUpdaterSysRegionInit Line | Count | Source | 82 | 5.14k | { | 83 | 5.14k | memset(p_updtregion, 0, sizeof(*p_updtregion)); | 84 | 5.14k | p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM; | 85 | 5.14k | p_updtregion->b_absolute = false; | 86 | | p_updtregion->b_in_window = false; | 87 | 5.14k | p_updtregion->inner_align = 0 ; // centered | 88 | 5.14k | } |
|
89 | | |
90 | | static inline substext_updater_region_t *SubpictureUpdaterSysRegionNew( void ) |
91 | 43.2k | { |
92 | 43.2k | substext_updater_region_t *p_region = malloc(sizeof(*p_region)); |
93 | 43.2k | if(p_region) |
94 | 43.2k | SubpictureUpdaterSysRegionInit(p_region); |
95 | 43.2k | return p_region; |
96 | 43.2k | } substtml.c:SubpictureUpdaterSysRegionNew Line | Count | Source | 91 | 12.1k | { | 92 | 12.1k | substext_updater_region_t *p_region = malloc(sizeof(*p_region)); | 93 | 12.1k | if(p_region) | 94 | 12.1k | SubpictureUpdaterSysRegionInit(p_region); | 95 | 12.1k | return p_region; | 96 | 12.1k | } |
subsvtt.c:SubpictureUpdaterSysRegionNew Line | Count | Source | 91 | 29.8k | { | 92 | 29.8k | substext_updater_region_t *p_region = malloc(sizeof(*p_region)); | 93 | 29.8k | if(p_region) | 94 | 29.8k | SubpictureUpdaterSysRegionInit(p_region); | 95 | 29.8k | return p_region; | 96 | 29.8k | } |
cc.c:SubpictureUpdaterSysRegionNew Line | Count | Source | 91 | 1.22k | { | 92 | 1.22k | substext_updater_region_t *p_region = malloc(sizeof(*p_region)); | 93 | 1.22k | if(p_region) | 94 | 1.22k | SubpictureUpdaterSysRegionInit(p_region); | 95 | 1.22k | return p_region; | 96 | 1.22k | } |
Unexecuted instantiation: cea708.c:SubpictureUpdaterSysRegionNew Unexecuted instantiation: scte18.c:SubpictureUpdaterSysRegionNew Unexecuted instantiation: stl.c:SubpictureUpdaterSysRegionNew Unexecuted instantiation: subsdec.c:SubpictureUpdaterSysRegionNew Unexecuted instantiation: textst.c:SubpictureUpdaterSysRegionNew Unexecuted instantiation: substx3g.c:SubpictureUpdaterSysRegionNew |
97 | | |
98 | | static inline void SubpictureUpdaterSysRegionAdd(substext_updater_region_t *p_prev, |
99 | | substext_updater_region_t *p_new) |
100 | 43.2k | { |
101 | 43.2k | substext_updater_region_t **pp_next = &p_prev->p_next; |
102 | 57.5k | for(; *pp_next; pp_next = &(*pp_next)->p_next); |
103 | 43.2k | *pp_next = p_new; |
104 | 43.2k | } substtml.c:SubpictureUpdaterSysRegionAdd Line | Count | Source | 100 | 12.1k | { | 101 | 12.1k | substext_updater_region_t **pp_next = &p_prev->p_next; | 102 | 26.4k | for(; *pp_next; pp_next = &(*pp_next)->p_next); | 103 | 12.1k | *pp_next = p_new; | 104 | 12.1k | } |
subsvtt.c:SubpictureUpdaterSysRegionAdd Line | Count | Source | 100 | 29.8k | { | 101 | 29.8k | substext_updater_region_t **pp_next = &p_prev->p_next; | 102 | 29.8k | for(; *pp_next; pp_next = &(*pp_next)->p_next); | 103 | 29.8k | *pp_next = p_new; | 104 | 29.8k | } |
cc.c:SubpictureUpdaterSysRegionAdd Line | Count | Source | 100 | 1.22k | { | 101 | 1.22k | substext_updater_region_t **pp_next = &p_prev->p_next; | 102 | 1.22k | for(; *pp_next; pp_next = &(*pp_next)->p_next); | 103 | 1.22k | *pp_next = p_new; | 104 | 1.22k | } |
Unexecuted instantiation: cea708.c:SubpictureUpdaterSysRegionAdd Unexecuted instantiation: scte18.c:SubpictureUpdaterSysRegionAdd Unexecuted instantiation: stl.c:SubpictureUpdaterSysRegionAdd Unexecuted instantiation: subsdec.c:SubpictureUpdaterSysRegionAdd Unexecuted instantiation: textst.c:SubpictureUpdaterSysRegionAdd Unexecuted instantiation: substx3g.c:SubpictureUpdaterSysRegionAdd |
105 | | |
106 | | static uint64_t GetScalingModesAsFlags(const substext_updater_region_t *r) |
107 | 0 | { |
108 | 0 | uint64_t in_window_flags = 0; |
109 | 0 | for (int i=0; i<64 && r; i++) |
110 | 0 | { |
111 | 0 | in_window_flags |= (r->b_in_window ? UINT64_C(0) : UINT64_C(1)) << i; |
112 | 0 | r = r->p_next; |
113 | 0 | } |
114 | 0 | return in_window_flags; |
115 | 0 | } Unexecuted instantiation: substtml.c:GetScalingModesAsFlags Unexecuted instantiation: subsvtt.c:GetScalingModesAsFlags Unexecuted instantiation: cc.c:GetScalingModesAsFlags Unexecuted instantiation: cea708.c:GetScalingModesAsFlags Unexecuted instantiation: scte18.c:GetScalingModesAsFlags Unexecuted instantiation: stl.c:GetScalingModesAsFlags Unexecuted instantiation: subsdec.c:GetScalingModesAsFlags Unexecuted instantiation: textst.c:GetScalingModesAsFlags Unexecuted instantiation: substx3g.c:GetScalingModesAsFlags |
116 | | |
117 | | static void SubpictureTextUpdate(subpicture_t *subpic, |
118 | | const struct vlc_spu_updater_configuration *cfg) |
119 | 0 | { |
120 | 0 | subtext_updater_sys_t *sys = subpic->updater.sys; |
121 | 0 | const video_format_t *fmt_src = cfg->current.video_src; |
122 | 0 | const video_format_t *fmt_dst = cfg->current.video_dst; |
123 | 0 | substext_updater_region_t *p_updtregion = &sys->region; |
124 | 0 | video_format_t render_fmt = *fmt_dst; |
125 | 0 | video_format_t prev_render_fmt = *cfg->previous.video_dst; |
126 | |
|
127 | 0 | if (p_updtregion->b_in_window) |
128 | 0 | { |
129 | 0 | render_fmt.i_x_offset = render_fmt.i_y_offset = 0; |
130 | 0 | render_fmt.i_width = render_fmt.i_visible_width = cfg->current.display_width; |
131 | 0 | render_fmt.i_height = render_fmt.i_visible_height = cfg->current.display_height; |
132 | 0 | render_fmt.i_sar_num = render_fmt.i_sar_den = 1; |
133 | 0 | prev_render_fmt.i_x_offset = prev_render_fmt.i_y_offset = 0; |
134 | 0 | prev_render_fmt.i_width = prev_render_fmt.i_visible_width = cfg->previous.display_width; |
135 | 0 | prev_render_fmt.i_height = prev_render_fmt.i_visible_height = cfg->previous.display_height; |
136 | 0 | prev_render_fmt.i_sar_num = prev_render_fmt.i_sar_den = 1; |
137 | 0 | } |
138 | |
|
139 | 0 | uint64_t scaling_modes_flags = GetScalingModesAsFlags(p_updtregion); |
140 | |
|
141 | 0 | if (render_fmt.i_visible_width == prev_render_fmt.i_visible_width && |
142 | 0 | render_fmt.i_visible_height == prev_render_fmt.i_visible_height && |
143 | 0 | video_format_IsSimilar(cfg->previous.video_dst, fmt_dst) && |
144 | 0 | sys->scaling_modes_flags == scaling_modes_flags && |
145 | 0 | (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update > cfg->pts)) |
146 | 0 | return; |
147 | | |
148 | 0 | sys->scaling_modes_flags = scaling_modes_flags; |
149 | |
|
150 | 0 | if (!(p_updtregion->flags & UPDT_REGION_FIXED_DONE) && |
151 | 0 | p_updtregion->b_absolute && !vlc_spu_regions_is_empty(&subpic->regions) && |
152 | 0 | subpic->i_original_picture_width > 0 && |
153 | 0 | subpic->i_original_picture_height > 0) |
154 | 0 | { |
155 | 0 | subpicture_region_t *p_region = |
156 | 0 | vlc_spu_regions_first_or_null(&subpic->regions); |
157 | 0 | p_updtregion->flags |= UPDT_REGION_FIXED_DONE; |
158 | 0 | p_updtregion->origin.x = p_region->i_x; |
159 | 0 | p_updtregion->origin.y = p_region->i_y; |
160 | 0 | p_updtregion->extent.x = subpic->i_original_picture_width; |
161 | 0 | p_updtregion->extent.y = subpic->i_original_picture_height; |
162 | 0 | p_updtregion->flags &= ~(UPDT_REGION_ORIGIN_X_IS_RATIO|UPDT_REGION_ORIGIN_Y_IS_RATIO| |
163 | 0 | UPDT_REGION_EXTENT_X_IS_RATIO|UPDT_REGION_EXTENT_Y_IS_RATIO); |
164 | 0 | } |
165 | 0 | vlc_spu_regions_Clear( &subpic->regions ); |
166 | |
|
167 | 0 | assert(render_fmt.i_sar_num && render_fmt.i_sar_den); |
168 | |
|
169 | 0 | vlc_rational_t sar; |
170 | | |
171 | | /* NOTE about fmt_dst: |
172 | | * fmt_dst area and A/R will change to display once WxH of the |
173 | | * display is greater than the source video in direct rendering. |
174 | | * This will cause weird sudded region "moves" or "linebreaks" when |
175 | | * resizing window, mostly vertically. |
176 | | * see changes by 4a49754d943560fe79bc42f107d8ce566ea24898 */ |
177 | |
|
178 | 0 | if( sys->region.flags & UPDT_REGION_USES_GRID_COORDINATES ) |
179 | 0 | { |
180 | 0 | if( sys->region.flags & UPDT_REGION_USES_16_9_GRID ) |
181 | 0 | { |
182 | 0 | sar.num = 16; |
183 | 0 | sar.den = 9; |
184 | 0 | } |
185 | 0 | else |
186 | 0 | { |
187 | 0 | sar.num = 4; |
188 | 0 | sar.den = 3; |
189 | 0 | } |
190 | 0 | } |
191 | 0 | else |
192 | 0 | { |
193 | 0 | sar.num = 1; |
194 | 0 | sar.den = 1; |
195 | 0 | } |
196 | |
|
197 | 0 | if( sys->region.flags & UPDT_REGION_USES_GRID_COORDINATES ) |
198 | 0 | { |
199 | 0 | subpic->i_original_picture_width = render_fmt.i_height * sar.num / sar.den; |
200 | 0 | subpic->i_original_picture_height = render_fmt.i_height; |
201 | 0 | } |
202 | 0 | else |
203 | 0 | { |
204 | 0 | subpic->i_original_picture_width = render_fmt.i_width * render_fmt.i_sar_num / render_fmt.i_sar_den; |
205 | 0 | subpic->i_original_picture_height = render_fmt.i_height; |
206 | 0 | } |
207 | |
|
208 | 0 | bool b_schedule_blink_update = false; |
209 | |
|
210 | 0 | for( substext_updater_region_t *update_region = &sys->region; |
211 | 0 | update_region; update_region = update_region->p_next ) |
212 | 0 | { |
213 | 0 | subpicture_region_t *r = subpicture_region_NewText(); |
214 | 0 | if (!r) |
215 | 0 | return; |
216 | 0 | vlc_spu_regions_push(&subpic->regions, r); |
217 | 0 | r->fmt.i_sar_num = sar.num; |
218 | 0 | r->fmt.i_sar_den = sar.den; |
219 | |
|
220 | 0 | r->p_text = text_segment_Copy( update_region->p_segments ); |
221 | 0 | r->b_absolute = update_region->b_absolute; |
222 | 0 | r->b_in_window = update_region->b_in_window; |
223 | 0 | r->i_align = update_region->align; |
224 | 0 | r->text_flags |= update_region->inner_align & SUBPICTURE_ALIGN_MASK; |
225 | 0 | if (update_region->flags & UPDT_REGION_IGNORE_BACKGROUND) |
226 | 0 | r->text_flags |= VLC_SUBPIC_TEXT_FLAG_NO_REGION_BG; |
227 | 0 | bool b_gridmode = (update_region->flags & UPDT_REGION_USES_GRID_COORDINATES) != 0; |
228 | 0 | if (b_gridmode) |
229 | 0 | r->text_flags |= VLC_SUBPIC_TEXT_FLAG_GRID_MODE; |
230 | |
|
231 | 0 | if (!(update_region->flags & UPDT_REGION_FIXED_DONE)) |
232 | 0 | { |
233 | 0 | const float margin_ratio = sys->margin_ratio; |
234 | 0 | const int margin_h = margin_ratio * ( b_gridmode ? subpic->i_original_picture_width |
235 | 0 | : render_fmt.i_visible_width ); |
236 | 0 | const int margin_v = margin_ratio * render_fmt.i_visible_height; |
237 | | |
238 | | /* subpic invisible margins sizes */ |
239 | 0 | const int outerright_h = render_fmt.i_width - (render_fmt.i_visible_width + render_fmt.i_x_offset); |
240 | 0 | const int outerbottom_v = render_fmt.i_height - (render_fmt.i_visible_height + render_fmt.i_y_offset); |
241 | | /* regions usable */ |
242 | 0 | const int inner_w = render_fmt.i_visible_width - margin_h * 2; |
243 | 0 | const int inner_h = render_fmt.i_visible_height - margin_v * 2; |
244 | |
|
245 | 0 | if (r->i_align & SUBPICTURE_ALIGN_LEFT) |
246 | 0 | r->i_x = margin_h + render_fmt.i_x_offset; |
247 | 0 | else if (r->i_align & SUBPICTURE_ALIGN_RIGHT) |
248 | 0 | r->i_x = margin_h + outerright_h; |
249 | 0 | else |
250 | 0 | r->i_x = 0; |
251 | |
|
252 | 0 | if (r->i_align & SUBPICTURE_ALIGN_TOP ) |
253 | 0 | r->i_y = margin_v + render_fmt.i_y_offset; |
254 | 0 | else if (r->i_align & SUBPICTURE_ALIGN_BOTTOM ) |
255 | 0 | r->i_y = margin_v + outerbottom_v; |
256 | 0 | else |
257 | 0 | r->i_y = 0; |
258 | |
|
259 | 0 | if( update_region->flags & UPDT_REGION_ORIGIN_X_IS_RATIO ) |
260 | 0 | r->i_x += update_region->origin.x * inner_w; |
261 | 0 | else |
262 | 0 | r->i_x += update_region->origin.x; |
263 | |
|
264 | 0 | if( update_region->flags & UPDT_REGION_ORIGIN_Y_IS_RATIO ) |
265 | 0 | r->i_y += update_region->origin.y * inner_h; |
266 | 0 | else |
267 | 0 | r->i_y += update_region->origin.y; |
268 | |
|
269 | 0 | if( update_region->flags & UPDT_REGION_EXTENT_X_IS_RATIO ) |
270 | 0 | r->i_max_width += update_region->extent.x * inner_w; |
271 | 0 | else |
272 | 0 | r->i_max_width += update_region->extent.x; |
273 | |
|
274 | 0 | if( update_region->flags & UPDT_REGION_EXTENT_Y_IS_RATIO ) |
275 | 0 | r->i_max_height += update_region->extent.y * inner_h; |
276 | 0 | else |
277 | 0 | r->i_max_height += update_region->extent.y; |
278 | |
|
279 | 0 | } else { |
280 | | /* FIXME it doesn't adapt on crop settings changes */ |
281 | 0 | r->i_x = update_region->origin.x * render_fmt.i_width / update_region->extent.x; |
282 | 0 | r->i_y = update_region->origin.y * render_fmt.i_height / update_region->extent.y; |
283 | 0 | } |
284 | | |
285 | | /* Add missing default style, if any, to all segments */ |
286 | 0 | for ( text_segment_t* p_segment = r->p_text; p_segment; p_segment = p_segment->p_next ) |
287 | 0 | { |
288 | | /* Add decoder defaults */ |
289 | 0 | if( p_segment->style ) |
290 | 0 | text_style_Merge( p_segment->style, sys->p_default_style, false ); |
291 | 0 | else |
292 | 0 | p_segment->style = text_style_Duplicate( sys->p_default_style ); |
293 | |
|
294 | 0 | if( p_segment->style ) |
295 | 0 | { |
296 | | /* Update all segments font sizes in video source %, |
297 | | * so we can handle HiDPI properly and have consistent rendering limits */ |
298 | 0 | if( p_segment->style->i_font_size > 0 && fmt_src->i_visible_height > 0 ) |
299 | 0 | { |
300 | 0 | p_segment->style->f_font_relsize = 100.0 * p_segment->style->i_font_size / fmt_src->i_visible_height; |
301 | 0 | p_segment->style->i_font_size = 0; |
302 | 0 | } |
303 | |
|
304 | 0 | if( p_segment->style->i_style_flags & (STYLE_BLINK_BACKGROUND|STYLE_BLINK_FOREGROUND) ) |
305 | 0 | { |
306 | 0 | if( sys->b_blink_even ) /* do nothing at first */ |
307 | 0 | { |
308 | 0 | if( p_segment->style->i_style_flags & STYLE_BLINK_BACKGROUND ) |
309 | 0 | p_segment->style->i_background_alpha = |
310 | 0 | (~p_segment->style->i_background_alpha) & 0xFF; |
311 | 0 | if( p_segment->style->i_style_flags & STYLE_BLINK_FOREGROUND ) |
312 | 0 | p_segment->style->i_font_alpha = |
313 | 0 | (~p_segment->style->i_font_alpha) & 0xFF; |
314 | 0 | } |
315 | 0 | b_schedule_blink_update = true; |
316 | 0 | } |
317 | 0 | } |
318 | 0 | } |
319 | 0 | } |
320 | | |
321 | 0 | if( b_schedule_blink_update && |
322 | 0 | (sys->i_next_update == VLC_TICK_INVALID || sys->i_next_update < cfg->pts) ) |
323 | 0 | { |
324 | 0 | sys->i_next_update = cfg->pts + VLC_TICK_FROM_SEC(1); |
325 | 0 | sys->b_blink_even = !sys->b_blink_even; |
326 | 0 | } |
327 | 0 | } Unexecuted instantiation: substtml.c:SubpictureTextUpdate Unexecuted instantiation: subsvtt.c:SubpictureTextUpdate Unexecuted instantiation: cc.c:SubpictureTextUpdate Unexecuted instantiation: cea708.c:SubpictureTextUpdate Unexecuted instantiation: scte18.c:SubpictureTextUpdate Unexecuted instantiation: stl.c:SubpictureTextUpdate Unexecuted instantiation: subsdec.c:SubpictureTextUpdate Unexecuted instantiation: textst.c:SubpictureTextUpdate Unexecuted instantiation: substx3g.c:SubpictureTextUpdate |
328 | | static void SubpictureTextDestroy(subpicture_t *subpic) |
329 | 453k | { |
330 | 453k | subtext_updater_sys_t *sys = subpic->updater.sys; |
331 | | |
332 | 453k | SubpictureUpdaterSysRegionClean( &sys->region ); |
333 | 453k | substext_updater_region_t *p_region = sys->region.p_next; |
334 | 497k | while( p_region ) |
335 | 43.2k | { |
336 | 43.2k | substext_updater_region_t *p_next = p_region->p_next; |
337 | 43.2k | SubpictureUpdaterSysRegionClean( p_region ); |
338 | 43.2k | free( p_region ); |
339 | 43.2k | p_region = p_next; |
340 | 43.2k | } |
341 | 453k | text_style_Delete( sys->p_default_style ); |
342 | 453k | free(sys); |
343 | 453k | } substtml.c:SubpictureTextDestroy Line | Count | Source | 329 | 10.2k | { | 330 | 10.2k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 10.2k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 10.2k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 22.4k | while( p_region ) | 335 | 12.1k | { | 336 | 12.1k | substext_updater_region_t *p_next = p_region->p_next; | 337 | 12.1k | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 12.1k | free( p_region ); | 339 | 12.1k | p_region = p_next; | 340 | 12.1k | } | 341 | 10.2k | text_style_Delete( sys->p_default_style ); | 342 | 10.2k | free(sys); | 343 | 10.2k | } |
subsvtt.c:SubpictureTextDestroy Line | Count | Source | 329 | 18.7k | { | 330 | 18.7k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 18.7k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 18.7k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 48.5k | while( p_region ) | 335 | 29.8k | { | 336 | 29.8k | substext_updater_region_t *p_next = p_region->p_next; | 337 | 29.8k | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 29.8k | free( p_region ); | 339 | 29.8k | p_region = p_next; | 340 | 29.8k | } | 341 | 18.7k | text_style_Delete( sys->p_default_style ); | 342 | 18.7k | free(sys); | 343 | 18.7k | } |
cc.c:SubpictureTextDestroy Line | Count | Source | 329 | 18.0k | { | 330 | 18.0k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 18.0k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 18.0k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 19.2k | while( p_region ) | 335 | 1.22k | { | 336 | 1.22k | substext_updater_region_t *p_next = p_region->p_next; | 337 | 1.22k | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 1.22k | free( p_region ); | 339 | 1.22k | p_region = p_next; | 340 | 1.22k | } | 341 | 18.0k | text_style_Delete( sys->p_default_style ); | 342 | 18.0k | free(sys); | 343 | 18.0k | } |
Unexecuted instantiation: cea708.c:SubpictureTextDestroy Unexecuted instantiation: scte18.c:SubpictureTextDestroy stl.c:SubpictureTextDestroy Line | Count | Source | 329 | 4.38k | { | 330 | 4.38k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 4.38k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 4.38k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 4.38k | while( p_region ) | 335 | 0 | { | 336 | 0 | substext_updater_region_t *p_next = p_region->p_next; | 337 | 0 | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 0 | free( p_region ); | 339 | 0 | p_region = p_next; | 340 | 0 | } | 341 | 4.38k | text_style_Delete( sys->p_default_style ); | 342 | 4.38k | free(sys); | 343 | 4.38k | } |
subsdec.c:SubpictureTextDestroy Line | Count | Source | 329 | 397k | { | 330 | 397k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 397k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 397k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 397k | while( p_region ) | 335 | 0 | { | 336 | 0 | substext_updater_region_t *p_next = p_region->p_next; | 337 | 0 | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 0 | free( p_region ); | 339 | 0 | p_region = p_next; | 340 | 0 | } | 341 | 397k | text_style_Delete( sys->p_default_style ); | 342 | 397k | free(sys); | 343 | 397k | } |
Unexecuted instantiation: textst.c:SubpictureTextDestroy substx3g.c:SubpictureTextDestroy Line | Count | Source | 329 | 5.14k | { | 330 | 5.14k | subtext_updater_sys_t *sys = subpic->updater.sys; | 331 | | | 332 | 5.14k | SubpictureUpdaterSysRegionClean( &sys->region ); | 333 | 5.14k | substext_updater_region_t *p_region = sys->region.p_next; | 334 | 5.14k | while( p_region ) | 335 | 0 | { | 336 | 0 | substext_updater_region_t *p_next = p_region->p_next; | 337 | 0 | SubpictureUpdaterSysRegionClean( p_region ); | 338 | 0 | free( p_region ); | 339 | 0 | p_region = p_next; | 340 | 0 | } | 341 | 5.14k | text_style_Delete( sys->p_default_style ); | 342 | 5.14k | free(sys); | 343 | 5.14k | } |
|
344 | | |
345 | | static inline subpicture_t *decoder_NewSubpictureText(decoder_t *decoder) |
346 | 453k | { |
347 | 453k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); |
348 | | |
349 | 453k | static const struct vlc_spu_updater_ops spu_ops = |
350 | 453k | { |
351 | 453k | .update = SubpictureTextUpdate, |
352 | 453k | .destroy = SubpictureTextDestroy, |
353 | 453k | }; |
354 | | |
355 | 453k | subpicture_updater_t updater = { |
356 | 453k | .sys = sys, |
357 | 453k | .ops = &spu_ops, |
358 | 453k | }; |
359 | | |
360 | 453k | SubpictureUpdaterSysRegionInit( &sys->region ); |
361 | 453k | sys->margin_ratio = 0.04f; |
362 | 453k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); |
363 | 453k | if(unlikely(!sys->p_default_style)) |
364 | 0 | { |
365 | 0 | free(sys); |
366 | 0 | return NULL; |
367 | 0 | } |
368 | 453k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); |
369 | 453k | if (!subpic) |
370 | 0 | { |
371 | 0 | text_style_Delete(sys->p_default_style); |
372 | 0 | free(sys); |
373 | 0 | return NULL; |
374 | 0 | } |
375 | 453k | sys->region.b_absolute = true; sys->region.b_in_window = false; |
376 | | sys->i_next_update = VLC_TICK_INVALID; |
377 | 453k | return subpic; |
378 | 453k | } substtml.c:decoder_NewSubpictureText Line | Count | Source | 346 | 10.2k | { | 347 | 10.2k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 10.2k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 10.2k | { | 351 | 10.2k | .update = SubpictureTextUpdate, | 352 | 10.2k | .destroy = SubpictureTextDestroy, | 353 | 10.2k | }; | 354 | | | 355 | 10.2k | subpicture_updater_t updater = { | 356 | 10.2k | .sys = sys, | 357 | 10.2k | .ops = &spu_ops, | 358 | 10.2k | }; | 359 | | | 360 | 10.2k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 10.2k | sys->margin_ratio = 0.04f; | 362 | 10.2k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 10.2k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 10.2k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 10.2k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 10.2k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 10.2k | return subpic; | 378 | 10.2k | } |
subsvtt.c:decoder_NewSubpictureText Line | Count | Source | 346 | 18.7k | { | 347 | 18.7k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 18.7k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 18.7k | { | 351 | 18.7k | .update = SubpictureTextUpdate, | 352 | 18.7k | .destroy = SubpictureTextDestroy, | 353 | 18.7k | }; | 354 | | | 355 | 18.7k | subpicture_updater_t updater = { | 356 | 18.7k | .sys = sys, | 357 | 18.7k | .ops = &spu_ops, | 358 | 18.7k | }; | 359 | | | 360 | 18.7k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 18.7k | sys->margin_ratio = 0.04f; | 362 | 18.7k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 18.7k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 18.7k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 18.7k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 18.7k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 18.7k | return subpic; | 378 | 18.7k | } |
cc.c:decoder_NewSubpictureText Line | Count | Source | 346 | 18.0k | { | 347 | 18.0k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 18.0k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 18.0k | { | 351 | 18.0k | .update = SubpictureTextUpdate, | 352 | 18.0k | .destroy = SubpictureTextDestroy, | 353 | 18.0k | }; | 354 | | | 355 | 18.0k | subpicture_updater_t updater = { | 356 | 18.0k | .sys = sys, | 357 | 18.0k | .ops = &spu_ops, | 358 | 18.0k | }; | 359 | | | 360 | 18.0k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 18.0k | sys->margin_ratio = 0.04f; | 362 | 18.0k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 18.0k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 18.0k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 18.0k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 18.0k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 18.0k | return subpic; | 378 | 18.0k | } |
Unexecuted instantiation: cea708.c:decoder_NewSubpictureText Unexecuted instantiation: scte18.c:decoder_NewSubpictureText stl.c:decoder_NewSubpictureText Line | Count | Source | 346 | 4.38k | { | 347 | 4.38k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 4.38k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 4.38k | { | 351 | 4.38k | .update = SubpictureTextUpdate, | 352 | 4.38k | .destroy = SubpictureTextDestroy, | 353 | 4.38k | }; | 354 | | | 355 | 4.38k | subpicture_updater_t updater = { | 356 | 4.38k | .sys = sys, | 357 | 4.38k | .ops = &spu_ops, | 358 | 4.38k | }; | 359 | | | 360 | 4.38k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 4.38k | sys->margin_ratio = 0.04f; | 362 | 4.38k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 4.38k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 4.38k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 4.38k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 4.38k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 4.38k | return subpic; | 378 | 4.38k | } |
subsdec.c:decoder_NewSubpictureText Line | Count | Source | 346 | 397k | { | 347 | 397k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 397k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 397k | { | 351 | 397k | .update = SubpictureTextUpdate, | 352 | 397k | .destroy = SubpictureTextDestroy, | 353 | 397k | }; | 354 | | | 355 | 397k | subpicture_updater_t updater = { | 356 | 397k | .sys = sys, | 357 | 397k | .ops = &spu_ops, | 358 | 397k | }; | 359 | | | 360 | 397k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 397k | sys->margin_ratio = 0.04f; | 362 | 397k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 397k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 397k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 397k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 397k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 397k | return subpic; | 378 | 397k | } |
Unexecuted instantiation: textst.c:decoder_NewSubpictureText substx3g.c:decoder_NewSubpictureText Line | Count | Source | 346 | 5.14k | { | 347 | 5.14k | subtext_updater_sys_t *sys = calloc(1, sizeof(*sys)); | 348 | | | 349 | 5.14k | static const struct vlc_spu_updater_ops spu_ops = | 350 | 5.14k | { | 351 | 5.14k | .update = SubpictureTextUpdate, | 352 | 5.14k | .destroy = SubpictureTextDestroy, | 353 | 5.14k | }; | 354 | | | 355 | 5.14k | subpicture_updater_t updater = { | 356 | 5.14k | .sys = sys, | 357 | 5.14k | .ops = &spu_ops, | 358 | 5.14k | }; | 359 | | | 360 | 5.14k | SubpictureUpdaterSysRegionInit( &sys->region ); | 361 | 5.14k | sys->margin_ratio = 0.04f; | 362 | 5.14k | sys->p_default_style = text_style_Create( STYLE_NO_DEFAULTS ); | 363 | 5.14k | if(unlikely(!sys->p_default_style)) | 364 | 0 | { | 365 | 0 | free(sys); | 366 | 0 | return NULL; | 367 | 0 | } | 368 | 5.14k | subpicture_t *subpic = decoder_NewSubpicture(decoder, &updater); | 369 | 5.14k | if (!subpic) | 370 | 0 | { | 371 | 0 | text_style_Delete(sys->p_default_style); | 372 | 0 | free(sys); | 373 | 0 | return NULL; | 374 | 0 | } | 375 | 5.14k | sys->region.b_absolute = true; sys->region.b_in_window = false; | 376 | | sys->i_next_update = VLC_TICK_INVALID; | 377 | 5.14k | return subpic; | 378 | 5.14k | } |
|