[FFmpeg-cvslog] avcodec/mpegaudioenc: Don't pad one bit at a time
Andreas Rheinhardt
git at videolan.org
Mon Apr 14 00:18:32 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr 10 22:20:33 2025 +0200| [62e1abcf0dfd7a105c12f73ce965f1946312be2c] | committer: Andreas Rheinhardt
avcodec/mpegaudioenc: Don't pad one bit at a time
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62e1abcf0dfd7a105c12f73ce965f1946312be2c
---
libavcodec/mpegaudioenc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
index 9a6aae6f78..49255b7f29 100644
--- a/libavcodec/mpegaudioenc.c
+++ b/libavcodec/mpegaudioenc.c
@@ -743,9 +743,12 @@ static void encode_frame(MpegAudioContext *s,
av_assert1(put_bits_left(p) == padding);
+ /* flush */
+ flush_put_bits(p);
+
/* padding */
- for(i=0;i<padding;i++)
- put_bits(p, 1, 0);
+ if (put_bytes_left(p, 0))
+ memset(put_bits_ptr(p), 0, put_bytes_left(p, 0));
}
static int MPA_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
@@ -778,9 +781,6 @@ static int MPA_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
encode_frame(s, bit_alloc, padding);
- /* flush */
- flush_put_bits(&s->pb);
-
if (frame->pts != AV_NOPTS_VALUE)
avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, avctx->initial_padding);
More information about the ffmpeg-cvslog
mailing list