From a17a7661906ba295d67afd80ac0770422e1b02b3 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 14 Oct 2015 11:33:25 +0200 Subject: 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 --- libavcodec/xsubdec.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'libavcodec/xsubdec.c') diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index a7dd7ee628..7e25787989 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -57,6 +57,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, int64_t packet_time = 0; GetBitContext gb; int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); + AVSubtitleRect *rect; + int j; memset(sub, 0, sizeof(*sub)); @@ -106,13 +108,13 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, sub->rects[0]->x = x; sub->rects[0]->y = y; sub->rects[0]->w = w; sub->rects[0]->h = h; sub->rects[0]->type = SUBTITLE_BITMAP; - sub->rects[0]->pict.linesize[0] = w; - sub->rects[0]->pict.data[0] = av_malloc(w * h); + sub->rects[0]->linesize[0] = w; + sub->rects[0]->data[0] = av_malloc(w * h); sub->rects[0]->nb_colors = 4; - sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE); - if (!sub->rects[0]->pict.data[0] || !sub->rects[0]->pict.data[1]) { - av_freep(&sub->rects[0]->pict.data[1]); - av_freep(&sub->rects[0]->pict.data[0]); + sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE); + if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) { + av_freep(&sub->rects[0]->data[1]); + av_freep(&sub->rects[0]->data[0]); av_freep(&sub->rects[0]); av_freep(&sub->rects); return AVERROR(ENOMEM); @@ -120,23 +122,33 @@ 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); + ((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf); 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; + ((uint32_t *)sub->rects[0]->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; + ((uint32_t *)sub->rects[0]->data[1])[i] |= *buf++ << 24; } +#if FF_API_AVPICTURE +FF_DISABLE_DEPRECATION_WARNINGS + rect = sub->rects[0]; + for (j = 0; j < 4; j++) { + rect->pict.data[j] = rect->data[j]; + rect->pict.linesize[j] = rect->linesize[j]; + } +FF_ENABLE_DEPRECATION_WARNINGS +#endif + // process RLE-compressed data init_get_bits(&gb, buf, (buf_end - buf) * 8); - bitmap = sub->rects[0]->pict.data[0]; + bitmap = sub->rects[0]->data[0]; for (y = 0; y < h; y++) { // interlaced: do odd lines - if (y == (h + 1) / 2) bitmap = sub->rects[0]->pict.data[0] + w; + if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w; for (x = 0; x < w; ) { int log2 = ff_log2_tab[show_bits(&gb, 8)]; int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); -- cgit v1.2.3