[FFmpeg-cvslog] avformat: do not use AVIO_FLAG_* with avio_alloc_context

Marvin Scholz git at videolan.org
Sat Dec 4 15:35:58 EET 2021


ffmpeg | branch: master | Marvin Scholz <epirat07 at gmail.com> | Mon Nov 22 00:25:16 2021 +0100| [c6f4e10111debf5b547a399661a5fe997d761033] | committer: Anton Khirnov

avformat: do not use AVIO_FLAG_* with avio_alloc_context

The documentation states that here 0 should be used for read-only and
1 for a writable buffer. AVIO_FLAG_WRITE however is 2, while it works
due to the way the flag is handled internally, it is still wrong
according to the documentation.

Additionally it makes it seem as if the AVIO_FLAG_* values could be used
here, which is actually not true, as when AVIO_FLAG_READ would be used
here it would create a writable buffer as AVIO_FLAG_READ is defined as 1.

Signed-off-by: Anton Khirnov <anton at khirnov.net>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c6f4e10111debf5b547a399661a5fe997d761033
---

 libavformat/hdsenc.c             | 2 +-
 libavformat/segment.c            | 2 +-
 libavformat/smoothstreamingenc.c | 2 +-
 libavformat/tests/movenc.c       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c
index 64d9f1413d..2a52019120 100644
--- a/libavformat/hdsenc.c
+++ b/libavformat/hdsenc.c
@@ -368,7 +368,7 @@ static int hds_write_header(AVFormatContext *s)
             ctx->flags = s->flags;
 
             ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf),
-                                         AVIO_FLAG_WRITE, os,
+                                         1, os,
                                          NULL, hds_write, NULL);
             if (!ctx->pb) {
                 return AVERROR(ENOMEM);
diff --git a/libavformat/segment.c b/libavformat/segment.c
index 9861462405..d531286c31 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -569,7 +569,7 @@ static int open_null_ctx(AVIOContext **ctx)
     uint8_t *buf = av_malloc(buf_size);
     if (!buf)
         return AVERROR(ENOMEM);
-    *ctx = avio_alloc_context(buf, buf_size, AVIO_FLAG_WRITE, NULL, NULL, NULL, NULL);
+    *ctx = avio_alloc_context(buf, buf_size, 1, NULL, NULL, NULL, NULL);
     if (!*ctx) {
         av_free(buf);
         return AVERROR(ENOMEM);
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index 27b59c299c..6bede7c254 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -335,7 +335,7 @@ static int ism_write_header(AVFormatContext *s)
         st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
         st->time_base = s->streams[i]->time_base;
 
-        ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
+        ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), 1, os, NULL, ism_write, ism_seek);
         if (!ctx->pb) {
             return AVERROR(ENOMEM);
         }
diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c
index 04155dde76..2af72f11c7 100644
--- a/libavformat/tests/movenc.c
+++ b/libavformat/tests/movenc.c
@@ -186,7 +186,7 @@ static void init_fps(int bf, int audio_preroll, int fps)
     ctx->oformat = av_guess_format(format, NULL, NULL);
     if (!ctx->oformat)
         exit(1);
-    ctx->pb = avio_alloc_context(iobuf, iobuf_size, AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
+    ctx->pb = avio_alloc_context(iobuf, iobuf_size, 1, NULL, NULL, io_write, NULL);
     if (!ctx->pb)
         exit(1);
     ctx->pb->write_data_type = io_write_data_type;



More information about the ffmpeg-cvslog mailing list