[MPlayer-cvslog] r24815 - in trunk: libass/ass_render.c libvo/vo_gl.c

eugeni subversion at mplayerhq.hu
Fri Oct 19 20:16:23 CEST 2007


Author: eugeni
Date: Fri Oct 19 20:16:23 2007
New Revision: 24815

Log:
Avoid text deformation and subtitles moving outside the screen in pan-and-scan
mode.

For this, crop amounts are passed from vo_gl as negative margins sizes. They
are used to calculate aspect ratio. They are ignored when calculating subtitle
 positions, so subtitles will stay on screen most of the time.


Modified:
   trunk/libass/ass_render.c
   trunk/libvo/vo_gl.c

Modified: trunk/libass/ass_render.c
==============================================================================
--- trunk/libass/ass_render.c	(original)
+++ trunk/libass/ass_render.c	Fri Oct 19 20:16:23 2007
@@ -184,6 +184,8 @@ typedef struct frame_context_s {
 	int width, height; // screen dimensions
 	int orig_height; // frame height ( = screen height - margins )
 	int orig_width; // frame width ( = screen width - margins )
+	int orig_height_nocrop; // frame height ( = screen height - margins + cropheight)
+	int orig_width_nocrop; // frame width ( = screen width - margins + cropwidth)
 	ass_track_t* track;
 	long long time; // frame's timestamp, ms
 	double font_scale;
@@ -446,28 +448,33 @@ static ass_image_t* render_text(text_inf
  * \brief Mapping between script and screen coordinates
  */
 static int x2scr(int x) {
-	return x*frame_context.orig_width / frame_context.track->PlayResX + global_settings->left_margin;
+	return x*frame_context.orig_width_nocrop / frame_context.track->PlayResX +
+		FFMAX(global_settings->left_margin, 0);
 }
 /**
  * \brief Mapping between script and screen coordinates
  */
 static int y2scr(int y) {
-	return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin;
+	return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
+		FFMAX(global_settings->top_margin, 0);
 }
 // the same for toptitles
 static int y2scr_top(int y) {
 	if (global_settings->use_margins)
-		return y * frame_context.orig_height / frame_context.track->PlayResY;
+		return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY;
 	else
-		return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin;
+		return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
+			FFMAX(global_settings->top_margin, 0);
 }
 // the same for subtitles
 static int y2scr_sub(int y) {
 	if (global_settings->use_margins)
-		return y * frame_context.orig_height / frame_context.track->PlayResY +
-		       global_settings->top_margin + global_settings->bottom_margin;
+		return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
+			FFMAX(global_settings->top_margin, 0) +
+			FFMAX(global_settings->bottom_margin, 0);
 	else
-		return y * frame_context.orig_height / frame_context.track->PlayResY + global_settings->top_margin;
+		return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
+			FFMAX(global_settings->top_margin, 0);
 }
 
 static void compute_string_bbox( text_info_t* info, FT_BBox *abbox ) {
@@ -2101,6 +2108,12 @@ static int ass_start_frame(ass_renderer_
 	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.orig_width_nocrop = global_settings->frame_width -
+		FFMAX(global_settings->left_margin, 0) -
+		FFMAX(global_settings->right_margin, 0);
+	frame_context.orig_height_nocrop = global_settings->frame_height -
+		FFMAX(global_settings->top_margin, 0) -
+		FFMAX(global_settings->bottom_margin, 0);
 	frame_context.track = track;
 	frame_context.time = now;
 

Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c	(original)
+++ trunk/libvo/vo_gl.c	Fri Oct 19 20:16:23 2007
@@ -907,8 +907,8 @@ static int control(uint32_t request, voi
       if (scaled_osd) {r->w = image_width; r->h = image_height;}
       else if (vo_fs) {
         r->w = vo_screenwidth; r->h = vo_screenheight;
-        r->ml = r->mr = ass_border_x > 0 ? ass_border_x : 0;
-        r->mt = r->mb = ass_border_y > 0 ? ass_border_y : 0;
+        r->ml = r->mr = ass_border_x;
+        r->mt = r->mb = ass_border_y;
       } else {
         r->w = vo_dwidth; r->h = vo_dheight;
       }



More information about the MPlayer-cvslog mailing list