changeset 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 488948c565b9
files sub/ass_mp.c sub/ass_mp.h
diffstat 2 files changed, 4 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/sub/ass_mp.c	Wed Sep 26 20:05:00 2012 +0000
+++ b/sub/ass_mp.c	Wed Sep 26 20:16:38 2012 +0000
@@ -260,7 +260,6 @@
 static void ass_configure(ASS_Renderer* priv, int w, int h, int unscaled) {
 	int hinting;
 	ass_set_frame_size(priv, w, h);
-	ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0);
 	ass_set_use_margins(priv, ass_use_margins);
 	ass_set_font_scale(priv, ass_font_scale);
 	if (!unscaled && (ass_hinting & 4))
@@ -325,16 +324,6 @@
 
 int ass_force_reload = 0; // flag set if global ass-related settings were changed
 
-ASS_Image* ass_mp_render_frame(ASS_Renderer *priv, ASS_Track* track, long long now, int* detect_change) {
-	if (ass_force_reload) {
-		ass_set_margins(priv, ass_top_margin, ass_bottom_margin, 0, 0);
-		ass_set_use_margins(priv, ass_use_margins);
-		ass_set_font_scale(priv, ass_font_scale);
-		ass_force_reload = 0;
-	}
-	return ass_render_frame(priv, track, now, detect_change);
-}
-
 /* EOSD source for ASS subtitles. */
 
 static ASS_Renderer *ass_renderer;
@@ -345,15 +334,16 @@
 	long long ts_ms = (ts + sub_delay) * 1000 + .5;
 	ASS_Image *aimg;
 	struct mp_eosd_image *img;
-	if (res->changed || !src->initialized) {
+	if (res->changed || !src->initialized || ass_force_reload) {
 		double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb);
 		ass_configure(ass_renderer, res->w, res->h, res->unscaled);
-		ass_set_margins(ass_renderer, res->mt, res->mb, res->ml, res->mr);
+		ass_set_margins(ass_renderer, res->mt + ass_top_margin, res->mb + ass_bottom_margin, res->ml, res->mr);
 		ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw / res->srch);
 		src->initialized = 1;
+		ass_force_reload = 0;
 	}
 	aimg = sub_visibility && ass_track && ts != MP_NOPTS_VALUE ?
-		ass_mp_render_frame(ass_renderer, ass_track, ts_ms, &src->changed) :
+		ass_render_frame(ass_renderer, ass_track, ts_ms, &src->changed) :
 		NULL;
 	if (!aimg != !src->images)
 		src->changed = 2;
--- a/sub/ass_mp.h	Wed Sep 26 20:05:00 2012 +0000
+++ b/sub/ass_mp.h	Wed Sep 26 20:16:38 2012 +0000
@@ -59,7 +59,6 @@
 } EOSD_ImageList;
 
 extern int ass_force_reload;
-ASS_Image* ass_mp_render_frame(ASS_Renderer *priv, ASS_Track* track, long long now, int* detect_change);
 
 /**
  * Initialize the use of EOSD for ASS subtitles rendering.