[FFmpeg-devel] [PATCH 1/2] VP4 video decoder
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Sun May 12 14:24:56 EEST 2019
On 12.05.2019, at 08:12, Peter Ross <pross at xvid.org> wrote:
> +static int read_mb_value(GetBitContext *gb)
> +{
> + int v = 1;
> + int size;
> +
> + do {
> + size = 0;
> + if (!get_bits1(gb))
> + break;
> + v++;
> + do {
> + if (!get_bits1(gb))
> + break;
> + v += 1 << size++;
> + } while (size < 8);
> + } while (size == 8);
> +
> + if (size)
> + v += get_bits(gb, size);
> +
> + return v;
> +}
Maybe not worth it performance wise, but did you check if this could be simplified?
For example the get_bits1 cases that end up with size 0 could return directly.
Or it could peek ahead 9 bits in the bitstream and count the leading 1s to get v and size without looping (i.e. loop only for the 9 bits of 1s specifically).
Alternatively add a comment to clarify the encoding scheme it implements (like 9 consecutive 1s is a prefix encoding an offset of 257 etc).
More information about the ffmpeg-devel
mailing list