[PATCH] Basic SSA subtitle support

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
davidfstr
Enlightened
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

[PATCH] Basic SSA subtitle support

Post by davidfstr »

I've written an initial SSA->UTF-8 subtitle decoder. Works perfectly as-is but doesn't yet support recognition of bold, italic, and underline styling.

I've also slightly improved out-of-memory handling in the TX3G subtitle decoder.

The initial patch:
http://handbrake.fr/pastebin/pastebin.php?show=1429

I'll get an updated patch with bold/italic/underline support. Will almost certainly make the parsing code more complex. :wink:
Starhawk
Experienced
Posts: 90
Joined: Sun Feb 24, 2008 8:27 pm

Re: [PATCH] Basic SSA subtitle support

Post by Starhawk »

OMG, Awesome work! Very much looking forward to when being able to render SSA to the video track, but still, this is fantastic.
Starhawk
Experienced
Posts: 90
Joined: Sun Feb 24, 2008 8:27 pm

Re: [PATCH] Basic SSA subtitle support

Post by Starhawk »

The only issue I've seen is when there are multiple subtitles appearing on screen at the same time, during opening sequences with music lyrics and dialogue, for example. This is should be expected and is just the nature of the beast, IMO. Watching the encoded video, it looks like it tries to display all subtitles, but gets behind. It will eventually sync it self up again once subtitle activity has decreased.
davidfstr
Enlightened
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr »

All good to go and polished:
http://handbrake.fr/pastebin/pastebin.php?show=1437

Changes:

Code: Select all

SSA->UTF-8 subtitle decoder. Contributed by davidfstr.
* Also slightly improved out-of-memory handling in the TX3G subtitle decoder.
I have tested this with the following interesting subtitles:
1. aaa{\b1\i1}bbbcccdddeeefff
2. aaa{\u1\b1}bbb{\b0\be1\i1\u0}cccdddeeefff
3. aaa{\u1\b1}bbb{\i1}cccdddeeefff
4. aaa{\u1\b1}bbb{\i1\b0}cccdddeeefff

Next up: SSA burn-in support with libass
eddyg
Veteran User
Posts: 798
Joined: Mon Apr 23, 2007 3:34 am

Re: [PATCH] Basic SSA subtitle support

Post by eddyg »

Hi David,

any substitle rendered in HB should not be input type specific. Instead it should render the plain utf text subs in the hb subtitle packets. If the markup becomes an issue we'll have to specify what the expected format is in a hb sub.

Cheers Ed.
davidfstr
Enlightened
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr »

In the case of rendered SSA subs, I wasn't going to use the UTF-8 text at all.

I was planning on modifying dec-ssa-sub to use libass to create an output packet in the PICTURESUB format when the subtitle track is configured to output to PICTURESUB. If the output format is TEXTSUB, dec-ssa-sub would use the behavior indicated in this patch.

In case I was unclear, this patch is ready for review. I will be doing SSA burn-in in a separate patch.
Deleted User 11865

Re: [PATCH] Basic SSA subtitle support

Post by Deleted User 11865 »

Patch 1437 updated to apply cleanly to r3341: http://handbrake.fr/pastebin/pastebin.php?show=1449
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins »

Thanks for updating the patch Rodeo.
Committed http://trac.handbrake.fr/changeset/3342
rachel
Novice
Posts: 71
Joined: Thu Mar 15, 2007 7:34 pm

Re: [PATCH] Basic SSA subtitle support

Post by rachel »

Think this might have broke building, at least on OSX for me. Link error with _hb_decssasub undefined.

This is with a clean checkout of svn3342 on a core 2 duo mac, previously successfully used to build several earlier svn versions up to and including svn3339 yesterday. :-)

Full log of build: http://handbrake.fr/pastebin/pastebin.php?show=1452

(As I just reported a subtitling related bug seen on svn3339 and svn3340 and i just saw these committed I thought I'd look see if there was any difference or anything more in activity log. But can't as it won't build. :-))

Forget to svn add something? ;-)
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins »

rachel
Novice
Posts: 71
Joined: Thu Mar 15, 2007 7:34 pm

Re: [PATCH] Basic SSA subtitle support

Post by rachel »

Confirmed; it builds, ship it. :-)
davidfstr
Enlightened
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr »

Just noticed a buffer overflow that snuck in with the rich-text enhancements.

The following line in libhb/decssasub.c:

Code: Select all

int maxOutputSize = (end - pos) + ((numStyleOverrides + 1) * MAX_OVERHEAD_PER_OVERRIDE);
should read:

Code: Select all

int maxOutputSize = (end - textFieldPos) + ((numStyleOverrides + 1) * MAX_OVERHEAD_PER_OVERRIDE);
User avatar
JohnAStebbins
HandBrake Team
Posts: 5712
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins »

Post Reply