aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2018-07-24 20:25:20 +0200
committerRainer Hochecker <fernetmenta@online.de>2018-07-24 20:25:20 +0200
commitd6f05b20944a52e42271e20d5f32961a79d9da4f (patch)
tree2d97fa82dd8744270d8256484b4065603c70878d
parent35c034879ad2ecff2efb494e55f732357c30e862 (diff)
VideoPlayer: fix aspec ratio of libass subs
-rw-r--r--xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp8
-rw-r--r--xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.h3
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/OverlayRenderer.cpp5
3 files changed, 11 insertions, 5 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp
index c95e7324c8..599b221c95 100644
--- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp
+++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.cpp
@@ -137,7 +137,8 @@ bool CDVDSubtitlesLibass::CreateTrack(char* buf, size_t size)
return true;
}
-ASS_Image* CDVDSubtitlesLibass::RenderImage(int frameWidth, int frameHeight, int videoWidth, int videoHeight, double pts, int useMargin, double position, int *changes)
+ASS_Image* CDVDSubtitlesLibass::RenderImage(int frameWidth, int frameHeight, int videoWidth, int videoHeight, int sourceWidth, int sourceHeight,
+ double pts, int useMargin, double position, int *changes)
{
CSingleLock lock(m_section);
if(!m_renderer || !m_track)
@@ -146,14 +147,15 @@ ASS_Image* CDVDSubtitlesLibass::RenderImage(int frameWidth, int frameHeight, int
return NULL;
}
- double storage_aspect = (double)frameWidth / frameHeight;
+ double sar = (double)sourceWidth / sourceHeight;
+ double dar = (double)videoWidth / videoHeight;
ass_set_frame_size(m_renderer, frameWidth, frameHeight);
int topmargin = (frameHeight - videoHeight) / 2;
int leftmargin = (frameWidth - videoWidth) / 2;
ass_set_margins(m_renderer, topmargin, topmargin, leftmargin, leftmargin);
ass_set_use_margins(m_renderer, useMargin);
ass_set_line_position(m_renderer, position);
- ass_set_aspect_ratio(m_renderer, storage_aspect / CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().fPixelRatio, storage_aspect);
+ ass_set_aspect_ratio(m_renderer, dar, sar);
return ass_render_frame(m_renderer, m_track, DVD_TIME_TO_MSEC(pts), changes);
}
diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.h b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.h
index f0f967cbfe..44230af790 100644
--- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.h
+++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDSubtitlesLibass.h
@@ -33,7 +33,8 @@ public:
CDVDSubtitlesLibass();
~CDVDSubtitlesLibass() override;
- ASS_Image* RenderImage(int frameWidth, int frameHeight, int videoWidth, int videoHeight, double pts, int useMargin = 0, double position = 0.0, int* changes = NULL);
+ ASS_Image* RenderImage(int frameWidth, int frameHeight, int videoWidth, int videoHeight, int sourceWidth, int sourceHeight,
+ double pts, int useMargin = 0, double position = 0.0, int* changes = NULL);
ASS_Event* GetEvents();
int GetNrOfEvents();
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRenderer.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRenderer.cpp
index 40ec912e13..8b55e17e66 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRenderer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/OverlayRenderer.cpp
@@ -326,6 +326,8 @@ COverlay* CRenderer::Convert(CDVDOverlaySSA* o, double pts)
// libass render in a target area which named as frame. the frame size may bigger than video size,
// and including margins between video to frame edge. libass allow to render subtitles into the margins.
// this has been used to show subtitles in the top or bottom "black bar" between video to frame border.
+ int sourceWidth = MathUtils::round_int(m_rs.Width());
+ int sourceHeight = MathUtils::round_int(m_rs.Height());
int videoWidth = MathUtils::round_int(m_rd.Width());
int videoHeight = MathUtils::round_int(m_rd.Height());
int targetWidth = MathUtils::round_int(m_rv.Width());
@@ -354,7 +356,8 @@ COverlay* CRenderer::Convert(CDVDOverlaySSA* o, double pts)
else
position = 0.0;
int changes = 0;
- ASS_Image* images = o->m_libass->RenderImage(targetWidth, targetHeight, videoWidth, videoHeight, pts, useMargin, position, &changes);
+ ASS_Image* images = o->m_libass->RenderImage(targetWidth, targetHeight, videoWidth, videoHeight, sourceWidth, sourceHeight,
+ pts, useMargin, position, &changes);
if(o->m_textureid)
{