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

Alexandre Colucci alexandre at elgato.com
Tue Apr 26 10:48:46 CEST 2011


> 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: submission.diff
Type: application/octet-stream
Size: 1117 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110426/c101bbe5/attachment.obj>

More information about the ffmpeg-devel mailing list