[x264-devel] commit: Revert part of r963 (Jason Garrett-Glaser )

git version control git at videolan.org
Sat Sep 6 08:11:45 CEST 2008


x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Fri Sep  5 23:14:23 2008 -0700| [3d2983da7bbdbcfa08b12252ab71b0bf19a9ce26] | committer: Jason Garrett-Glaser 

Revert part of r963
In some rare (but significant) cases, the optimized nal_encode algorithm gave incorrect results.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=3d2983da7bbdbcfa08b12252ab71b0bf19a9ce26
---

 common/common.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/common/common.c b/common/common.c
index 77e3a8c..96b6f2b 100644
--- a/common/common.c
+++ b/common/common.c
@@ -641,6 +641,7 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
     uint8_t *dst = p_data;
     uint8_t *src = nal->p_payload;
     uint8_t *end = &nal->p_payload[nal->i_payload];
+    int i_count = 0;
 
     /* FIXME this code doesn't check overflow */
 
@@ -656,12 +657,17 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
     /* nal header */
     *dst++ = ( 0x00 << 7 ) | ( nal->i_ref_idc << 5 ) | nal->i_type;
 
-    if( src < end ) *dst++ = *src++;
-    if( src < end ) *dst++ = *src++;
     while( src < end )
     {
-        if( src[0] <= 0x03 && !src[-2] && !src[-1] )
+        if( i_count == 2 && *src <= 0x03 )
+        {
             *dst++ = 0x03;
+            i_count = 0;
+        }
+        if( *src == 0 )
+            i_count++;
+        else
+            i_count = 0;
         *dst++ = *src++;
     }
     *pi_data = dst - (uint8_t*)p_data;



More information about the x264-devel mailing list