Mercurial > mplayer.hg
comparison sub/ass_mp.c @ 35123:bf46a9b2abda
Set ass margins only from one single locations.
This fixes the different settings from e.g. vo and -ass-margin options
fighting against each other.
To allow this to work, apply the global option values on top of
the vo values.
If this is the most desirable behaviour is up to discussion,
but it seems reasonable and is the easiest way to solve this.
author | reimar |
---|---|
date | Wed, 26 Sep 2012 20:16:38 +0000 |
parents | ccf5f4e1e87c |
children | 7f3dbf4bf1d5 |
comparison
equal
deleted
inserted
replaced
35122:ccf5f4e1e87c | 35123:bf46a9b2abda |
---|---|
258 } | 258 } |
259 | 259 |
260 static void ass_configure(ASS_Renderer* priv, int w, int h, int unscaled) { | 260 static void ass_configure(ASS_Renderer* priv, int w, int h, int unscaled) { |
261 int hinting; | 261 int hinting; |
262 ass_set_frame_size(priv, w, h); | 262 ass_set_frame_size(priv, w, h); |
263 ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0); | |
264 ass_set_use_margins(priv, ass_use_margins); | 263 ass_set_use_margins(priv, ass_use_margins); |
265 ass_set_font_scale(priv, ass_font_scale); | 264 ass_set_font_scale(priv, ass_font_scale); |
266 if (!unscaled && (ass_hinting & 4)) | 265 if (!unscaled && (ass_hinting & 4)) |
267 hinting = 0; | 266 hinting = 0; |
268 else | 267 else |
323 return priv; | 322 return priv; |
324 } | 323 } |
325 | 324 |
326 int ass_force_reload = 0; // flag set if global ass-related settings were changed | 325 int ass_force_reload = 0; // flag set if global ass-related settings were changed |
327 | 326 |
328 ASS_Image* ass_mp_render_frame(ASS_Renderer *priv, ASS_Track* track, long long now, int* detect_change) { | |
329 if (ass_force_reload) { | |
330 ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0); | |
331 ass_set_use_margins(priv, ass_use_margins); | |
332 ass_set_font_scale(priv, ass_font_scale); | |
333 ass_force_reload = 0; | |
334 } | |
335 return ass_render_frame(priv, track, now, detect_change); | |
336 } | |
337 | |
338 /* EOSD source for ASS subtitles. */ | 327 /* EOSD source for ASS subtitles. */ |
339 | 328 |
340 static ASS_Renderer *ass_renderer; | 329 static ASS_Renderer *ass_renderer; |
341 static int prev_visibility; | 330 static int prev_visibility; |
342 | 331 |
343 static void eosd_ass_update(struct mp_eosd_source *src, const struct mp_eosd_settings *res, double ts) | 332 static void eosd_ass_update(struct mp_eosd_source *src, const struct mp_eosd_settings *res, double ts) |
344 { | 333 { |
345 long long ts_ms = (ts + sub_delay) * 1000 + .5; | 334 long long ts_ms = (ts + sub_delay) * 1000 + .5; |
346 ASS_Image *aimg; | 335 ASS_Image *aimg; |
347 struct mp_eosd_image *img; | 336 struct mp_eosd_image *img; |
348 if (res->changed || !src->initialized) { | 337 if (res->changed || !src->initialized || ass_force_reload) { |
349 double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb); | 338 double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb); |
350 ass_configure(ass_renderer, res->w, res->h, res->unscaled); | 339 ass_configure(ass_renderer, res->w, res->h, res->unscaled); |
351 ass_set_margins(ass_renderer, res->mt, res->mb, res->ml, res->mr); | 340 ass_set_margins(ass_renderer, res->mt + ass_top_margin, res->mb + ass_bottom_margin, res->ml, res->mr); |
352 ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw / res->srch); | 341 ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw / res->srch); |
353 src->initialized = 1; | 342 src->initialized = 1; |
343 ass_force_reload = 0; | |
354 } | 344 } |
355 aimg = sub_visibility && ass_track && ts != MP_NOPTS_VALUE ? | 345 aimg = sub_visibility && ass_track && ts != MP_NOPTS_VALUE ? |
356 ass_mp_render_frame(ass_renderer, ass_track, ts_ms, &src->changed) : | 346 ass_render_frame(ass_renderer, ass_track, ts_ms, &src->changed) : |
357 NULL; | 347 NULL; |
358 if (!aimg != !src->images) | 348 if (!aimg != !src->images) |
359 src->changed = 2; | 349 src->changed = 2; |
360 if (src->changed) { | 350 if (src->changed) { |
361 eosd_image_remove_all(src); | 351 eosd_image_remove_all(src); |