This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 4675271e7a8cb672e68a340d566310c226a4d680 Author: Lynne <[email protected]> AuthorDate: Tue May 26 02:26:20 2026 +0900 Commit: Lynne <[email protected]> CommitDate: Tue May 26 17:46:59 2026 +0900 vulkan/rangecoder: fix encoding issue when -1 != 0xFF This was an oversight while microoptimizing. The outstanding_byte can reach 0xFF in some situations, which was causing errors when encoding, particularly with 32-bit floats. Sponsored-by: Sovereign Tech Fund --- libavcodec/vulkan/rangecoder.glsl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/vulkan/rangecoder.glsl b/libavcodec/vulkan/rangecoder.glsl index 17741793f0..cbb346da8d 100644 --- a/libavcodec/vulkan/rangecoder.glsl +++ b/libavcodec/vulkan/rangecoder.glsl @@ -46,7 +46,9 @@ struct RangeCoder { uint low; uint range; uint16_t outstanding_count; - uint8_t outstanding_byte; + /* note: -1 is the value at init, and it has a different meaning from 0xFF, + * so we have to handle both, meaning we have to keep this signed */ + int16_t outstanding_byte; }; shared RangeCoder rc; @@ -61,29 +63,29 @@ void rac_init(uint bs_start, uint bs_len) rc.low = 0; rc.range = 0xFF00; rc.outstanding_count = uint16_t(0); - rc.outstanding_byte = uint8_t(0xFF); + rc.outstanding_byte = int16_t(-1); } #ifdef FULL_RENORM -/* Full renorm version that can handle outstanding_byte == 0xFF */ +/* Full renorm version that can handle the initial outstanding_byte < 0 */ void renorm_encoder(void) { - if (rc.outstanding_byte == 0xFF) { - rc.outstanding_byte = uint8_t(rc.low >> 8); + if (rc.outstanding_byte < int16_t(0)) { + rc.outstanding_byte = int16_t(rc.low >> 8); } else if (rc.low <= 0xFF00) { - slice_data[rc.bs_off++].v = rc.outstanding_byte; + slice_data[rc.bs_off++].v = uint8_t(rc.outstanding_byte); uint16_t cnt = rc.outstanding_count; for (; cnt > 0; cnt--) slice_data[rc.bs_off++].v = uint8_t(0xFF); rc.outstanding_count = uint16_t(0); - rc.outstanding_byte = uint8_t(rc.low >> 8); + rc.outstanding_byte = int16_t(rc.low >> 8); } else if (rc.low >= 0x10000) { - slice_data[rc.bs_off++].v = rc.outstanding_byte + uint8_t(1); + slice_data[rc.bs_off++].v = uint8_t(rc.outstanding_byte) + uint8_t(1); uint16_t cnt = rc.outstanding_count; for (; cnt > 0; cnt--) slice_data[rc.bs_off++].v = uint8_t(0x00); rc.outstanding_count = uint16_t(0); - rc.outstanding_byte = uint8_t(bitfieldExtract(rc.low, 8, 8)); + rc.outstanding_byte = int16_t(bitfieldExtract(rc.low, 8, 8)); } else { rc.outstanding_count++; } @@ -108,10 +110,10 @@ void renorm_encoder(void) return; } - uint8_t outstanding_byte = rc.outstanding_byte; + uint8_t outstanding_byte = uint8_t(rc.outstanding_byte); rc.outstanding_count = uint16_t(0); - rc.outstanding_byte = uint8_t(low >> 8); + rc.outstanding_byte = int16_t(low >> 8); uint8_t obs = uint8_t(low > 0xFF00); uint8_t fill = obs - uint8_t(1); /* unsigned underflow */ _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
