]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xsubenc.c
avcodec: Constify AVCodecs
[ffmpeg] / libavcodec / xsubenc.c
index ad7144db2db9e67a3a9fa7106fb5181d1b988e8f..03d0dc2d869b3dc13291743a04724e37e00009ed 100644 (file)
@@ -63,7 +63,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap,
         x0 = 0;
         while (x0 < w) {
             // Make sure we have enough room for at least one run and padding
-            if (pb->size_in_bits - put_bits_count(pb) < 7*8)
+            if (put_bytes_left(pb, 1) < 7)
                 return AVERROR_BUFFER_TOO_SMALL;
 
             x1 = x0;
@@ -132,19 +132,6 @@ 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]->data[0] || !h->rects[0]->data[1]) {
         av_log(avctx, AV_LOG_WARNING, "No subtitle bitmap available.\n");
@@ -197,7 +184,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
                         h->rects[0]->linesize[0] * 2,
                         h->rects[0]->w, (h->rects[0]->h + 1) >> 1))
         return AVERROR_BUFFER_TOO_SMALL;
-    bytestream_put_le16(&rlelenptr, put_bits_count(&pb) >> 3); // Length of first field
+    bytestream_put_le16(&rlelenptr, put_bytes_count(&pb, 0)); // Length of first field
 
     if (xsub_encode_rle(&pb, h->rects[0]->data[0] + h->rects[0]->linesize[0],
                         h->rects[0]->linesize[0] * 2,
@@ -211,7 +198,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
     flush_put_bits(&pb);
 
-    return hdr - buf + put_bits_count(&pb)/8;
+    return hdr - buf + put_bytes_output(&pb);
 }
 
 static av_cold int xsub_encoder_init(AVCodecContext *avctx)
@@ -224,7 +211,7 @@ static av_cold int xsub_encoder_init(AVCodecContext *avctx)
     return 0;
 }
 
-AVCodec ff_xsub_encoder = {
+const AVCodec ff_xsub_encoder = {
     .name       = "xsub",
     .long_name  = NULL_IF_CONFIG_SMALL("DivX subtitles (XSUB)"),
     .type       = AVMEDIA_TYPE_SUBTITLE,