diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-22 21:18:03 +0200 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-10-22 21:41:53 +0200 |
commit | ee573b4d31d49280df0fbec61af6184130d26737 (patch) | |
tree | 46f462f7e70dadd32d21e932449cd3124404a7a2 /libavcodec/xsubdec.c | |
parent | 37498a4b202e332e690ba02b9ab04afcbb08c9a5 (diff) | |
parent | a17a7661906ba295d67afd80ac0770422e1b02b3 (diff) | |
download | ffmpeg-ee573b4d31d49280df0fbec61af6184130d26737.tar.gz |
Merge commit 'a17a7661906ba295d67afd80ac0770422e1b02b3'
* commit 'a17a7661906ba295d67afd80ac0770422e1b02b3':
lavc: Add data and linesize to AVSubtitleRect
Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavcodec/xsubdec.c')
-rw-r--r-- | libavcodec/xsubdec.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 2db263ba29..540607aa74 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; // check that at least header fits if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) { @@ -104,13 +106,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); @@ -119,23 +121,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)); |