History

lavc/decode: wrap AV_FRAME_FLAG_DISCARD handling in a loop

Makes sure discarded frames do not cause EAGAIN to be returned during flushing, which is forbidden.

Anton Khirnov committed 2 years ago

Commit 048e9781 parent 64743b41 file · +8 −3Browse files

Unified · Split

libavcodec/decode.c+8−3
@@ -613,17 +613,22 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 612 unmodified lines
613613 av_assert0(!frame->buf[0]);
614614
615615 if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) {
616+ while (1) {
616617 frame->pict_type = dc->initial_pict_type;
617618 frame->flags |= dc->intra_only_flag;
618619 ret = codec->cb.receive_frame(avctx, frame);
619620 emms_c();
620621 if (!ret) {
621− if (avctx->codec->type == AVMEDIA_TYPE_VIDEO)
622− ret = (frame->flags & AV_FRAME_FLAG_DISCARD) ? AVERROR(EAGAIN) : 0;
623− else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
622+ if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
624623 int64_t discarded_samples = 0;
625624 ret = discard_samples(avctx, frame, &discarded_samples);
626625 }
626+ if (ret == AVERROR(EAGAIN) || (frame->flags & AV_FRAME_FLAG_DISCARD)) {
627+ av_frame_unref(frame);
628+ continue;
629+ }
630+ }
631+ break;
627632 }
628633 } else
629634 ret = decode_simple_receive_frame(avctx, frame);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t