lavc: check for overflow in init_get_bits

Fix an undefined behaviour and make the function return a proper
error in case of overflow.

CC: libav-stable@libav.org
(cherry picked from commit d9cf5f516974c64e01846ca685301014b38cf224)

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
lavc: introduce the convenience function init_get_bits8

Accept the buffer size in bytes and check for overflow before passing
the value in bits to init_get_bits.
(cherry picked from commit e28ac6e5e27e64a206e399e958481c1e6f992189)

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
lavc: set the default rc_initial_buffer_occupancy

rc_buffer_size is not set before.

Solve the initial the rate control underflow issue reported in
bug 222.

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit bff3607547fdbb6e32b3830a351e6a33280c1e0d)

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libx264: use the library specific default rc_initial_buffer_occupancy

By default libav sets it to 3/4 while x264 sets it to 9/10.

CC: libav-stable@libav.org

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 47812070a267cbdf74164e154d03d99bf8ced100)

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>