From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D555346B58 for ; Mon, 3 Jul 2023 19:33:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 767D468C5AE; Mon, 3 Jul 2023 22:33:02 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60B1868C59F for ; Mon, 3 Jul 2023 22:32:54 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F37D52404F5 for ; Mon, 3 Jul 2023 21:32:53 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id mOmmVLjZlZZw for ; Mon, 3 Jul 2023 21:32:52 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E0A20240591 for ; Mon, 3 Jul 2023 21:32:51 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id BA24A3A16DB for ; Mon, 3 Jul 2023 21:32:45 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Jul 2023 21:32:26 +0200 Message-Id: <20230703193229.8593-8-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230703193229.8593-1-anton@khirnov.net> References: <20230703193229.8593-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 07/10] lavc/decode: track whether the caller started draining with a separate flag X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Decoding pipeline has multiple stages, some of which may have their own delay (e.g. bitstream filters). The code currently uses AVCodecInternal.draining to track all of them, but they do not have to all be in sync. --- libavcodec/decode.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index acec9860a5..47714a9393 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -55,6 +55,11 @@ typedef struct DecodeContext { /* to prevent infinite loop on errors when draining */ int nb_draining_errors; + + /** + * The caller has submitted a NULL packet on input. + */ + int draining_started; } DecodeContext; static DecodeContext *decode_ctx(AVCodecInternal *avci) @@ -626,12 +631,13 @@ FF_ENABLE_DEPRECATION_WARNINGS int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt) { AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); int ret; if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec)) return AVERROR(EINVAL); - if (avctx->internal->draining) + if (dc->draining_started) return AVERROR_EOF; if (avpkt && !avpkt->size && avpkt->data) @@ -642,7 +648,8 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke ret = av_packet_ref(avci->buffer_pkt, avpkt); if (ret < 0) return ret; - } + } else + dc->draining_started = 1; ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt); if (ret < 0) { @@ -1756,6 +1763,7 @@ AVBufferRef *ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void ff_decode_flush_buffers(AVCodecContext *avctx) { AVCodecInternal *avci = avctx->internal; + DecodeContext *dc = decode_ctx(avci); av_packet_unref(avci->last_pkt_props); av_packet_unref(avci->in_pkt); @@ -1765,7 +1773,8 @@ void ff_decode_flush_buffers(AVCodecContext *avctx) av_bsf_flush(avci->bsf); - decode_ctx(avci)->nb_draining_errors = 0; + dc->nb_draining_errors = 0; + dc->draining_started = 0; } AVCodecInternal *ff_decode_internal_alloc(void) -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".