]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xsubenc.c
vaapi_encode: Refactor slightly to allow easier setting of global options
[ffmpeg] / libavcodec / xsubenc.c
index 6f359a1d6e8b9ac54bd77e45c6ca3a06b4d3d37a..5b7e135d265db185ba89f6ce311c88c94e64e7c5 100644 (file)
@@ -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;
 
@@ -210,10 +223,10 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx)
 }
 
 AVCodec ff_xsub_encoder = {
-    .name      = "xsub",
-    .type      = AVMEDIA_TYPE_SUBTITLE,
-    .id        = AV_CODEC_ID_XSUB,
-    .init      = xsub_encoder_init,
-    .encode_sub= xsub_encode,
-    .long_name = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
+    .name       = "xsub",
+    .long_name  = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
+    .type       = AVMEDIA_TYPE_SUBTITLE,
+    .id         = AV_CODEC_ID_XSUB,
+    .init       = xsub_encoder_init,
+    .encode_sub = xsub_encode,
 };