[PATCH] Rendering SSA/ASS subtitles via libass
#1
I've decided to try my hand at adding libass support to dvdplayer for my gsoc qualification task. I posted the patch here:
http://sourceforge.net/tracker/index.php...tid=581840

Some notes:

tested against revision 12670 of linuxport
libass requires the fontconfig library

The files created are:
DVDSubtitleParserSSA.cpp - Handles parsing the .ass/ssa file
DVDOverlaySSA .cpp - overlay containing libass structures

Files modified are:
DVDOverlayRenderer.cpp - added a function to handle rendering SSA overlays
DVDFactorySubtitle.cpp - to detect the ass/ssa file

Included in the file is a compiled version of libass as well as a test ssa file with some karaoke/positioning effects.


I'm not used to working with large MakeFile projects, so please feel free to call me an idiot and tell me what i did wrong Big Grin
Reply
#2
cool as.

now, i'm too tired to actually think so let's just do the sillies.

http://dureks.dyndns.org:8080/libass.patch.comments

tip; open your diff in a decent editor (like vim or emacs or whatever) and set the tabsize to something != 2 - makes them very easy to spot.

you need to update the browsable sub extension list in CGUIDialogAudioAndSubtitleSettings.cpp - and possible CUtil::CacheSubtitles (not sure if .ass is in there)

will look at the actual code later unless somebody beats me to it - first impression it looks good
Reply
#3
sweet:
will look at the code later but... do you think you could create an aas decoder in the same fashion as vobsubs...... ah forget it. i need to combine those two things somehow as otherwise we'll have to maintain two paths depending on if the aas subs are internal in mkv or as en external file.

* just forget my ramblings *
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
one note. ditch the now pts in the overlay structure, make that a parameter to the render function instead.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#5
I know I'm a bit off topic here, but please excuse me while I dance.
Reply
#6
I've tried this patch and it works for me.
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#7
Spiff: Sorry about not getting back to you about the nits/problems earlier, I've had 2 tests in as many days. I'll try and fix the nits and have another patch for you to look over tonight.
Reply
#8
Quote:+bool CDVDSubtitleParserSSA::Open(CDVDStreamInfo &hints)
+{
+ //Converting to C String for libass's convenience
+ int length = m_strFileName.length();
+ char fileName[length + 1];
+ m_strFileName.copy(fileName, length, 0);
+ fileName[length] = '\0';
+
+
+ CLog::Log(LOGINFO, "SSA Parser: Creating ass_track from SSA file: %s", fileName);
+ ass_track = ass_read_file(ass_library, fileName, 0);

ass_track = ass_read_file(ass_library, (char*)m_strFileName.c_str(), 0);


Also the current code leaks memory. There is nothing freeing the libass structures is there? One simple solution could be to add a ref counted wrapper around the libass pointers, which destroys it when done (christ I want the new shared_ptr of new c++ standards). should probably also have a criticalsection which is locked when used.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
Quote:+CDVDSubtitleParserSSA::CDVDSubtitleParserSSA(CDVDSubtitleStream* pStream, const string& strFile)
+ : CDVDSubtitleParser(pStream, strFile)
+{
+ //Setting a Default Font
+ string strFont = "Arial.ttf";
+ string strPath = "";
+ CLog::Log(LOGINFO, "SSA Parser: Creating ASS library structure");
+ ass_library = ass_library_init();
+
+ CLog::Log(LOGINFO, "SSA Parser: Initializing ASS library font settings");
+ if (!XFILE::CFile::Exists(strPath))
+ {
+ strPath = _P("Q:\\media\\Fonts\\");
+ ass_set_fonts_dir(ass_library, strPath.c_str());
+ strPath += strFont;
+ #ifdef _LINUX
+ strPath = PTH_IC(strPath);
+ #endif
+ }

How can strPath be anything but empty at the call of exists?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#10
The whole parsefile function seems useless (and with it the entire inputstream)? Doesn't the libass structure contain all the timing info you need?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#11
As for the first point: thanks Smile that didn't occur to me, haha.

The second point: I am actually not completey sure. there are some calls to ass_library_done and ass_track_done that i've since added that I forgot in the patch, but I do not know if it correctly frees all of its pointers.

Regardng the exists call: D'oh! i'll fix that.

The parsefile function: You are actually correct, the ass_track contains all necessary timing info, however I wasn't sure how to make it play nicely with how subtitles are currently done. The reason I still parse the file is to make Overlay objects with current times so. Is there another way you might reccomend?

Thanks for the comments!
Reply

Logout Mark Read Team Forum Stats Members Help
[PATCH] Rendering SSA/ASS subtitles via libass0