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@khirnov.net>
This commit is contained in:
Marvin Scholz 2021-11-22 00:25:16 +01:00 committed by Anton Khirnov
parent a7df966c82
commit c6f4e10111
4 changed files with 4 additions and 4 deletions

View File

@ -368,7 +368,7 @@ static int hds_write_header(AVFormatContext *s)
ctx->flags = s->flags; ctx->flags = s->flags;
ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf),
AVIO_FLAG_WRITE, os, 1, os,
NULL, hds_write, NULL); NULL, hds_write, NULL);
if (!ctx->pb) { if (!ctx->pb) {
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

View File

@ -569,7 +569,7 @@ static int open_null_ctx(AVIOContext **ctx)
uint8_t *buf = av_malloc(buf_size); uint8_t *buf = av_malloc(buf_size);
if (!buf) if (!buf)
return AVERROR(ENOMEM); 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) { if (!*ctx) {
av_free(buf); av_free(buf);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);

View File

@ -335,7 +335,7 @@ static int ism_write_header(AVFormatContext *s)
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base; 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) { if (!ctx->pb) {
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }

View File

@ -186,7 +186,7 @@ static void init_fps(int bf, int audio_preroll, int fps)
ctx->oformat = av_guess_format(format, NULL, NULL); ctx->oformat = av_guess_format(format, NULL, NULL);
if (!ctx->oformat) if (!ctx->oformat)
exit(1); 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) if (!ctx->pb)
exit(1); exit(1);
ctx->pb->write_data_type = io_write_data_type; ctx->pb->write_data_type = io_write_data_type;