[FFmpeg-devel] [PATCH 3/5] lavf: replace FFERROR_REDO with AVERROR(EAGAIN)
Anton Khirnov
anton at khirnov.net
Tue Nov 8 13:25:48 EET 2022
There is no meaningful distinction between them, both mean "the demuxer
did some work, but did not produce a packet - should be called again".
---
libavformat/demux.c | 12 ++++--------
libavformat/demux.h | 6 ------
libavformat/flvdec.c | 14 +++++++-------
libavformat/lxfdec.c | 2 +-
libavformat/mlvdec.c | 2 +-
libavformat/mpeg.c | 2 +-
libavformat/smacker.c | 2 +-
7 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 5cd9522367..8c81a58274 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -572,14 +572,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (err < 0) {
av_packet_unref(pkt);
- /* Some demuxers return FFERROR_REDO when they consume
- data and discard it (ignored streams, junk, extradata).
- We must re-call the demuxer to get the real packet.
-
- Treat EAGAIN the same as FFERROR_REDO, unless the user
- requested non-blocking behavior. */
- if (err == FFERROR_REDO ||
- (err == AVERROR(EAGAIN) && !(s->flags & AVFMT_FLAG_NONBLOCK)))
+ /* Some demuxers return AVERROR(EAGAIN) when they consume
+ data and discard it (ignored streams, junk, extradata). Call the
+ demuxer again unless the user requested non-blocking behavior. */
+ if (err == AVERROR(EAGAIN) && !(s->flags & AVFMT_FLAG_NONBLOCK))
continue;
if (!pktl || err == AVERROR(EAGAIN))
return err;
diff --git a/libavformat/demux.h b/libavformat/demux.h
index 1f57e062f6..a008c3dba1 100644
--- a/libavformat/demux.h
+++ b/libavformat/demux.h
@@ -55,12 +55,6 @@ typedef struct FFStreamInfo {
int fps_last_dts_idx;
} FFStreamInfo;
-/**
- * Returned by demuxers to indicate that data was consumed but discarded
- * (ignored streams or junk data). The framework will re-call the demuxer.
- */
-#define FFERROR_REDO FFERRTAG('R','E','D','O')
-
#define RELATIVE_TS_BASE (INT64_MAX - (1LL << 48))
static av_always_inline int is_relative(int64_t ts)
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index d83edff727..d320a431db 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1058,7 +1058,7 @@ retry:
}
if (size == 0) {
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
@@ -1110,13 +1110,13 @@ skip:
av_log(s, AV_LOG_ERROR, "Unable to seek to the next packet\n");
return AVERROR_INVALIDDATA;
}
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
/* skip empty data packets */
if (!size) {
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
@@ -1160,7 +1160,7 @@ skip:
(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && stream_type == FLV_STREAM_TYPE_VIDEO)) ||
st->discard >= AVDISCARD_ALL) {
avio_seek(s->pb, next, SEEK_SET);
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
@@ -1273,7 +1273,7 @@ retry_duration:
if (st->codecpar->extradata) {
if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0)
return ret;
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
if ((ret = flv_get_extradata(s, st, size)) < 0)
@@ -1284,14 +1284,14 @@ retry_duration:
if (st->codecpar->codec_id == AV_CODEC_ID_AAC && t && !strcmp(t->value, "Omnia A/XE"))
st->codecpar->extradata_size = 2;
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
}
/* skip empty data packets */
if (!size) {
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto leave;
}
diff --git a/libavformat/lxfdec.c b/libavformat/lxfdec.c
index 8003ae98b7..bd28dfe270 100644
--- a/libavformat/lxfdec.c
+++ b/libavformat/lxfdec.c
@@ -307,7 +307,7 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
if (stream > 1) {
av_log(s, AV_LOG_WARNING,
"got packet with illegal stream index %"PRIu32"\n", stream);
- return FFERROR_REDO;
+ return AVERROR(EAGAIN);
}
if (stream == 1 && s->nb_streams < 2) {
diff --git a/libavformat/mlvdec.c b/libavformat/mlvdec.c
index db3b77bb9b..d510787fcd 100644
--- a/libavformat/mlvdec.c
+++ b/libavformat/mlvdec.c
@@ -422,7 +422,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
pb = mlv->pb[sti->index_entries[index].size];
if (!pb) {
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto next_packet;
}
avio_seek(pb, sti->index_entries[index].pos, SEEK_SET);
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..f566ff74bd 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -251,7 +251,7 @@ redo:
if (avio_feof(s->pb))
return AVERROR_EOF;
// FIXME we should remember header_state
- return FFERROR_REDO;
+ return AVERROR(EAGAIN);
}
if (startcode == PACK_START_CODE)
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index 1d54e8e917..052b6d28d4 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -332,7 +332,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt)
}
if (s->streams[smk->videoindex]->discard >= AVDISCARD_ALL) {
- ret = FFERROR_REDO;
+ ret = AVERROR(EAGAIN);
goto next_frame;
}
if (smk->frame_size >= INT_MAX/2) {
--
2.35.1
More information about the ffmpeg-devel
mailing list