]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dvdsubenc.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / dvdsubenc.c
index e54b5f0d7bf1082b8d508352d0f80bb4350bf8bf..cbea4e372cd8bdcfda7aecdf4dad1fae958c9a1e 100644 (file)
@@ -279,20 +279,6 @@ static int encode_dvd_subtitles(AVCodecContext *avctx,
             break;
         }
 
-#if FF_API_AVPICTURE
-FF_DISABLE_DEPRECATION_WARNINGS
-    for (i = 0; i < rects; i++)
-        if (!h->rects[i]->data[0]) {
-            AVSubtitleRect *rect = h->rects[i];
-            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
-
     vrect = *h->rects[0];
 
     if (rects > 1) {
@@ -424,6 +410,29 @@ fail:
     return ret;
 }
 
+static int bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
+{
+    int ret;
+    char *str;
+
+    ret = av_bprint_finalize(buf, &str);
+    if (ret < 0)
+        return ret;
+    if (!av_bprint_is_complete(buf)) {
+        av_free(str);
+        return AVERROR(ENOMEM);
+    }
+
+    avctx->extradata = str;
+    /* Note: the string is NUL terminated (so extradata can be read as a
+     * string), but the ending character is not accounted in the size (in
+     * binary formats you are likely not supposed to mux that character). When
+     * extradata is copied, it is also padded with AV_INPUT_BUFFER_PADDING_SIZE
+     * zeros. */
+    avctx->extradata_size = buf->len;
+    return 0;
+}
+
 static int dvdsub_init(AVCodecContext *avctx)
 {
     DVDSubtitleContext *dvdc = avctx->priv_data;
@@ -451,7 +460,7 @@ static int dvdsub_init(AVCodecContext *avctx)
         av_bprintf(&extradata, " %06"PRIx32"%c",
                    dvdc->global_palette[i] & 0xFFFFFF, i < 15 ? ',' : '\n');
 
-    ret = avpriv_bprint_to_extradata(avctx, &extradata);
+    ret = bprint_to_extradata(avctx, &extradata);
     if (ret < 0)
         return ret;
 
@@ -484,7 +493,7 @@ static const AVClass dvdsubenc_class = {
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
-AVCodec ff_dvdsub_encoder = {
+const AVCodec ff_dvdsub_encoder = {
     .name           = "dvdsub",
     .long_name      = NULL_IF_CONFIG_SMALL("DVD subtitles"),
     .type           = AVMEDIA_TYPE_SUBTITLE,