[FFmpeg-devel] [PATCH] fixes and optimization for ff_find_start_code()
Thu Feb 26 15:56:48 CET 2009
The following patch fixes bugs in ff_find_start_code() and
(1) In certain cases, ff_find_start_code() could report false
positives, depending on the contents of start_code when the
the function gets called.
Cause: The for-loop operates on start_code without clearing
it. It simply shiftes the contents and checks if a
start code has been found- thus, shifting the old
Example: start_code = 0x00000001 at call time
The second for-loop iteration will always return
a false positive.
Looking through the ffmpeg code, this is not always taken into
account. Sometimes ff_find_start_code() gets called repeatedly
with old contents which could trigger a false positive randomly.
(2) ff_find_start_code() always changes start_code without providing
a way to know if this is old contents, a found start_code or some
This patch fixes (1) and (2) and greatly simplifies the function
along the way. The new behaviour won't cause any regressions and has
been tested extensively:
(1) start_code is still always modified
(2) start_code contains either a valid start code or 0xFFFFFFFF
which can be used to shortcut certain evaluations (subject for
a different patch though)
The simplified version seems to be easier optimizable for gcc 4.3.x
as with -O3 and some artificial benchmarks I made, the new version
is approx. 33% faster in all cases. A oprofile in mythtv revealed
also a speed up.
Hope this patch is okay. If there are any questions or remarks, please let me
know. Thanks for taking a look...
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 2884 bytes
Desc: not available
More information about the ffmpeg-devel