[FFmpeg-cvslog] lavf/latmenc: use a local simplified copy of avpriv_copy_bits()

Anton Khirnov git at videolan.org
Wed Oct 28 15:26:24 EET 2020


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Oct 26 13:16:38 2020 +0100| [886c601a7064333708f2fdbaf970eb783b5a2008] | committer: Anton Khirnov

lavf/latmenc: use a local simplified copy of avpriv_copy_bits()

This is the only place in lavf where avpriv_copy_bits() is used, so this
allows us to make avpriv_copy_bits() lavc-local.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=886c601a7064333708f2fdbaf970eb783b5a2008
---

 libavformat/latmenc.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
index 684483bc71..701c3932c4 100644
--- a/libavformat/latmenc.c
+++ b/libavformat/latmenc.c
@@ -101,6 +101,17 @@ static int latm_write_header(AVFormatContext *s)
     return 0;
 }
 
+static void copy_bits(PutBitContext *pb, const uint8_t *src, int length)
+{
+    int words = length >> 4;
+    int bits  = length & 15;
+    int i;
+    for (i = 0; i < words; i++)
+        put_bits(pb, 16, AV_RB16(src + 2 * i));
+    if (bits)
+        put_bits(pb, bits, AV_RB16(src + 2 * words) >> (16 - bits));
+}
+
 static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
 {
     LATMContext *ctx = s->priv_data;
@@ -121,11 +132,11 @@ static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs)
         /* AudioSpecificConfig */
         if (ctx->object_type == AOT_ALS) {
             header_size = (par->extradata_size - (ctx->off >> 3)) * 8;
-            avpriv_copy_bits(bs, &par->extradata[ctx->off >> 3], header_size);
+            copy_bits(bs, &par->extradata[ctx->off >> 3], header_size);
         } else {
             // + 3 assumes not scalable and dependsOnCoreCoder == 0,
             // see decode_ga_specific_config in libavcodec/aacdec.c
-            avpriv_copy_bits(bs, par->extradata, ctx->off + 3);
+            copy_bits(bs, par->extradata, ctx->off + 3);
 
             if (!ctx->channel_conf) {
                 GetBitContext gb;
@@ -207,9 +218,9 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt)
         // This allows us to remux our FATE AAC samples into latm
         // files that are still playable with minimal effort.
         put_bits(&bs, 8, pkt->data[0] & 0xfe);
-        avpriv_copy_bits(&bs, pkt->data + 1, 8*pkt->size - 8);
+        copy_bits(&bs, pkt->data + 1, 8*pkt->size - 8);
     } else
-        avpriv_copy_bits(&bs, pkt->data, 8*pkt->size);
+        copy_bits(&bs, pkt->data, 8*pkt->size);
 
     flush_put_bits(&bs);
 



More information about the ffmpeg-cvslog mailing list