]> git.sesse.net Git - ffmpeg/commitdiff
lavf/latmenc: use a local simplified copy of avpriv_copy_bits()
authorAnton Khirnov <anton@khirnov.net>
Mon, 26 Oct 2020 12:16:38 +0000 (13:16 +0100)
committerAnton Khirnov <anton@khirnov.net>
Wed, 28 Oct 2020 12:53:23 +0000 (13:53 +0100)
This is the only place in lavf where avpriv_copy_bits() is used, so this
allows us to make avpriv_copy_bits() lavc-local.

libavformat/latmenc.c

index 684483bc71bee0a133bc3a82370510e33f632c10..701c3932c4c3286ba445212da326f6e0421cc279 100644 (file)
@@ -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);