diff options
author | Alexandre Colucci <alexandre@elgato.com> | 2015-01-07 12:18:08 +0100 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2015-01-12 22:23:35 +0100 |
commit | 3d0752d82f8eaa326cff306ae50b0186a5b4d304 (patch) | |
tree | a21cc44521303014cccadd29298e1cfabac57464 | |
parent | bfe18be88a66da25b60a091de6011197dcb231fd (diff) | |
download | ffmpeg-3d0752d82f8eaa326cff306ae50b0186a5b4d304.tar.gz |
xsub: Support DXSA subtitles
These have a DXSA tag and contain alpha in addition to
color values for palette.
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 5a1addd7c1d8ff218ed4b84f4f02fdb83980094c)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r-- | libavcodec/xsubdec.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 3d85973de6..d01b410829 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -56,11 +56,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, int w, h, x, y, i; int64_t packet_time = 0; GetBitContext gb; + int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); memset(sub, 0, sizeof(*sub)); // check that at least header fits - if (buf_size < 27 + 7 * 2 + 4 * 3) { + if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) { av_log(avctx, AV_LOG_ERROR, "coded frame too small\n"); return -1; } @@ -107,9 +108,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, // read palette for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->pict.data[1])[i] = bytestream_get_be24(&buf); - // make all except background (first entry) non-transparent - for (i = 1; i < sub->rects[0]->nb_colors; i++) - ((uint32_t*)sub->rects[0]->pict.data[1])[i] |= 0xff000000; + + if (!has_alpha) { + // make all except background (first entry) non-transparent + for (i = 1; i < sub->rects[0]->nb_colors; i++) + ((uint32_t *)sub->rects[0]->pict.data[1])[i] |= 0xff000000; + } else { + for (i = 0; i < sub->rects[0]->nb_colors; i++) + ((uint32_t *)sub->rects[0]->pict.data[1])[i] |= *buf++ << 24; + } // process RLE-compressed data init_get_bits(&gb, buf, (buf_end - buf) * 8); |