On 2014-04-05 03:41:14 +0200, Luca Barbato wrote:
> Two less read and somehow match the style of other functions with similar
> purpose in the codebase.
only in the unlikely case of damaged streams, one read more for
the expected case.
> ---
> libavcodec/h264.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 1a04cc1..daaa5f8 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -1284,18 +1284,23 @@ int ff_set_ref_count(H264Context *h)
> static int get_nal_start(const uint8_t *buf, int buf_size,
> int buf_index, int next_avc)
> {
> - // start code prefix search
> - for (; buf_index + 3 < next_avc; buf_index++)
> - // This should always succeed in the first iteration.
> - if (buf[buf_index] == 0 &&
> - buf[buf_index + 1] == 0 &&
> - buf[buf_index + 2] == 1)
> - break;
> + unsigned int var, i;
>
> if (buf_index + 3 >= buf_size)
> return buf_size;
>
> - return buf_index + 3;
> + var = AV_RB24(buf + buf_index);
> +
> + for (i = buf_index + 3; i < next_avc; i++) {
> + var = (var << 8) | buf[i];
> + if ((var & 0xffffff00) == 0x00000100)
> + break;
> + }
i = buf_index + 3
while (var != 0x000001)
var = ((var << 8) | buf[i++]) & 0xffffff;
> +
> + if (i >= buf_size)
> + return buf_size;
> +
> + return i;
> }
but it can imho stay as it is
Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel