Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Vittorio Giovara authored on 2015/05/26 22:24:38... | ... |
@@ -85,6 +85,13 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char *buf, int buf_size |
85 | 85 |
|
86 | 86 |
uint64_t ffio_read_varlen(AVIOContext *bc); |
87 | 87 |
|
88 |
+/** |
|
89 |
+ * Read size bytes from AVIOContext into buf. |
|
90 |
+ * Check that exactly size bytes have been read. |
|
91 |
+ * @return number of bytes read or AVERROR |
|
92 |
+ */ |
|
93 |
+int ffio_read_size(AVIOContext *s, unsigned char *buf, int size); |
|
94 |
+ |
|
88 | 95 |
/** @warning must be called before any I/O */ |
89 | 96 |
int ffio_set_buf_size(AVIOContext *s, int buf_size); |
90 | 97 |
|
... | ... |
@@ -496,6 +496,14 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) |
496 | 496 |
return size1 - size; |
497 | 497 |
} |
498 | 498 |
|
499 |
+int ffio_read_size(AVIOContext *s, unsigned char *buf, int size) |
|
500 |
+{ |
|
501 |
+ int ret = avio_read(s, buf, size); |
|
502 |
+ if (ret != size) |
|
503 |
+ return AVERROR_INVALIDDATA; |
|
504 |
+ return ret; |
|
505 |
+} |
|
506 |
+ |
|
499 | 507 |
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data) |
500 | 508 |
{ |
501 | 509 |
if (s->buf_end - s->buf_ptr >= size && !s->write_flag) { |