[FFmpeg-devel] [PATCH] avcodec, avfilter, avformat: Remove redundant avpriv_align_put_bits
Paul B Mahol
onemda at gmail.com
Sat Aug 1 12:28:18 EEST 2020
LGTM. I thought flush_put_bits flushes more bits depending on cache size,
but obviously that assumption is incorrect.
On 7/30/20, Andreas Rheinhardt <andreas.rheinhardt at gmail.com> wrote:
> flush_put_bits() already fills the bitstream with zeroes, so it is
> unnecessary to align the bitstream before.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> avpriv_align_put_bits() seems to be a function that should not exist as
> an avpriv function and instead be replaced by an inline function like
> the others or replaced by flush_put_bits().
>
> Notice that even after this patch there are still users of
> avpriv_align_put_bits() outside of libavcodec, because an inline
> function in mpeg4audio.h uses it.
>
> libavcodec/hevc_ps_enc.c | 3 +--
> libavcodec/mpegvideo_enc.c | 1 -
> libavcodec/vc2enc.c | 1 -
> libavcodec/xsubenc.c | 1 -
> libavfilter/vf_signature.c | 1 -
> libavformat/latmenc.c | 1 -
> 6 files changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/libavcodec/hevc_ps_enc.c b/libavcodec/hevc_ps_enc.c
> index 78a73a5c0a..5449f81c82 100644
> --- a/libavcodec/hevc_ps_enc.c
> +++ b/libavcodec/hevc_ps_enc.c
> @@ -113,10 +113,9 @@ int ff_hevc_encode_nal_vps(HEVCVPS *vps, unsigned int
> id,
> put_bits(&pb, 1, 0); // extension flag
>
> put_bits(&pb, 1, 1); // stop bit
> - avpriv_align_put_bits(&pb);
> + flush_put_bits(&pb);
>
> data_size = put_bits_count(&pb) / 8;
> - flush_put_bits(&pb);
>
> return data_size;
> }
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index 21c30a9f8a..09697d89c8 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -2818,7 +2818,6 @@ static void write_slice_end(MpegEncContext *s){
> ff_mjpeg_encode_stuffing(s);
> }
>
> - avpriv_align_put_bits(&s->pb);
> flush_put_bits(&s->pb);
>
> if ((s->avctx->flags & AV_CODEC_FLAG_PASS1) && !s->partitioned_frame)
> diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c
> index ba5a03e4ec..2efb0f70ad 100644
> --- a/libavcodec/vc2enc.c
> +++ b/libavcodec/vc2enc.c
> @@ -780,7 +780,6 @@ static int encode_slices(VC2EncContext *s)
> int slice_x, slice_y, skip = 0;
> SliceArgs *enc_args = s->slice_args;
>
> - avpriv_align_put_bits(&s->pb);
> flush_put_bits(&s->pb);
> buf = put_bits_ptr(&s->pb);
>
> diff --git a/libavcodec/xsubenc.c b/libavcodec/xsubenc.c
> index 4d58e0f3b5..349c1bca3c 100644
> --- a/libavcodec/xsubenc.c
> +++ b/libavcodec/xsubenc.c
> @@ -206,7 +206,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
> // Enforce total height to be a multiple of 2
> if (h->rects[0]->h & 1) {
> put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR);
> - avpriv_align_put_bits(&pb);
> }
>
> flush_put_bits(&pb);
> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
> index d07b213f31..5ea55d5247 100644
> --- a/libavfilter/vf_signature.c
> +++ b/libavfilter/vf_signature.c
> @@ -559,7 +559,6 @@ static int binary_export(AVFilterContext *ctx,
> StreamContext *sc, const char* fi
> }
> }
>
> - avpriv_align_put_bits(&buf);
> flush_put_bits(&buf);
> fwrite(buffer, 1, put_bits_count(&buf)/8, f);
> fclose(f);
> diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c
> index 72b7f72f22..5458ce2596 100644
> --- a/libavformat/latmenc.c
> +++ b/libavformat/latmenc.c
> @@ -211,7 +211,6 @@ static int latm_write_packet(AVFormatContext *s,
> AVPacket *pkt)
> } else
> avpriv_copy_bits(&bs, pkt->data, 8*pkt->size);
>
> - avpriv_align_put_bits(&bs);
> flush_put_bits(&bs);
>
> len = put_bits_count(&bs) >> 3;
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
More information about the ffmpeg-devel
mailing list