diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-02 19:56:37 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-05 12:08:18 +0100 |
commit | c856e4c5469761390d278e4c5953d86df1d64a21 (patch) | |
tree | 2e50dfd31f0b50983f0e86c22c13488954d59f35 | |
parent | 57e20dd6b6ee47576e83a26c6215d99211421003 (diff) | |
download | ffmpeg-c856e4c5469761390d278e4c5953d86df1d64a21.tar.gz |
avformat/avio: Avoid indirection in ffio_fdopen()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavformat/avio.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c index 1622a03d7f..f3d10fac39 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -408,8 +408,9 @@ fail: return ret; } -int ffio_fdopen(AVIOContext **s, URLContext *h) +int ffio_fdopen(AVIOContext **sp, URLContext *h) { + AVIOContext *s; uint8_t *buffer = NULL; int buffer_size, max_packet_size; @@ -428,36 +429,37 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) if (!buffer) return AVERROR(ENOMEM); - *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h, - ffurl_read2, ffurl_write2, ffurl_seek2); - if (!*s) { + *sp = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h, + ffurl_read2, ffurl_write2, ffurl_seek2); + if (!*sp) { av_freep(&buffer); return AVERROR(ENOMEM); } - (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist); - if (!(*s)->protocol_whitelist && h->protocol_whitelist) { - avio_closep(s); + s = *sp; + s->protocol_whitelist = av_strdup(h->protocol_whitelist); + if (!s->protocol_whitelist && h->protocol_whitelist) { + avio_closep(sp); return AVERROR(ENOMEM); } - (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist); - if (!(*s)->protocol_blacklist && h->protocol_blacklist) { - avio_closep(s); + s->protocol_blacklist = av_strdup(h->protocol_blacklist); + if (!s->protocol_blacklist && h->protocol_blacklist) { + avio_closep(sp); return AVERROR(ENOMEM); } - (*s)->direct = h->flags & AVIO_FLAG_DIRECT; + s->direct = h->flags & AVIO_FLAG_DIRECT; - (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; - (*s)->max_packet_size = max_packet_size; - (*s)->min_packet_size = h->min_packet_size; + s->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; + s->max_packet_size = max_packet_size; + s->min_packet_size = h->min_packet_size; if(h->prot) { - (*s)->read_pause = h->prot->url_read_pause; - (*s)->read_seek = h->prot->url_read_seek; + s->read_pause = h->prot->url_read_pause; + s->read_seek = h->prot->url_read_seek; if (h->prot->url_read_seek) - (*s)->seekable |= AVIO_SEEKABLE_TIME; + s->seekable |= AVIO_SEEKABLE_TIME; } - ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek; - (*s)->av_class = &ff_avio_class; + ((FFIOContext*)s)->short_seek_get = ffurl_get_short_seek; + s->av_class = &ff_avio_class; return 0; } |