[FFmpeg-cvslog] vulkan/common: Fix off-by-one error in flush_put_bits
IndecisiveTurtle
git at videolan.org
Thu Nov 28 03:03:17 EET 2024
ffmpeg | branch: master | IndecisiveTurtle <geoster3d at gmail.com> | Wed Nov 27 21:18:05 2024 +0200| [f794ed48c09cfb31611cb4fe4bf7df32339f12eb] | committer: Lynne
vulkan/common: Fix off-by-one error in flush_put_bits
If caller wrote a divisible by eight number of bits it would write an extra byte.
Also increment by to_write instead of BUF_BYTES which overly pads the bitstream.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f794ed48c09cfb31611cb4fe4bf7df32339f12eb
---
libavcodec/vulkan/common.comp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/vulkan/common.comp b/libavcodec/vulkan/common.comp
index a28701584e..17c18934e6 100644
--- a/libavcodec/vulkan/common.comp
+++ b/libavcodec/vulkan/common.comp
@@ -141,12 +141,12 @@ uint32_t flush_put_bits(inout PutBitContext pb)
pb.bit_buf <<= pb.bit_left;
if (pb.bit_left < BUF_BITS) {
- uint to_write = ((BUF_BITS - pb.bit_left) >> 3) + 1;
+ uint to_write = ((BUF_BITS - pb.bit_left - 1) >> 3) + 1;
u8buf bs = u8buf(pb.buf);
for (int i = 0; i < to_write; i++)
bs[i].v = BYTE_EXTRACT(pb.bit_buf, BUF_BYTES - uint8_t(1) - i);
- pb.buf = uint64_t(bs) + BUF_BYTES;
+ pb.buf = uint64_t(bs) + to_write;
}
pb.bit_left = BUF_BITS;
More information about the ffmpeg-cvslog
mailing list