summaryrefslogtreecommitdiff
path: root/libavformat/av1dec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-04 16:52:07 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-08-25 23:01:54 +0200
commit45bfe8b838275235412777dd430206d9a24eb3ee (patch)
treed35a1ee7436b0259fd26d32bc80482c0a9f2927e /libavformat/av1dec.c
parent530ac6aa305aeda631c77f8a17e96c14c7ab1a1c (diff)
avformat/avio: Move internal AVIOContext fields to avio_internal.h
Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/av1dec.c')
-rw-r--r--libavformat/av1dec.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c
index 37f21483b9..e994312253 100644
--- a/libavformat/av1dec.c
+++ b/libavformat/av1dec.c
@@ -157,32 +157,33 @@ static int read_obu(const uint8_t *buf, int size, int64_t *obu_size, int *type)
static int annexb_probe(const AVProbeData *p)
{
- AVIOContext pb;
+ FFIOContext ctx;
+ AVIOContext *const pb = &ctx.pub;
int64_t obu_size;
uint32_t temporal_unit_size, frame_unit_size, obu_unit_size;
int seq = 0;
int ret, type, cnt = 0;
- ffio_init_context(&pb, p->buf, p->buf_size, 0,
+ ffio_init_context(&ctx, p->buf, p->buf_size, 0,
NULL, NULL, NULL, NULL);
- ret = leb(&pb, &temporal_unit_size);
+ ret = leb(pb, &temporal_unit_size);
if (ret < 0)
return 0;
cnt += ret;
- ret = leb(&pb, &frame_unit_size);
+ ret = leb(pb, &frame_unit_size);
if (ret < 0 || ((int64_t)frame_unit_size + ret) > temporal_unit_size)
return 0;
cnt += ret;
- ret = leb(&pb, &obu_unit_size);
+ ret = leb(pb, &obu_unit_size);
if (ret < 0 || ((int64_t)obu_unit_size + ret) >= frame_unit_size)
return 0;
cnt += ret;
frame_unit_size -= obu_unit_size + ret;
- avio_skip(&pb, obu_unit_size);
- if (pb.eof_reached || pb.error)
+ avio_skip(pb, obu_unit_size);
+ if (pb->eof_reached || pb->error)
return 0;
// Check that the first OBU is a Temporal Delimiter.
@@ -192,13 +193,13 @@ static int annexb_probe(const AVProbeData *p)
cnt += obu_unit_size;
do {
- ret = leb(&pb, &obu_unit_size);
+ ret = leb(pb, &obu_unit_size);
if (ret < 0 || ((int64_t)obu_unit_size + ret) > frame_unit_size)
return 0;
cnt += ret;
- avio_skip(&pb, obu_unit_size);
- if (pb.eof_reached || pb.error)
+ avio_skip(pb, obu_unit_size);
+ if (pb->eof_reached || pb->error)
return 0;
ret = read_obu(p->buf + cnt, FFMIN(p->buf_size - cnt, obu_unit_size), &obu_size, &type);