diff mbox series

[FFmpeg-devel,05/12] avcodec/vorbisenc, wmavoice: Use put_bits_left() where appropriate

Message ID 20210325154956.2405162-5-andreas.rheinhardt@gmail.com
State Accepted
Commit e48f18e2d5e492ef41139d55a3698044fc245eca
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
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/vorbisenc.c | 4 ++--
 libavcodec/wmavoice.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index f8a08f816f..080017e2bf 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -155,7 +155,7 @@  static inline int put_codeword(PutBitContext *pb, vorbis_enc_codebook *cb,
     av_assert2(entry >= 0);
     av_assert2(entry < cb->nentries);
     av_assert2(cb->lens[entry]);
-    if (pb->size_in_bits - put_bits_count(pb) < cb->lens[entry])
+    if (put_bits_left(pb) < cb->lens[entry])
         return AVERROR(EINVAL);
     put_bits(pb, cb->lens[entry], cb->codewords[entry]);
     return 0;
@@ -798,7 +798,7 @@  static int floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
     int coded[MAX_FLOOR_VALUES]; // first 2 values are unused
     int i, counter;
 
-    if (pb->size_in_bits - put_bits_count(pb) < 1 + 2 * ilog(range - 1))
+    if (put_bits_left(pb) < 1 + 2 * ilog(range - 1))
         return AVERROR(EINVAL);
     put_bits(pb, 1, 1); // non zero
     put_bits(pb, ilog(range - 1), posts[0]);
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index fbdb865360..e76807faa5 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -1881,7 +1881,7 @@  static void copy_bits(PutBitContext *pb,
     rmn_bits = rmn_bytes = get_bits_left(gb);
     if (rmn_bits < nbits)
         return;
-    if (nbits > pb->size_in_bits - put_bits_count(pb))
+    if (nbits > put_bits_left(pb))
         return;
     rmn_bits &= 7; rmn_bytes >>= 3;
     if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0)