Mesa (master): vl/rbsp: add a check for emulation prevention three byte

Leo Liu leoliu at kemper.freedesktop.org
Wed Aug 10 13:54:13 UTC 2016


Module: Mesa
Branch: master
Commit: 6575ebdc4570b54ad98eaa2db19703a636acdc9d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=6575ebdc4570b54ad98eaa2db19703a636acdc9d

Author: Leo Liu <leo.liu at amd.com>
Date:   Mon Aug  8 16:01:23 2016 -0400

vl/rbsp: add a check for emulation prevention three byte

This is the case when the "00 00 03" is very close to the beginning of
nal unit header

v2: move the check to rbsp init

Signed-off-by: Leo Liu <leo.liu at amd.com>
Reviewed-by: Christian König <christian.koenig at amd.com>

---

 src/gallium/auxiliary/vl/vl_rbsp.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_rbsp.h b/src/gallium/auxiliary/vl/vl_rbsp.h
index 7867238..c8bebff 100644
--- a/src/gallium/auxiliary/vl/vl_rbsp.h
+++ b/src/gallium/auxiliary/vl/vl_rbsp.h
@@ -50,7 +50,8 @@ struct vl_rbsp {
  */
 static inline void vl_rbsp_init(struct vl_rbsp *rbsp, struct vl_vlc *nal, unsigned num_bits)
 {
-   unsigned bits_left = vl_vlc_bits_left(nal);
+   unsigned valid, bits_left = vl_vlc_bits_left(nal);
+   int i;
 
    /* copy the position */
    rbsp->nal = *nal;
@@ -62,10 +63,19 @@ static inline void vl_rbsp_init(struct vl_rbsp *rbsp, struct vl_vlc *nal, unsign
       if (vl_vlc_peekbits(nal, 24) == 0x000001 ||
           vl_vlc_peekbits(nal, 32) == 0x00000001) {
          vl_vlc_limit(&rbsp->nal, bits_left - vl_vlc_bits_left(nal));
-         return;
+         break;
       }
       vl_vlc_eatbits(nal, 8);
    }
+
+   valid = vl_vlc_valid_bits(&rbsp->nal);
+   /* search for the emulation prevention three byte */
+   for (i = 24; i <= valid; i += 8) {
+      if ((vl_vlc_peekbits(&rbsp->nal, i) & 0xffffff) == 0x3) {
+         vl_vlc_removebits(&rbsp->nal, i - 8, 8);
+         i += 8;
+      }
+   }
 }
 
 /**




More information about the mesa-commit mailing list