[MPlayer-dev-eng] [PATCH] Move SSA/ASS subtitles handling out of mkv demuxer

Michael Niedermayer michaelni at gmx.at
Sun Dec 30 03:15:17 CET 2007


On Sun, Dec 30, 2007 at 05:01:37AM +0300, Evgeniy Stepanov wrote:
> Hi,
> 
> this patch moves ass subtitle parsing out of mkv demuxer.
> 
> Headers are stored in sh_sub_t codecdata field and parsed lazily in 
> update_subtitles. Events are passed as demuxer packets and handled also in 
> update_subtitles. This way, subtitle handling in mkv demuxer is the same for 
> all types of subtitles (except vobsub).
> 
> update_subtitles() becomes more complicated. There are 4 cases now:
> 1. 't' subs with libass -> convert to struct subtitle then add to ass_track
> 2. 'a' subs with libass -> add to ass_track directly
> 3. 't' subs without libass -> passed to sub_add_text
> 4. 'a' subs without libass -> 8 leading fields stripped, then passed to 
> sub_add_text
> 
> With these changes, subtitles are always put into demuxer packets unchanged. 
> Libass support in lavf demuxer will be also much easier to do.

no real review, someone else should do that, just a minor comment

[...]
> -		if (pts != MP_NOPTS_VALUE) {
> -		    if (endpts == MP_NOPTS_VALUE)
> -			sub_clear_text(&subs, MP_NOPTS_VALUE);
> -		    sub_add_text(&subs, packet, len, endpts);
> -		    vo_osd_changed(OSDTYPE_SUBTITLE);
> -		}
> +            if (pts != MP_NOPTS_VALUE) {
> +                if (endpts == MP_NOPTS_VALUE)
> +                    sub_clear_text(&subs, MP_NOPTS_VALUE);
> +                if (type == 'a') { // ssa/ass subs without libass => convert to plaintext
> +                    int i;
> +                    unsigned char* p = packet;
> +                    for (i=0; i < 8 && *p != '\0'; p++)
> +                        if (*p == ',')
> +                            i++;
> +                    if (*p == '\0')  /* Broken line? */
> +                        continue;
> +                    len -= p - packet;
> +                    packet = p;
> +                }
> +                sub_add_text(&subs, packet, len, endpts);
> +                vo_osd_changed(OSDTYPE_SUBTITLE);
> +            }

you lost some tabs here which cause extra lines to appear in the diff
aka cosmetics ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20071230/49c2aeac/attachment.pgp>


More information about the MPlayer-dev-eng mailing list