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/rtpdec_asf.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/rtpdec_asf.c')
-rw-r--r-- | libavformat/rtpdec_asf.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 3802a57407..7812117228 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -87,20 +87,20 @@ static int packetizer_read(void *opaque, uint8_t *buf, int buf_size) return AVERROR(EAGAIN); } -static void init_packetizer(AVIOContext *pb, uint8_t *buf, int len) +static void init_packetizer(FFIOContext *pb, uint8_t *buf, int len) { ffio_init_context(pb, buf, len, 0, NULL, packetizer_read, NULL, NULL); /* this "fills" the buffer with its current content */ - pb->pos = len; - pb->buf_end = buf + len; + pb->pub.pos = len; + pb->pub.buf_end = buf + len; } int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) { int ret = 0; if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) { - AVIOContext pb = { 0 }; + FFIOContext pb; RTSPState *rt = s->priv_data; AVDictionary *opts = NULL; int len = strlen(p) * 6 / 8; @@ -127,7 +127,7 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) av_free(buf); return AVERROR(ENOMEM); } - rt->asf_ctx->pb = &pb; + rt->asf_ctx->pb = &pb.pub; av_dict_set(&opts, "no_resync_search", "1", 0); if ((ret = ff_copy_whiteblacklists(rt->asf_ctx, s)) < 0) { @@ -138,12 +138,12 @@ int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p) ret = avformat_open_input(&rt->asf_ctx, "", iformat, &opts); av_dict_free(&opts); if (ret < 0) { - av_free(pb.buffer); + av_free(pb.pub.buffer); return ret; } av_dict_copy(&s->metadata, rt->asf_ctx->metadata, 0); - rt->asf_pb_pos = avio_tell(&pb); - av_free(pb.buffer); + rt->asf_pb_pos = avio_tell(&pb.pub); + av_free(pb.pub.buffer); rt->asf_ctx->pb = NULL; } return ret; @@ -178,7 +178,8 @@ static int asfrtp_parse_sdp_line(AVFormatContext *s, int stream_index, } struct PayloadContext { - AVIOContext *pktbuf, pb; + FFIOContext pb; + AVIOContext *pktbuf; uint8_t *buf; }; @@ -193,7 +194,8 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, const uint8_t *buf, int len, uint16_t seq, int flags) { - AVIOContext *pb = &asf->pb; + FFIOContext *const pb0 = &asf->pb; + AVIOContext *const pb = &pb0->pub; int res, mflags, len_off; RTSPState *rt = s->priv_data; @@ -208,7 +210,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, av_freep(&asf->buf); - ffio_init_context(pb, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(pb0, (uint8_t *)buf, len, 0, NULL, NULL, NULL, NULL); while (avio_tell(pb) + 4 < len) { int start_off = avio_tell(pb); @@ -267,7 +269,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, } } - init_packetizer(pb, asf->buf, out_len); + init_packetizer(pb0, asf->buf, out_len); pb->pos += rt->asf_pb_pos; pb->eof_reached = 0; rt->asf_ctx->pb = pb; |