summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.h
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2020-03-28 03:19:30 +0200
committerOleg Oshmyan <chortos@inbox.lv>2020-07-05 21:25:52 +0300
commit450b791d9847e1730a3024d07f46c0b3d69d75d7 (patch)
tree07ad0df9fb6bc759fb8e99dabbf1826613750b51 /libass/ass_render.h
parent4698e1474a573659cfe97ebde3335ef4f4c48237 (diff)
downloadlibass-450b791d9847e1730a3024d07f46c0b3d69d75d7.tar.bz2
libass-450b791d9847e1730a3024d07f46c0b3d69d75d7.tar.xz
renderer: fix subtitles to full screen frame iff use_margins
Based on a commit by wm4. Nowadays, margins are used by players such as mpv to implement video zoom & pan, although this was not expected when margins were first implemented in libass. This results in unpleasant rendering when panning too far, and it is argued that subtitles should not change size or move when panning and zooming at all. libass also makes an attempt to keep subtitles on screen even when the use of margins is disabled. This is unintuitive and prone to break. Fix this by strictly separating events which render as if they were part of the video, and events which should use margins. The latter will now use the entire screen as canvas, rather than using the video frame. This actually simplifies the various y2scr functions. To preserve scaling (mainly for styled subtitles where line breaks are carefully chosen based on font/video size ratio) and to avoid badly stretching out things like ASS Margins due to aspect ratio differences between video and screen, estimate the unpanned & unzoomed video size from the video aspect ratio and the screen size, and base all scaling on that. This means that if the user plays a video in letterboxed mode without extra margins, they get the same scaling as if they were playing the same video with the same video rectangle size without any margins at all (with some elements merely spaced out to make use of the black bars); and when they zoom & pan afterwards, the subtitles don't move or change size. This changes behavior even with ass_set_use_margins(_, 0). Before this, normal dialogue was forced into the visible video area (if negative margins were set); now it renders it as if it were part of the video. This also changes the behavior of left and right margins even with ass_set_use_margins(_, 1). Before this, normal dialogue was forced into the visible video width (with both positive and negative margins); now it renders across the entire width of the screen/window. For 4:3 video letterboxed on 16:9 screen, this means text will cross the edges of the video, which may look worse than before.
Diffstat (limited to 'libass/ass_render.h')
-rw-r--r--libass/ass_render.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/libass/ass_render.h b/libass/ass_render.h
index e64fd6d5..417cfdfe 100644
--- a/libass/ass_render.h
+++ b/libass/ass_render.h
@@ -64,12 +64,12 @@ typedef struct {
double font_size_coeff; // font size multiplier
double line_spacing; // additional line spacing (in frame pixels)
double line_position; // vertical position for subtitles, 0-100 (0 = no change)
- int top_margin; // height of top margin. Everything except toptitles is shifted down by top_margin.
+ int top_margin; // height of top margin. Video frame 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
+ // 1 - place subtitles (incl. toptitles) in full display frame incl. margins
double par; // user defined pixel aspect ratio (0 = unset)
ASS_Hinting hinting;
ASS_ShapingLevel shaper;
@@ -302,8 +302,8 @@ struct ass_renderer {
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)
+ double fit_height; // frame height without zoom & pan (fit to screen & letterboxed)
+ double fit_width; // frame width without zoom & pan (fit to screen & letterboxed)
ASS_Track *track;
long long time; // frame's timestamp, ms
double font_scale;