]> git.sesse.net Git - ffmpeg/commitdiff
put_bits: make avpriv_align_put_bits() inline
authorAnton Khirnov <anton@khirnov.net>
Mon, 26 Oct 2020 12:36:06 +0000 (13:36 +0100)
committerAnton Khirnov <anton@khirnov.net>
Wed, 28 Oct 2020 12:53:23 +0000 (13:53 +0100)
This function is so extremely simple that it is preferable to make it
inline rather than deal with all the complications arising from it being
an exported symbol.

Keep avpriv_align_put_bits() around until the next major bump to
preserve ABI compatibility.

16 files changed:
libavcodec/aacenc.c
libavcodec/bitstream.c
libavcodec/flvenc.c
libavcodec/h261enc.c
libavcodec/ituh263enc.c
libavcodec/jpeglsenc.c
libavcodec/mpeg12enc.c
libavcodec/mpeg4audio.h
libavcodec/msmpeg4enc.c
libavcodec/put_bits.h
libavcodec/rv10enc.c
libavcodec/svq1enc.c
libavcodec/vc2enc.c
libavcodec/version.h
libavcodec/wmaenc.c
libavcodec/xsubenc.c

index e65b76cd74ab3cf86f23de0528cce115e91350f3..e477089f5ce63500156e94f13054a45089a06744 100644 (file)
@@ -83,7 +83,7 @@ static void put_pce(PutBitContext *pb, AVCodecContext *avctx)
         }
     }
 
-    avpriv_align_put_bits(pb);
+    align_put_bits(pb);
     put_bits(pb, 8, strlen(aux_data));
     avpriv_put_string(pb, aux_data, 0);
 }
@@ -522,7 +522,7 @@ static void put_bitstream_info(AACEncContext *s, const char *name)
         put_bits(&s->pb, 8, namelen - 14);
     put_bits(&s->pb, 4, 0); //extension type - filler
     padbits = -put_bits_count(&s->pb) & 7;
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     for (i = 0; i < namelen - 2; i++)
         put_bits(&s->pb, 8, name[i]);
     put_bits(&s->pb, 12 - padbits, 0);
index a908c1098042cf5cd3f04d30a8d99f8bfc70c72d..8be8a678d2651d459391ba5899b187f903c77f3b 100644 (file)
@@ -45,10 +45,12 @@ const uint8_t ff_log2_run[41]={
 24,
 };
 
+#if FF_API_AVPRIV_PUT_BITS
 void avpriv_align_put_bits(PutBitContext *s)
 {
-    put_bits(s, s->bit_left & 7, 0);
+    align_put_bits(s);
 }
+#endif
 
 void avpriv_put_string(PutBitContext *pb, const char *string,
                        int terminate_string)
index c1227277b3dd1f8496c7f48f4a898db40bf3112b..b85e4667c451d1cda9b10fbb1c8f788389670f76 100644 (file)
@@ -28,7 +28,7 @@ void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number)
 {
     int format;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     put_bits(&s->pb, 17, 1);
     /* 0: H.263 escape codes 1: 11-bit escape codes */
index 196c37b54346804bfaa886f1dc459f090bfec7a8..909bc23bb4bec6eb671c47f35c8a1c6a868a9603 100644 (file)
@@ -55,7 +55,7 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number)
     H261Context *h = (H261Context *)s;
     int format, temp_ref;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     /* Update the pointer to last GOB */
     s->ptr_lastgob = put_bits_ptr(&s->pb);
index ee09f2974c207c09bda062c9d15f3c5fa2e4456b..b1b78218a58fa73dcce3b0f12dd89c82c25ed6ca 100644 (file)
@@ -124,7 +124,7 @@ void ff_h263_encode_picture_header(MpegEncContext * s, int picture_number)
     coded_frame_rate= 1800000;
     coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     /* Update the pointer to last GOB */
     s->ptr_lastgob = put_bits_ptr(&s->pb);
index 0725457a94ce5a5a64423dba019961a53b0f9049..10a3bd0f619a250ffb38dc1a4c92c6c2bf08ce21 100644 (file)
@@ -403,7 +403,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             put_bits(&pb, 8, v);
         }
     }
-    avpriv_align_put_bits(&pb);
+    align_put_bits(&pb);
     av_freep(&buf2);
 
     /* End of image */
index f246427eeb320c02838708da3a24292f707a8c4b..46c3424de9b89d385fec2c915a812934599e6e16 100644 (file)
@@ -233,7 +233,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 static void put_header(MpegEncContext *s, int header)
 {
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     put_bits(&s->pb, 16, header >> 16);
     put_sbits(&s->pb, 16, header);
 }
index c4cdc1508ca6ce6029ee1c2ce71cff2aabe49b54..b274e92b628fd03b4a1e318b67cd3637b79a333f 100644 (file)
@@ -165,7 +165,7 @@ static inline int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb)
         ff_pce_copy_bits(pb, gb, 16);
     if (bits)
         ff_pce_copy_bits(pb, gb, bits);
-    avpriv_align_put_bits(pb);
+    align_put_bits(pb);
     align_get_bits(gb);
     comment_size = ff_pce_copy_bits(pb, gb, 8);
     for (; comment_size > 0; comment_size--)
index 144468b24f16df8650be3dd91207ab26067e16a6..2c61735d9d2b7643a2c47a0f24319f83477cadc6 100644 (file)
@@ -225,7 +225,7 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
 {
     find_best_tables(s);
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     put_bits(&s->pb, 2, s->pict_type - 1);
 
     put_bits(&s->pb, 5, s->qscale);
index 3ba9549948ee09858a38b078cd6690d8e1ec94dc..d7eaa1792e7861a304ff3d1f961b6da43f2e784a 100644 (file)
@@ -33,6 +33,8 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avassert.h"
 
+#include "version.h"
+
 #if ARCH_X86_64
 // TODO: Benchmark and optionally enable on other 64-bit architectures.
 typedef uint64_t BitBuf;
@@ -145,15 +147,14 @@ static inline void flush_put_bits_le(PutBitContext *s)
     s->bit_buf  = 0;
 }
 
+#if FF_API_AVPRIV_PUT_BITS
+void avpriv_align_put_bits(PutBitContext *s);
+#endif
+
 #ifdef BITSTREAM_WRITER_LE
-#define avpriv_align_put_bits align_put_bits_unsupported_here
 #define avpriv_put_string ff_put_string_unsupported_here
 #define avpriv_copy_bits avpriv_copy_bits_unsupported_here
 #else
-/**
- * Pad the bitstream with zeros up to the next byte boundary.
- */
-void avpriv_align_put_bits(PutBitContext *s);
 
 /**
  * Put the string string in the bitstream.
@@ -385,6 +386,14 @@ static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
     s->size_in_bits = 8*size;
 }
 
+/**
+ * Pad the bitstream with zeros up to the next byte boundary.
+ */
+static inline void align_put_bits(PutBitContext *s)
+{
+    put_bits(s, s->bit_left & 7, 0);
+}
+
 #undef AV_WBBUF
 #undef AV_WLBUF
 
index 55538148f28b490f2da3e70eb47ac660a46ce350..42316836c5eb5d1cf1becef7e374f9f71d9e5749 100644 (file)
@@ -33,7 +33,7 @@ int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number)
 {
     int full_frame= 0;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     put_bits(&s->pb, 1, 1);     /* marker */
 
index 4bf9eb9a0f24522beebe7a87b2aa2b7eec4af6c4..9e249aefe4b1235f75ac5e34fe2a76b9f3ced42f 100644 (file)
@@ -647,7 +647,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
         }
     }
 
-    // avpriv_align_put_bits(&s->pb);
+    // align_put_bits(&s->pb);
     while (put_bits_count(&s->pb) & 31)
         put_bits(&s->pb, 1, 0);
 
index 2efb0f70ade228f057ac75be7a19cef3759428dc..cd25884a63e33dac976c3aa9f16f8653b0015c74 100644 (file)
@@ -229,7 +229,7 @@ static void encode_parse_info(VC2EncContext *s, enum DiracParseCodes pcode)
 {
     uint32_t cur_pos, dist;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     cur_pos = put_bits_count(&s->pb) >> 3;
 
@@ -399,7 +399,7 @@ static void encode_source_params(VC2EncContext *s)
 /* VC-2 11 - sequence_header() */
 static void encode_seq_header(VC2EncContext *s)
 {
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     encode_parse_params(s);
     put_vc2_ue_uint(&s->pb, s->base_vf);
     encode_source_params(s);
@@ -409,7 +409,7 @@ static void encode_seq_header(VC2EncContext *s)
 /* VC-2 12.1 - picture_header() */
 static void encode_picture_header(VC2EncContext *s)
 {
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     put_bits32(&s->pb, s->picture_number++);
 }
 
@@ -509,15 +509,15 @@ static void encode_transform_params(VC2EncContext *s)
 static void encode_wavelet_transform(VC2EncContext *s)
 {
     encode_transform_params(s);
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 }
 
 /* VC-2 12 - picture_parse() */
 static void encode_picture_start(VC2EncContext *s)
 {
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     encode_picture_header(s);
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
     encode_wavelet_transform(s);
 }
 
@@ -753,7 +753,7 @@ static int encode_hq_slice(AVCodecContext *avctx, void *arg)
                                quants[level][orientation]);
             }
         }
-        avpriv_align_put_bits(pb);
+        align_put_bits(pb);
         bytes_len = (put_bits_count(pb) >> 3) - bytes_start - 1;
         if (p == 2) {
             int len_diff = slice_bytes_max - (put_bits_count(pb) >> 3);
index 02ffa95749ef08e463468664d16780a1e3a78e2b..78c4dd64ee8b63971e0b40281f5fa3d831a3b508 100644 (file)
 #ifndef FF_API_UNUSED_CODEC_CAPS
 #define FF_API_UNUSED_CODEC_CAPS   (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
-
+#ifndef FF_API_AVPRIV_PUT_BITS
+#define FF_API_AVPRIV_PUT_BITS     (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
index 091bc2ac3b91b1e05cb0c8aae0633525b86ea144..6a7e23d016c22ae5994e17d9ccd5f5ab18aede56 100644 (file)
@@ -343,7 +343,7 @@ static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
                          s->coef_vlcs[tindex]->huffcodes[1]);
         }
         if (s->version == 1 && s->avctx->channels >= 2)
-            avpriv_align_put_bits(&s->pb);
+            align_put_bits(&s->pb);
     }
     return 0;
 }
@@ -358,7 +358,7 @@ static int encode_frame(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
     else if (encode_block(s, src_coefs, total_gain) < 0)
         return INT_MAX;
 
-    avpriv_align_put_bits(&s->pb);
+    align_put_bits(&s->pb);
 
     return put_bits_count(&s->pb) / 8 - s->avctx->block_align;
 }
index 349c1bca3c6ee1d2595cb6dfd101332520a54bdb..58be5e6deb36e135d88f2c7ad81a94f975de67fe 100644 (file)
@@ -90,7 +90,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;
     }