mirror of https://github.com/mpv-player/mpv
Add right and left margins support to libass.
Add ability to not use margins even when they are available. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19544 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
d8dab41707
commit
a0f422546d
|
@ -14,6 +14,10 @@ typedef struct ass_settings_s {
|
||||||
double line_spacing; // additional line spacing (in frame pixels)
|
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 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 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.
|
double aspect; // frame aspect ratio, d_width / d_height.
|
||||||
} ass_settings_t;
|
} ass_settings_t;
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,7 @@ typedef struct frame_context_s {
|
||||||
ass_instance_t* ass_priv;
|
ass_instance_t* ass_priv;
|
||||||
int width, height; // screen dimensions
|
int width, height; // screen dimensions
|
||||||
int orig_height; // frame height ( = screen height - margins )
|
int orig_height; // frame height ( = screen height - margins )
|
||||||
|
int orig_width; // frame width ( = screen width - margins )
|
||||||
ass_track_t* track;
|
ass_track_t* track;
|
||||||
int add_bottom_margin; // additional margin, used to shift subtitles in case of collision
|
int add_bottom_margin; // additional margin, used to shift subtitles in case of collision
|
||||||
int add_top_margin;
|
int add_top_margin;
|
||||||
|
@ -140,7 +141,8 @@ static void ass_lazy_track_init(void)
|
||||||
track->PlayResX = 384;
|
track->PlayResX = 384;
|
||||||
track->PlayResY = 288;
|
track->PlayResY = 288;
|
||||||
} else {
|
} 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) {
|
if (!track->PlayResY) {
|
||||||
track->PlayResY = track->PlayResX / orig_aspect + .5;
|
track->PlayResY = track->PlayResX / orig_aspect + .5;
|
||||||
mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResY undefined, setting %d \n", track->PlayResY);
|
mp_msg(MSGT_GLOBAL, MSGL_WARN, "PlayResY undefined, setting %d \n", track->PlayResY);
|
||||||
|
@ -410,7 +412,7 @@ static int render_text(text_info_t* text_info, int dst_x, int dst_y)
|
||||||
* \brief Mapping between script and screen coordinates
|
* \brief Mapping between script and screen coordinates
|
||||||
*/
|
*/
|
||||||
static int x2scr(int x) {
|
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
|
* \brief Mapping between script and screen coordinates
|
||||||
|
@ -420,11 +422,18 @@ static int y2scr(int y) {
|
||||||
}
|
}
|
||||||
// the same for toptitles
|
// the same for toptitles
|
||||||
static int y2scr_top(int y) {
|
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
|
// the same for subtitles
|
||||||
static int y2scr_sub(int y) {
|
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) {
|
static void vmirror_bbox(FT_BBox* orig, FT_BBox* pbbox) {
|
||||||
|
@ -1745,6 +1754,7 @@ int ass_start_frame(ass_instance_t *priv, ass_track_t* track, long long now)
|
||||||
frame_context.ass_priv = priv;
|
frame_context.ass_priv = priv;
|
||||||
frame_context.width = global_settings->frame_width;
|
frame_context.width = global_settings->frame_width;
|
||||||
frame_context.height = global_settings->frame_height;
|
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_height = global_settings->frame_height - global_settings->top_margin - global_settings->bottom_margin;
|
||||||
frame_context.track = track;
|
frame_context.track = track;
|
||||||
frame_context.add_bottom_margin = 0;
|
frame_context.add_bottom_margin = 0;
|
||||||
|
|
Loading…
Reference in New Issue