[x264-devel] commit: Faster NAL unit encoding and remove unused nal_decode ( Jason Garrett-Glaser )
git version control
git at videolan.org
Fri Sep 5 22:13:24 CEST 2008
x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Thu Sep 4 00:43:54 2008 -0700| [d21665d886638b08862e41bc68ea62472a646ca1] | committer: Jason Garrett-Glaser
Faster NAL unit encoding and remove unused nal_decode
Small speedup at very high bitrates
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=d21665d886638b08862e41bc68ea62472a646ca1
---
common/common.c | 48 +++---------------------------------------------
1 files changed, 3 insertions(+), 45 deletions(-)
diff --git a/common/common.c b/common/common.c
index f628f8d..77e3a8c 100644
--- a/common/common.c
+++ b/common/common.c
@@ -642,8 +642,6 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
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 */
if( b_annexeb )
@@ -658,21 +656,12 @@ 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( i_count == 2 && *src <= 0x03 )
- {
+ if( src[0] <= 0x03 && !src[-2] && !src[-1] )
*dst++ = 0x03;
- i_count = 0;
- }
- if( *src == 0 )
- {
- i_count++;
- }
- else
- {
- i_count = 0;
- }
*dst++ = *src++;
}
*pi_data = dst - (uint8_t*)p_data;
@@ -680,37 +669,6 @@ int x264_nal_encode( void *p_data, int *pi_data, int b_annexeb, x264_nal_t *nal
return *pi_data;
}
-/****************************************************************************
- * x264_nal_decode:
- ****************************************************************************/
-int x264_nal_decode( x264_nal_t *nal, void *p_data, int i_data )
-{
- uint8_t *src = p_data;
- uint8_t *end = &src[i_data];
- uint8_t *dst = nal->p_payload;
-
- nal->i_type = src[0]&0x1f;
- nal->i_ref_idc = (src[0] >> 5)&0x03;
-
- src++;
-
- while( src < end )
- {
- if( src < end - 3 && src[0] == 0x00 && src[1] == 0x00 && src[2] == 0x03 )
- {
- *dst++ = 0x00;
- *dst++ = 0x00;
-
- src += 3;
- continue;
- }
- *dst++ = *src++;
- }
-
- nal->i_payload = dst - (uint8_t*)p_data;
- return 0;
-}
-
/****************************************************************************
More information about the x264-devel
mailing list