From ea2b1ac70789ad6386c1b2984f3c1f1fe3c7f3ec Mon Sep 17 00:00:00 2001 From: Asd-g <65298684+Asd-g@users.noreply.github.com> Date: Tue, 2 Apr 2024 03:49:00 +0300 Subject: [PATCH] Flushing buffers (related fcd1ed5f0656940729373a17c3cf94e458a1da14) After 3bbe176e2770de419b7350d5a5ebe2c3c839d712 do not by default open and close the codec in order to flush the video buffer. --- common/lwlibav_dec.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/lwlibav_dec.c b/common/lwlibav_dec.c index 4787f930..0dd3872f 100644 --- a/common/lwlibav_dec.c +++ b/common/lwlibav_dec.c @@ -45,7 +45,13 @@ void lwlibav_flush_buffers lwlibav_decode_handler_t *dhp ) { - if (dhp->index_entries_count <= 1) + if (!strcmp(dhp->ctx->codec->name, "libdav1d") + && dhp->ctx->level > 9) + avcodec_flush_buffers(dhp->ctx); + else if (dhp->ctx->codec_type == AVMEDIA_TYPE_VIDEO + && strcmp(dhp->ctx->codec->name, "libdav1d")) + avcodec_flush_buffers(dhp->ctx); + else { const AVCodecParameters* codecpar = dhp->format->streams[dhp->stream_index]->codecpar; const AVCodec* codec = dhp->ctx->codec; @@ -67,8 +73,6 @@ void lwlibav_flush_buffers dhp->ctx->opaque = app_specific; } } - else - avcodec_flush_buffers(dhp->ctx); dhp->exh.delay_count = 0; }