hi
I have been using this function in my code to find H.264 NAL units.. I am just
wondering if there might be a small bug in the code, where it will return the
wrong pointer in some cases?
looking at the middle loop, which increments by 32-bit, and the case
where p[3] is 0:
if( p[3] == 0 ) {
if( p[2] == 0 && p[4] == 1 )
return p+1;
if( p[4] == 0 && p[5] == 1 )
return p+2;
}
offset: 0 1 2 3 4 5 6
content: x x 0 0 1 x x
^
|
|
`--------- returned pointer
same with p[3-5] == {0,0,1}, it returns &p[2]
the suggested patch below fixes this, but I am not sure if this
is the intention of the function, so please verify :)
diff --git a/libavformat/avc.c b/libavformat/avc.c
index 578e7d0..56c680e 100644
--- a/libavformat/avc.c
+++ b/libavformat/avc.c
@@ -45,9 +45,9 @@ const uint8_t *ff_avc_find_startcode(const uint8_t *p, const
uint8_t *end)
}
if( p[3] == 0 ) {
if( p[2] == 0 && p[4] == 1 )
- return p+1;
- if( p[4] == 0 && p[5] == 1 )
return p+2;
+ if( p[4] == 0 && p[5] == 1 )
+ return p+3;
}
}
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user