Module: Mesa
Branch: staging/23.3
Commit: 142c333748e052b47bdfd2c224ae905bbd24d41c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=142c333748e052b47bdfd2c224ae905bbd24d41c

Author: David Rosca <[email protected]>
Date:   Sun Nov 19 11:27:29 2023 +0100

util/rbsp: Fill bits twice if reading more than 16 bits

vl_rbsp_fillbits may fill less than 32 bits if it removes emulation
prevention bytes, but will fill at least 16 bits. We need to call it
twice when reading more than 16 bits.

This fixes parsing H264 SPS packed header in va frontend when emulation
prevention bytes are at position where 32 bit values are read.

Cc: mesa-stable

Reviewed-by: Leo Liu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26276>
(cherry picked from commit 73d69ef1e6b013f923ec459c789976570baaf447)

---

 .pick_status.json  | 2 +-
 src/util/vl_rbsp.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index c1ee235878b..e0ad2657f6e 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -374,7 +374,7 @@
         "description": "util/rbsp: Fill bits twice if reading more than 16 
bits",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null,
         "notes": null
diff --git a/src/util/vl_rbsp.h b/src/util/vl_rbsp.h
index 0842b0f1490..82043fc8752 100644
--- a/src/util/vl_rbsp.h
+++ b/src/util/vl_rbsp.h
@@ -138,6 +138,8 @@ static inline unsigned vl_rbsp_u(struct vl_rbsp *rbsp, 
unsigned n)
       return 0;
 
    vl_rbsp_fillbits(rbsp);
+   if (n > 16)
+      vl_rbsp_fillbits(rbsp);
    return vl_vlc_get_uimsbf(&rbsp->nal, n);
 }
 

Reply via email to