From 85ce9663a62d89f269eb14d2d303204490647870 Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 25 Feb 2022 00:17:02 +0100 Subject: [PATCH] Pass storage size to libass to fix rendering Since ASS rendering depends on the storage size of the video libass needs to know about it to render the subtitles correctly. If it isn't told about the storage size libass uses the value from PlayRes{X,Y} as a guess, but this isn't always correct. With Aegisub currently always rendering at storage resolution this ends up the same as the frame size. --- src/subtitles_provider_libass.cpp | 2 ++ subprojects/csri/backends/libass/libass_csri.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/subtitles_provider_libass.cpp b/src/subtitles_provider_libass.cpp index 815c820da..f497bdb34 100644 --- a/src/subtitles_provider_libass.cpp +++ b/src/subtitles_provider_libass.cpp @@ -170,6 +170,8 @@ LibassSubtitlesProvider::~LibassSubtitlesProvider() { void LibassSubtitlesProvider::DrawSubtitles(VideoFrame &frame,double time) { ass_set_frame_size(renderer(), frame.width, frame.height); + // Note: this relies on Aegisub always rendering at video storage res + ass_set_storage_size(renderer(), frame.width, frame.height); ASS_Image* img = ass_render_frame(renderer(), ass_track, int(time * 1000), nullptr); diff --git a/subprojects/csri/backends/libass/libass_csri.c b/subprojects/csri/backends/libass/libass_csri.c index 295b182d6..7447b2a84 100644 --- a/subprojects/csri/backends/libass/libass_csri.c +++ b/subprojects/csri/backends/libass/libass_csri.c @@ -105,6 +105,8 @@ int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt) if (!csri_is_rgb(fmt->pixfmt) || csri_has_alpha(fmt->pixfmt)) return -1; ass_set_frame_size(inst->ass_renderer, fmt->width, fmt->height); + // Note: this relies on CSRI always rendering at video storage res + ass_set_storage_size(inst->ass_renderer, fmt->width, fmt->height); return 0; }