1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

put_bits: make avpriv_align_put_bits() inline

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.
This commit is contained in:
Anton Khirnov 2020-10-26 13:36:06 +01:00
parent 886c601a70
commit 717503f716
16 changed files with 41 additions and 28 deletions

View 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);

View 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)

View 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 */

View 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);

View 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);

View 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 */

View 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);
}

View 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--)

View 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);

View 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

View 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 */

View 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);

View 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);

View File

@ -144,6 +144,8 @@
#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 */

View 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;
}

View 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;
}