[Ffmpeg-devel] Subtitle patches

Ian Caulfield imc25
Mon Aug 15 14:40:42 CEST 2005

On Sun, 14 Aug 2005, Michael Niedermayer wrote:

> Hi
> On Wed, Jul 27, 2005 at 06:33:22PM +0100, Ian Caulfield wrote:
>> Hi,
>> I've attache a couple of subtitle decoder patches - subs.diff fixes a
>> couple of minor bugs in my DVB subtitle decoder, and also fixes a few
>> problems in the DVD decoder (the palette entries were being read
>> back-to-front, and the timing conversions were slighly off). I've also
>> added an extra field to the AVSubtitleRect structure to pass the DVD clut
>> mappings out, so that an application with access to the IFO files can
>> display the correct colours.
> thats not good at all, the way AVSubtitleRect is stored we cannot add
> anything to it without breaking binary compatibility, please change it to
> a linked list (or anything else if you have an idea), so we break
> compatibility just once instead of every time a field is added, also
> please increase the version number in avcodec.h if compatibility is broken

Will do. Given that the next change is going to have to break 
compatibility, it's probably worth addressing as much as possible!

> forget arrays of structures which are vissible outside libav*, as already
> described above its very problematic if we add a field and the user
> application was compiled against a version of libav* prior to that
> maybe merging AVSubtitle & AVSubtitleRect would simplify things if we
> output multiple AVSubtitles anyway?

There is a slight semantic difference - an AVSubtitle represents a single 
page of display - all the AVSubtitleRects within one page are displayed 
together. For DVD subtitles, it's possible to generate multiple pages from 
one packet. Perhaps if the decode call returns a list of AVSubtitles?

>>  - Different formats use different coordinate systems - DVB subtitles are
>> based on a 720x576 frame regardless of video resolution, while DVD
>> subtitles are given (I think) in video coordinates (does anyone have a
>> sub-D1 DVD to test this on?). Also DVD subtitles for letterboxed display
>> are formatted to put the text into the black bars - they're meant to be
>> scaled separately to the video. Currently there's no way to support this
>> in the AVSubtitle struct. What would be the best way to represent this?
> well either convert to the video width/height or set the width/height
> of the used coordinate system in AVCodecContext, i think the later is
> better in the long run as there might be multiple video streams with
> different resolution but the same subtitles

Agreed that the latter is the better solution. Just wondering how best to 
implement this.

DVD subtitles are scaled to video coordinates (although may be stretched 
to 4:3 with widescreen video). The subtitle stream doesn't specify the 
video size.

DVB subtitles are scaled to 720x576 (possible widescreen issues there 

If we added fields to AVCodecContext to indicate the frame size then an 
application such as ffmpeg doing transcoding would have to rescale 
AVSubtitles itself - might be better to add them to the AVSubtitle 
structure (or perhaps both?), then an encoder could rescale as it needed 
without the encoding application needing to know the output resolution.


More information about the ffmpeg-devel mailing list