diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-10-14 12:33:25 +0300 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-10-21 13:02:29 +0300 |
commit | a17a7661906ba295d67afd80ac0770422e1b02b3 (patch) | |
tree | 37dd2b426804d375f7b79f79c1fca43eb2baac8f /libavcodec/xsubenc.c | |
parent | f890677d05bc4e8b494a73373ab4cc19791bf884 (diff) |
lavc: Add data and linesize to AVSubtitleRect
Use the new fields directly instead of the ones from AVPicture.
This removes a layer of indirection which serves no pratical purpose
whatsoever, and will help in removing AVPicture structure completely
later.
Every subtitle encoder/decoder seamlessly points to the new arrays,
so it is possible to deprecate AVSubtitleRect.pict.
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/xsubenc.c')
-rw-r--r-- | libavcodec/xsubenc.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c index fc46fb8651..5b7e135d26 100644 --- a/libavcodec/xsubenc.c +++ b/libavcodec/xsubenc.c @@ -131,8 +131,21 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, if (h->num_rects > 1) av_log(avctx, AV_LOG_WARNING, "Only single rects supported (%d in subtitle.)\n", h->num_rects); +#if FF_API_AVPICTURE +FF_DISABLE_DEPRECATION_WARNINGS + if (!h->rects[0]->data[0]) { + AVSubtitleRect *rect = h->rects[0]; + int j; + for (j = 0; j < 4; j++) { + rect->data[j] = rect->pict.data[j]; + rect->linesize[j] = rect->pict.linesize[j]; + } + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + // TODO: render text-based subtitles into bitmaps - if (!h->rects[0]->pict.data[0] || !h->rects[0]->pict.data[1]) { + if (!h->rects[0]->data[0] || !h->rects[0]->data[1]) { av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n"); return -1; } @@ -142,7 +155,7 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, av_log(avctx, AV_LOG_WARNING, "No more than 4 subtitle colors supported (%d found.)\n", h->rects[0]->nb_colors); // TODO: Palette swapping if color zero is not transparent - if (((uint32_t *)h->rects[0]->pict.data[1])[0] & 0xff) + if (((uint32_t *)h->rects[0]->data[1])[0] & 0xff) av_log(avctx, AV_LOG_WARNING, "Color index 0 is not transparent. Transparency will be messed up.\n"); if (make_tc(startTime, start_tc) || make_tc(endTime, end_tc)) { @@ -174,19 +187,19 @@ static int xsub_encode(AVCodecContext *avctx, unsigned char *buf, // Palette for (i=0; i<4; i++) - bytestream_put_be24(&hdr, ((uint32_t *)h->rects[0]->pict.data[1])[i]); + bytestream_put_be24(&hdr, ((uint32_t *)h->rects[0]->data[1])[i]); // Bitmap // RLE buffer. Reserve 2 bytes for possible padding after the last row. init_put_bits(&pb, hdr, bufsize - (hdr - buf) - 2); - if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0], - h->rects[0]->pict.linesize[0]*2, + if (xsub_encode_rle(&pb, h->rects[0]->data[0], + h->rects[0]->linesize[0] * 2, h->rects[0]->w, (h->rects[0]->h + 1) >> 1)) return -1; bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3); // Length of first field - if (xsub_encode_rle(&pb, h->rects[0]->pict.data[0] + h->rects[0]->pict.linesize[0], - h->rects[0]->pict.linesize[0]*2, + if (xsub_encode_rle(&pb, h->rects[0]->data[0] + h->rects[0]->linesize[0], + h->rects[0]->linesize[0] * 2, h->rects[0]->w, h->rects[0]->h >> 1)) return -1; |