[PATCH] Basic SSA subtitle support

Developer discussion and patch submissions only!
Forum rules
This forum is for developer discussion and patch submission only.
Post Reply
davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

[PATCH] Basic SSA subtitle support

Post by davidfstr » Sun May 23, 2010 3:57 am

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
Regular User
Posts: 90
Joined: Sun Feb 24, 2008 8:27 pm

Re: [PATCH] Basic SSA subtitle support

Post by Starhawk » Sun May 23, 2010 4:18 pm

OMG, Awesome work! Very much looking forward to when being able to render SSA to the video track, but still, this is fantastic.

Starhawk
Regular User
Posts: 90
Joined: Sun Feb 24, 2008 8:27 pm

Re: [PATCH] Basic SSA subtitle support

Post by Starhawk » Sun May 23, 2010 4:37 pm

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
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr » Tue May 25, 2010 8:53 am

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 » Tue May 25, 2010 8:49 pm

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
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr » Wed May 26, 2010 1:50 am

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.

User avatar
Rodeo
HandBrake Team
Posts: 11517
Joined: Tue Mar 03, 2009 8:55 pm

Re: [PATCH] Basic SSA subtitle support

Post by Rodeo » Tue Jun 01, 2010 4:21 pm

Patch 1437 updated to apply cleanly to r3341: http://handbrake.fr/pastebin/pastebin.php?show=1449

User avatar
JohnAStebbins
HandBrake Team
Posts: 4953
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins » Tue Jun 01, 2010 8:23 pm

Thanks for updating the patch Rodeo.
Committed http://trac.handbrake.fr/changeset/3342

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

Re: [PATCH] Basic SSA subtitle support

Post by rachel » Tue Jun 01, 2010 9:12 pm

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: 4953
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins » Tue Jun 01, 2010 9:29 pm


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

Re: [PATCH] Basic SSA subtitle support

Post by rachel » Tue Jun 01, 2010 9:43 pm

Confirmed; it builds, ship it. :-)

davidfstr
Regular User
Posts: 149
Joined: Sun Apr 12, 2009 7:41 pm

Re: [PATCH] Basic SSA subtitle support

Post by davidfstr » Wed Jun 02, 2010 5:24 am

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: 4953
Joined: Sat Feb 09, 2008 7:21 pm

Re: [PATCH] Basic SSA subtitle support

Post by JohnAStebbins » Wed Jun 02, 2010 5:43 am


Post Reply