mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-30 14:40:32 +00:00
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.
This commit is contained in:
parent
d9cf5f5169
commit
e28ac6e5e2
@ -393,6 +393,22 @@ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize GetBitContext.
|
||||||
|
* @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
|
||||||
|
* larger than the actual read bits because some optimized bitstream
|
||||||
|
* readers read 32 or 64 bit at once and could read over the end
|
||||||
|
* @param byte_size the size of the buffer in bytes
|
||||||
|
* @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
|
||||||
|
*/
|
||||||
|
static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
|
||||||
|
int byte_size)
|
||||||
|
{
|
||||||
|
if (byte_size > INT_MAX / 8)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
|
return init_get_bits(s, buffer, byte_size * 8);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void align_get_bits(GetBitContext *s)
|
static inline void align_get_bits(GetBitContext *s)
|
||||||
{
|
{
|
||||||
int n = -get_bits_count(s) & 7;
|
int n = -get_bits_count(s) & 7;
|
||||||
|
Loading…
Reference in New Issue
Block a user