[FFmpeg-devel] [PATCH] Fix incorrect decoding of DXSA subtitles (DivX subtitle with alpha)

Michael Niedermayer michaelni at gmx.at
Wed Apr 27 02:53:56 CEST 2011


On Tue, Apr 26, 2011 at 07:05:33PM +0200, Reimar Döffinger wrote:
> On Tue, Apr 26, 2011 at 10:48:46AM +0200, Alexandre Colucci wrote:
> > > On Thu, Apr 21, 2011 at 11:49:09AM +0200, Alexandre Colucci wrote:
> > >> This patch fixes the DXSA subtitles decoding. See screenshots for before and after the patch.
> > >> If the fourcc is DXSA, there are extra 4 bytes before the compressed data. The specifications are not public but the format is supported by DivX Player.
> > > 
> > > I do not like depending on the tag.
> > 
> > 
> > That is what the official reference implementation does.
> > 
> > 
> > > I assume there is nothing in the data itself to distinguish
> > > between the formats?
> > 
> > There isn't, that's why the reference implementation looks at the codec tag.
> > 
> > > If not I think it might be better to add a new CODEC_ID.
> > 
> > A trivial 4 byte difference does not really justify a new CODEC_ID, especially since that would require changing several files including those in libavformat and may break existing code.
> > 
> > > But either way, the code should just be
> > > |= *buf++ << 24;
> > > which will work if you do not run the loop above that case.
> > > Or use the same loop for both case, e.g. (pseudo-code):
> > > for (i = 0; i < sub->rects[0]->nb_colors; i++) {
> > >    uint32_t alpha = i ? 0xff000000 : 0;
> > >    if (tag == DXSA)
> > >        alpha = *buf++ << 24;
> > >    ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= alpha;
> > > }
> > 
> > Attached is the revised patch (functionally equivalent to the previous one) with only one loop.
> 
> It still looks a bit ugly to me but I don't have any
> convincingly better way.
> So it is fine by me, any objections by anyone else?

If the tags is the only way to detect it theres no point in wasting
time discussing. Its the way it is.
Also we have plenty of code in h263dec.c that also depends on the
codec_tag

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

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110427/e5e11a94/attachment.asc>


More information about the ffmpeg-devel mailing list