Mercurial > libavcodec.hg
diff h263.c @ 9024:2bf694251330 libavcodec
Add ff_h263_find_resync_marker() to find the bit position of the next resync_marker, if any.
patch by Gwenole Beauchesne gbeauchesne splitted-desktopcom
based on suggested implementation by me
author | michael |
---|---|
date | Tue, 24 Feb 2009 16:12:47 +0000 |
parents | 251c7a9cb795 |
children | e9ba8210d495 |
line wrap: on
line diff
--- a/h263.c Tue Feb 24 15:56:53 2009 +0000 +++ b/h263.c Tue Feb 24 16:12:47 2009 +0000 @@ -3293,6 +3293,27 @@ } /** + * finds the next resync_marker + * @param p pointer to buffer to scan + * @param end pointer to the end of the buffer + * @return pointer to the next resync_marker, or \p end if none was found + */ +const uint8_t *ff_h263_find_resync_marker(const uint8_t *restrict p, const uint8_t * restrict end) +{ + assert(p < end); + + end-=2; + p++; + for(;p<end; p+=2){ + if(!*p){ + if (!p[-1] && p[1]) return p - 1; + else if(!p[ 1] && p[2]) return p; + } + } + return end+2; +} + +/** * decodes the group of blocks / video packet header. * @return bit position of the resync_marker, or <0 if none was found */