]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xsubenc.c
avcodec/msmpeg4dec: Avoid duplication of VLC init code
[ffmpeg] / libavcodec / xsubenc.c
index 4d58e0f3b589ec599e63fa8a3937dcf3810d488e..9139159c986909650f91ee4abcafdc901be3efbc 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "avcodec.h"
 #include "bytestream.h"
+#include "internal.h"
 #include "put_bits.h"
 
 /**
@@ -62,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;
@@ -90,7 +91,7 @@ static int xsub_encode_rle(PutBitContext *pb, const uint8_t *bitmap,
         if (color != PADDING_COLOR && (PADDING + (w&1)))
             put_xsub_rle(pb, PADDING + (w&1), PADDING_COLOR);
 
-        avpriv_align_put_bits(pb);
+        align_put_bits(pb);
 
         bitmap += linesize;
     }
@@ -196,7 +197,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,
@@ -206,12 +207,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
     // Enforce total height to be a multiple of 2
     if (h->rects[0]->h & 1) {
         put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR);
-        avpriv_align_put_bits(&pb);
     }
 
     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)
@@ -231,4 +231,5 @@ AVCodec ff_xsub_encoder = {
     .id         = AV_CODEC_ID_XSUB,
     .init       = xsub_encoder_init,
     .encode_sub = xsub_encode,
+    .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
 };