diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-08-04 16:52:07 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-08-25 23:01:54 +0200 |
commit | 45bfe8b838275235412777dd430206d9a24eb3ee (patch) | |
tree | d35a1ee7436b0259fd26d32bc80482c0a9f2927e /libavformat/rdt.c | |
parent | 530ac6aa305aeda631c77f8a17e96c14c7ab1a1c (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/rdt.c')
-rw-r--r-- | libavformat/rdt.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/libavformat/rdt.c b/libavformat/rdt.c index da55503ea6..a015acb690 100644 --- a/libavformat/rdt.c +++ b/libavformat/rdt.c @@ -131,7 +131,8 @@ ff_rdt_calc_response_and_checksum(char response[41], char chksum[9], static int rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) { - AVIOContext pb; + FFIOContext pb0; + AVIOContext *const pb = &pb0.pub; unsigned int size; uint32_t tag; @@ -151,32 +152,32 @@ rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) */ if (!rdt->mlti_data) return -1; - ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0, + ffio_init_context(&pb0, rdt->mlti_data, rdt->mlti_data_size, 0, NULL, NULL, NULL, NULL); - tag = avio_rl32(&pb); + tag = avio_rl32(pb); if (tag == MKTAG('M', 'L', 'T', 'I')) { int num, chunk_nr; /* read index of MDPR chunk numbers */ - num = avio_rb16(&pb); + num = avio_rb16(pb); if (rule_nr < 0 || rule_nr >= num) return -1; - avio_skip(&pb, rule_nr * 2); - chunk_nr = avio_rb16(&pb); - avio_skip(&pb, (num - 1 - rule_nr) * 2); + avio_skip(pb, rule_nr * 2); + chunk_nr = avio_rb16(pb); + avio_skip(pb, (num - 1 - rule_nr) * 2); /* read MDPR chunks */ - num = avio_rb16(&pb); + num = avio_rb16(pb); if (chunk_nr >= num) return -1; while (chunk_nr--) - avio_skip(&pb, avio_rb32(&pb)); - size = avio_rb32(&pb); + avio_skip(pb, avio_rb32(pb)); + size = avio_rb32(pb); } else { size = rdt->mlti_data_size; - avio_seek(&pb, 0, SEEK_SET); + avio_seek(pb, 0, SEEK_SET); } - if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[st->index], size, NULL) < 0) + if (ff_rm_read_mdpr_codecdata(rdt->rmctx, pb, st, rdt->rmst[st->index], size, NULL) < 0) return -1; return 0; @@ -296,16 +297,16 @@ rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, const uint8_t *buf, int len, uint16_t rtp_seq, int flags) { int seq = 1, res; - AVIOContext pb; if (rdt->audio_pkt_cnt == 0) { + FFIOContext pb; int pos, rmflags; ffio_init_context(&pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); rmflags = (flags & RTP_FLAG_KEY) ? 2 : 0; - res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt, - &seq, rmflags, *timestamp); - pos = avio_tell(&pb); + res = ff_rm_parse_packet(rdt->rmctx, &pb.pub, st, rdt->rmst[st->index], + len, pkt, &seq, rmflags, *timestamp); + pos = avio_tell(&pb.pub); if (res < 0) return res; if (res > 0) { |