diff mbox series

[FFmpeg-devel,03/12] avcodec/mlpenc: Avoid redundant temporary PutBitContext

Message ID 20210325154956.2405162-3-andreas.rheinhardt@gmail.com
State Accepted
Commit 3183eda0fa4861e88c02150b887e2945839a58a1
Headers show
Series [FFmpeg-devel,01/12] avcodec/vorbisenc: Remove always-false check | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 25, 2021, 3:49 p.m. UTC
We are already word-aligned here, so one can just as well flush the main
PutBitContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mlpenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c
index 9782cb8261..40db76f350 100644
--- a/libavcodec/mlpenc.c
+++ b/libavcodec/mlpenc.c
@@ -1067,7 +1067,7 @@  static uint8_t *write_substrs(MLPEncodeContext *ctx, uint8_t *buf, int buf_size,
         RestartHeader  *rh = &ctx->restart_header [substr];
         int substr_restart_frame = restart_frame;
         uint8_t parity, checksum;
-        PutBitContext pb, tmpb;
+        PutBitContext pb;
         int params_changed;
 
         ctx->cur_restart_header = rh;
@@ -1117,9 +1117,9 @@  static uint8_t *write_substrs(MLPEncodeContext *ctx, uint8_t *buf, int buf_size,
             put_bits(&pb, 32, END_OF_STREAM);
         }
 
-        /* Data must be flushed for the checksum and parity to be correct. */
-        tmpb = pb;
-        flush_put_bits(&tmpb);
+        /* Data must be flushed for the checksum and parity to be correct;
+         * notice that we already are word-aligned here. */
+        flush_put_bits(&pb);
 
         parity   = ff_mlp_calculate_parity(buf, put_bits_count(&pb) >> 3) ^ 0xa9;
         checksum = ff_mlp_checksum8       (buf, put_bits_count(&pb) >> 3);