[FFmpeg-devel] [RFC] XSUB subtitle decoder

Reimar Döffinger Reimar.Doeffinger
Sun Aug 5 14:21:19 CEST 2007

On Sun, Aug 05, 2007 at 01:21:22PM +0200, Michael Niedermayer wrote:
> On Sat, Aug 04, 2007 at 08:55:20PM +0200, Reimar D?ffinger wrote:
> > here is my first approach it this, unfortunately there are a lot of
> > problems.
> > 1) I have only one very short sample:
> >   http://samples.mplayerhq.hu/sub/small.divx
> >   The other sample on our server:
> >   http://samples.mplayerhq.hu/sub/DivX+Subtitles.divx
> >   I am fairly certain that this does not contain any subtitles at all
> >   (though it contains a subtitle stream).
> > 2) ffplay is the only application to test, but unfortunately seems to be
> >    quite buggy:
> >    It does not check the boundaries if the subtitle before drawing
> >    it, so the small sample above crashes it since the y-Koordinate is
> >    too big. The reason for this is I think, that xsub gives
> >    Koordinates as on the DVD, i.e. assuming PAL resolution while
> >    ffplay assumes they are actual coordinates.
> >    The decoder can not do this transformation though since currently
> >    the actual movie resolution is not provided to it.
> hmm, whats in AVCodecContext.width/height? it seems these get read from
> avi for the subtitle stream?

Ah, right. That is how you get the original movie size. Now the question
is how to handle it.
Does adding a video_width and video_height to AVSubtitle and if set
using that to rescale in ffplay.c sound like a sensible approach?

> > 3) The start_display_time and end_display_time are relative to the
> >    packet pts. I lack a large enough sample to know if this works for
> >    xsub, but for the general case it seems like quite a strong
> >    assumption. Since packet pts is not passed to the decode function,
> >    a conversion is not possible here either.
> if relative doesnt work for some subtitle codec, we will have to think
> about what to do ...
> maybs simply adding a absolute_ts flag to AVCodec would do but maybe there
> are better solutions ...

Yes, maybe it's really better to wait until the problem crops up in
practice, I just didn't like that the subtitle code seems so very
closely tied to DVD-stuff :-(

> patch looks ok ...

Applied with some previous and additional revisions (esp. one fixing the
interlacing - I remembered they are really stored interlaced because it
was designed to be easily playable by standalone players and it was only
two lines of code to add it).

Reimar D?ffinger

More information about the ffmpeg-devel mailing list