Re: [Mesa-dev] [PATCH v2] vl/rbsp: add a check for emulation prevention three byte

2016-08-09 Thread Christian König

Am 09.08.2016 um 17:18 schrieb Leo Liu:

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 


Reviewed-by: Christian König 


---
  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) == 0x01 ||
vl_vlc_peekbits(nal, 32) == 0x0001) {
   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) & 0xff) == 0x3) {
+ vl_vlc_removebits(&rbsp->nal, i - 8, 8);
+ i += 8;
+  }
+   }
  }
  
  /**



___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] vl/rbsp: add a check for emulation prevention three byte

2016-08-09 Thread Leo Liu
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 
---
 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) == 0x01 ||
   vl_vlc_peekbits(nal, 32) == 0x0001) {
  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) & 0xff) == 0x3) {
+ vl_vlc_removebits(&rbsp->nal, i - 8, 8);
+ i += 8;
+  }
+   }
 }
 
 /**
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] vl/rbsp: add a check for emulation prevention three byte

2016-08-09 Thread Christian König

Am 09.08.2016 um 15:56 schrieb Leo Liu:

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 
---
  src/gallium/auxiliary/vl/vl_rbsp.h | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/src/gallium/auxiliary/vl/vl_rbsp.h 
b/src/gallium/auxiliary/vl/vl_rbsp.h
index 7867238..c175e23 100644
--- a/src/gallium/auxiliary/vl/vl_rbsp.h
+++ b/src/gallium/auxiliary/vl/vl_rbsp.h
@@ -61,7 +61,18 @@ static inline void vl_rbsp_init(struct vl_rbsp *rbsp, struct 
vl_vlc *nal, unsign
 while (vl_vlc_search_byte(nal, num_bits, 0x00)) {
if (vl_vlc_peekbits(nal, 24) == 0x01 ||
vl_vlc_peekbits(nal, 32) == 0x0001) {
+ unsigned valid;
+ int i;
+
   vl_vlc_limit(&rbsp->nal, bits_left - vl_vlc_bits_left(nal));
+ 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) & 0xff) == 0x3) {
+   vl_vlc_removebits(&rbsp->nal, i - 8, 8);
+   i += 8;
+}
+ }


Mhm, I think that isn't 100% correct either.

We return inside the loop only when we find the next NAL unit after the 
current one, but if this is the last one that isn't the case.



   return;


I think that just replacing thing return with a break and moving the 
code after the while should do the trick.


Regards,
Christian.


}
vl_vlc_eatbits(nal, 8);




___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] vl/rbsp: add a check for emulation prevention three byte

2016-08-09 Thread Leo Liu
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 
---
 src/gallium/auxiliary/vl/vl_rbsp.h | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/gallium/auxiliary/vl/vl_rbsp.h 
b/src/gallium/auxiliary/vl/vl_rbsp.h
index 7867238..c175e23 100644
--- a/src/gallium/auxiliary/vl/vl_rbsp.h
+++ b/src/gallium/auxiliary/vl/vl_rbsp.h
@@ -61,7 +61,18 @@ static inline void vl_rbsp_init(struct vl_rbsp *rbsp, struct 
vl_vlc *nal, unsign
while (vl_vlc_search_byte(nal, num_bits, 0x00)) {
   if (vl_vlc_peekbits(nal, 24) == 0x01 ||
   vl_vlc_peekbits(nal, 32) == 0x0001) {
+ unsigned valid;
+ int i;
+
  vl_vlc_limit(&rbsp->nal, bits_left - vl_vlc_bits_left(nal));
+ 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) & 0xff) == 0x3) {
+   vl_vlc_removebits(&rbsp->nal, i - 8, 8);
+   i += 8;
+}
+ }
  return;
   }
   vl_vlc_eatbits(nal, 8);
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev