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.
release/7.1
Anton Khirnov 11 months ago
parent d94cfd4900
commit 64743b45b5
  1. 12
      libavcodec/decode.c
  2. 6
      libavcodec/internal.h

@ -213,8 +213,6 @@ static int decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
int ret; int ret;
ret = av_bsf_receive_packet(avci->bsf, pkt); ret = av_bsf_receive_packet(avci->bsf, pkt);
if (ret == AVERROR_EOF)
avci->draining = 1;
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -247,14 +245,14 @@ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
if (ret == AVERROR(EAGAIN) && if (ret == AVERROR(EAGAIN) &&
(!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) { (!AVPACKET_IS_EMPTY(avci->buffer_pkt) || dc->draining_started)) {
ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt); ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
if (ret < 0) { if (ret >= 0)
av_packet_unref(avci->buffer_pkt); continue;
return ret;
}
continue; av_packet_unref(avci->buffer_pkt);
} }
if (ret == AVERROR_EOF)
avci->draining = 1;
return ret; return ret;
} }
} }

@ -123,7 +123,11 @@ typedef struct AVCodecInternal {
void *hwaccel_priv_data; 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; int draining;

Loading…
Cancel
Save