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

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/vulkan/common.comp+2−2
@@ -141,12 +141,12 @@ uint32_t flush_put_bits(inout PutBitContext pb) · 140 unmodified lines
141 pb.bit_buf <<= pb.bit_left;141 pb.bit_buf <<= pb.bit_left;
142 142
143 if (pb.bit_left < BUF_BITS) {143 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;
145 145
146 u8buf bs = u8buf(pb.buf);146 u8buf bs = u8buf(pb.buf);
147 for (int i = 0; i < to_write; i++)147 for (int i = 0; i < to_write; i++)
148 bs[i].v = BYTE_EXTRACT(pb.bit_buf, BUF_BYTES - uint8_t(1) - i);148 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;
150 }150 }
151 151
152 pb.bit_left = BUF_BITS;152 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