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. ffplay.diff patches ffplay to be able to display subtitles. When testing these, I found a couple of issues that I'm not sure how to resolve: - On the Lord of The Rings extended DVDs, the subtitles for the director's commentary tracks fade in and out by giving several SET_CONTR commands. The dvdsub decoder just takes the last alpha values, so the subtitles are invisible. To properly decode these subtitles, av_decode_subtitle needs to be able to return multiple AVSubtitles for one call. I think the best way to implement this is probably to change the API so that instead of passing an AVSubtitle* to the function, pass an AVSubtitle** and let the decoder allocate an array of AVSubtitles and return the number of pages in got_subtitles - 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? Ian
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
ffplay.diff patches ffplay to be able to display subtitles.
When testing these, I found a couple of issues that I'm not sure how to resolve:
- On the Lord of The Rings extended DVDs, the subtitles for the director's commentary tracks fade in and out by giving several SET_CONTR commands. The dvdsub decoder just takes the last alpha values, so the subtitles are invisible. To properly decode these subtitles, av_decode_subtitle needs to be able to return multiple AVSubtitles for one call. I think the best way to implement this is probably to change the API so that instead of passing an AVSubtitle* to the function, pass an AVSubtitle** and let the decoder allocate an array of AVSubtitles and return the number of pages in got_subtitles
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?
- 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 [...] -- Michael
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 too). 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. Ian
Hi On Mon, Aug 15, 2005 at 01:40:42PM +0100, Ian Caulfield wrote: [...]
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?
yes
- 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 too).
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.
i would prefer that rescaling is done in the application, not the encoder [...] -- Michael
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.
ffplay.diff patches ffplay to be able to display subtitles.
applied except the extra field in AVSubtitleRect [...] -- Michael
participants (2)
-
imc25@cam.ac.uk -
michaelni@gmx.at