]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xsubdec.c
Merge commit '3eeb7edfc2a1157b7b0e0ce21ac2cd44d55d405b'
[ffmpeg] / libavcodec / xsubdec.c
index 2db263ba29e759421019db830a1d2c699e82fb88..540607aa74b40f352aad5107914789aae597d94b 100644 (file)
@@ -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));