History

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.

IndecisiveTurtle committed 1 year ago

Commit f794ed41 parent 4e1a9111 file · +2 −2Browse files

Unified · Split

libavcodec/vulkan/common.comp+2−2
@@ -141,12 +141,12 @@ uint32_t flush_put_bits(inout PutBitContext pb) · 140 unmodified lines
141141 pb.bit_buf <<= pb.bit_left;
142142
143143 if (pb.bit_left < BUF_BITS) {
144− uint to_write = ((BUF_BITS - pb.bit_left) >> 3) + 1;
144+ uint to_write = ((BUF_BITS - pb.bit_left - 1) >> 3) + 1;
145145
146146 u8buf bs = u8buf(pb.buf);
147147 for (int i = 0; i < to_write; i++)
148148 bs[i].v = BYTE_EXTRACT(pb.bit_buf, BUF_BYTES - uint8_t(1) - i);
149− pb.buf = uint64_t(bs) + BUF_BYTES;
149+ pb.buf = uint64_t(bs) + to_write;
150150 }
151151
152152 pb.bit_left = BUF_BITS;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t