summaryrefslogtreecommitdiff
path: root/libavformat/latmenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-26 13:16:38 +0100
committerAnton Khirnov <anton@khirnov.net>2020-10-28 13:53:23 +0100
commit886c601a7064333708f2fdbaf970eb783b5a2008 (patch)
tree207dd80c63d653068e57d71b1449ecd80d5c8897 /libavformat/latmenc.c
parent2068ad5914e4b6ba1d9c57e093a0d879d7afc7cf (diff)
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.
Diffstat (limited to 'libavformat/latmenc.c')
-rw-r--r--libavformat/latmenc.c19
1 files 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);