[MPlayer-cvslog] r19544 - in trunk/libass: ass.h ass_render.c

eugeni subversion at mplayerhq.hu
Sat Aug 26 20:24:37 CEST 2006


Author: eugeni
Date: Sat Aug 26 20:24:37 2006
New Revision: 19544

Modified:
   trunk/libass/ass.h
   trunk/libass/ass_render.c

Log:
Add right and left margins support to libass.
Add ability to not use margins even when they are available.


Modified: trunk/libass/ass.h
==============================================================================
--- trunk/libass/ass.h	(original)
+++ trunk/libass/ass.h	Sat Aug 26 20:24:37 2006
@@ -14,6 +14,10 @@
 	double line_spacing; // additional line spacing (in frame pixels)
 	int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin.
 	int bottom_margin; // height of bottom margin. (frame_height - top_margin - bottom_margin) is original video height.
+	int left_margin;
+	int right_margin;
+	int use_margins; // 0 - place all subtitles inside original frame
+	                 // 1 - use margins for placing toptitles and subtitles
 	double aspect; // frame aspect ratio, d_width / d_height.
 } ass_settings_t;
 

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Sat Aug 26 20:24:37 2006
@@ -117,6 +117,7 @@
 	ass_instance_t* ass_priv;
 	int width, height; // screen dimensions
 	int orig_height; // frame height ( = screen height - margins )
+	int orig_width; // frame width ( = screen width - margins )
 	ass_track_t* track;
 	int add_bottom_margin; // additional margin, used to shift subtitles in case of collision
 	int add_top_margin;
@@ -140,7 +141,8 @@
 		track->PlayResX = 384;
 		track->PlayResY = 288;
 	} else {
-		double orig_aspect = (global_settings->aspect * frame_context.height) / frame_context.orig_height;
+		double orig_aspect = (global_settings->aspect * frame_context.height * frame_context.orig_width) /
+			frame_context.orig_height / frame_context.width;
 		if (!track->PlayResY) {
 			track->PlayResY = track->PlayResX / orig_aspect + .5;
 			mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResY undefined, setting %d  \n", track->PlayResY);
@@ -410,7 +412,7 @@
  * \brief Mapping between script and screen coordinates
  */
 static int x2scr(int x) {
-	return x*frame_context.width / frame_context.track->PlayResX;
+	return x*frame_context.width / frame_context.track->PlayResX + global_settings->left_margin;
 }
 /**
  * \brief Mapping between script and screen coordinates
@@ -420,11 +422,18 @@
 }
 // the same for toptitles
 static int y2scr_top(int y) {
-	return y * frame_context.orig_height / frame_context.track->PlayResY;
+	if (global_settings->use_margins)
+		return y * frame_context.orig_height / frame_context.track->PlayResY;
+	else
+		return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin;
 }
 // the same for subtitles
 static int y2scr_sub(int y) {
-	return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin + global_settings->bottom_margin;
+	if (global_settings->use_margins)
+		return y * frame_context.orig_height / frame_context.track->PlayResY +
+		       global_settings->top_margin + global_settings->bottom_margin;
+	else
+		return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin;
 }
 
 static void vmirror_bbox(FT_BBox* orig, FT_BBox* pbbox) {
@@ -1745,6 +1754,7 @@
 	frame_context.ass_priv = priv;
 	frame_context.width = global_settings->frame_width;
 	frame_context.height = global_settings->frame_height;
+	frame_context.orig_width = global_settings->frame_width - global_settings->left_margin - global_settings->right_margin;
 	frame_context.orig_height = global_settings->frame_height - global_settings->top_margin - global_settings->bottom_margin;
 	frame_context.track = track;
 	frame_context.add_bottom_margin = 0;



More information about the MPlayer-cvslog mailing list