From ac272886b1edd7e37b1147dca66fa9462f24a5d7 Mon Sep 17 00:00:00 2001 From: jeffqjiangNew <142832361+jeffqjiangNew@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:02:10 -0400 Subject: [PATCH] * rocDecode/AV1: Fixed a bug in the calculation of the floor of the base 2 logarithm. (#367) --- src/parser/av1_parser.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser/av1_parser.h b/src/parser/av1_parser.h index ba4b34dae0..a454622a95 100644 --- a/src/parser/av1_parser.h +++ b/src/parser/av1_parser.h @@ -430,12 +430,13 @@ protected: * \return the location of the most significant bit in x */ inline uint32_t FloorLog2(uint32_t x) { + uint32_t saved_x = x; uint32_t s = 0; while (x != 0) { x = x >> 1; s++; } - return x ? s - 1 : 0; + return saved_x ? s - 1 : 0; } /*! \brief Function to read variable length unsigned n-bit number appearing directly in the bitstream. 4.10.3. uvlc().