[FFmpeg-devel] [PATCH 1/3] vulkan/common: Fix off-by-one error in flush_put_bits
IndecisiveTurtle
geoster3d at gmail.com
Wed Nov 27 21:18:05 EET 2024
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.
---
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;
--
2.47.1
More information about the ffmpeg-devel
mailing list