summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-04-03 12:32:51 +0200
committerAnton Khirnov <anton@khirnov.net>2024-04-05 19:46:02 +0200
commit78912a6b9ccc7dc7665dd3bf1d9701dd4f760f72 (patch)
treeeac07b9253fcf71dada16edc8757063b967fc307
parentc03f72bbd135fd2ebe4a611973fae96ce927247a (diff)
lavc/internal: document the precise meaning of AVCodecInternal.draining
Also, set draining=1 in case a bitstream filter returns an internally-triggered EOF. While no bitstream filters currently inserted by decoders will do that, that may change in the future and it is better to cover this case.
-rw-r--r--libavcodec/decode.c12
-rw-r--r--libavcodec/internal.h6
2 files changed, 10 insertions, 8 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 255347766a..9a0e7f3ca5 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -197,8 +197,6 @@ static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
int ret;
ret = av_bsf_receive_packet(avci->bsf, pkt);
- if (ret == AVERROR_EOF)
- avci->draining = 1;
if (ret < 0)
return ret;
@@ -231,14 +229,14 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
if (ret == AVERROR(EAGAIN) &&
(!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
- if (ret < 0) {
- av_packet_unref(avci->buffer_pkt);
- return ret;
- }
+ if (ret >= 0)
+ continue;
- continue;
+ av_packet_unref(avci->buffer_pkt);
}
+ if (ret == AVERROR_EOF)
+ avci->draining = 1;
return ret;
}
}
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 64fe0122c8..3519525ab0 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -121,7 +121,11 @@ typedef struct AVCodecInternal {
void *hwaccel_priv_data;
/**
- * checks API usage: after codec draining, flush is required to resume operation
+ * decoding: AVERROR_EOF has been returned from ff_decode_get_packet(); must
+ * not be used by decoders that use the decode() callback, as they
+ * do not call ff_decode_get_packet() directly.
+ *
+ * encoding: a flush frame has been submitted to avcodec_send_frame().
*/
int draining;