mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
avio: Add avio_read wrapper to simplify error checking
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
cffb9ea81b
commit
bff0349d9d
@ -85,6 +85,13 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size
|
||||
|
||||
uint64_t ffio_read_varlen(AVIOContext *bc);
|
||||
|
||||
/**
|
||||
* Read size bytes from AVIOContext into buf.
|
||||
* Check that exactly size bytes have been read.
|
||||
* @return number of bytes read or AVERROR
|
||||
*/
|
||||
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size);
|
||||
|
||||
/** @warning must be called before any I/O */
|
||||
int ffio_set_buf_size(AVIOContext *s, int buf_size);
|
||||
|
||||
|
@ -496,6 +496,14 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
|
||||
return size1 - size;
|
||||
}
|
||||
|
||||
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
|
||||
{
|
||||
int ret = avio_read(s, buf, size);
|
||||
if (ret != size)
|
||||
return AVERROR_INVALIDDATA;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
|
||||
{
|
||||
if (s->buf_end - s->buf_ptr >= size && !s->write_flag) {
|
||||
|
Loading…
Reference in New Issue
Block a user