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 5BB1442B46 for ; Tue, 11 Jan 2022 20:55:42 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C7FB68AFCD; Tue, 11 Jan 2022 22:54:58 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 447D968AF57 for ; Tue, 11 Jan 2022 22:54:49 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B8B122404FE for ; Tue, 11 Jan 2022 21:54:48 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id g4ApduHry6L2 for ; Tue, 11 Jan 2022 21:54:48 +0100 (CET) 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 D9AEB240506 for ; Tue, 11 Jan 2022 21:54:46 +0100 (CET) Received: by libav.khirnov.net (Postfix, from userid 1000) id 6C77A3A0E76; Tue, 11 Jan 2022 21:47:25 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jan 2022 21:46:07 +0100 Message-Id: <20220111204610.14262-32-anton@khirnov.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220111204610.14262-1-anton@khirnov.net> References: <20220111204610.14262-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 32/35] lavfi/qsvvpp: switch to new FIFO API 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: --- libavfilter/qsvvpp.c | 46 +++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index d1218355c7..60da1d47c5 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -40,6 +40,11 @@ static const AVRational default_tb = { 1, 90000 }; +typedef struct QSVAsyncFrame { + mfxSyncPoint sync; + QSVFrame *frame; +} QSVAsyncFrame; + static const struct { int mfx_iopattern; const char *desc; @@ -642,16 +647,6 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) return 0; } -static unsigned int qsv_fifo_item_size(void) -{ - return sizeof(mfxSyncPoint) + sizeof(QSVFrame*); -} - -static unsigned int qsv_fifo_size(const AVFifoBuffer* fifo) -{ - return av_fifo_size(fifo)/qsv_fifo_item_size(); -} - int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param) { int i; @@ -727,7 +722,7 @@ int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *p s->got_frame = 0; /** keep fifo size at least 1. Even when async_depth is 0, fifo is used. */ - s->async_fifo = av_fifo_alloc((param->async_depth + 1) * qsv_fifo_item_size()); + s->async_fifo = av_fifo_alloc2(param->async_depth + 1, sizeof(QSVAsyncFrame), 0); s->async_depth = param->async_depth; if (!s->async_fifo) { ret = AVERROR(ENOMEM); @@ -799,24 +794,25 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; + QSVAsyncFrame aframe; mfxSyncPoint sync; QSVFrame *in_frame, *out_frame, *tmp; int ret, filter_ret; - while (s->eof && qsv_fifo_size(s->async_fifo)) { - av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL); - av_fifo_generic_read(s->async_fifo, &sync, sizeof(sync), NULL); - if (MFXVideoCORE_SyncOperation(s->session, sync, 1000) < 0) + while (s->eof && av_fifo_can_read(s->async_fifo)) { + av_fifo_read(s->async_fifo, &aframe, 1); + + if (MFXVideoCORE_SyncOperation(s->session, aframe.sync, 1000) < 0) av_log(ctx, AV_LOG_WARNING, "Sync failed.\n"); - filter_ret = s->filter_frame(outlink, tmp->frame); + filter_ret = s->filter_frame(outlink, aframe.frame->frame); if (filter_ret < 0) { - av_frame_free(&tmp->frame); + av_frame_free(&aframe.frame->frame); return filter_ret; } - tmp->queued--; + aframe.frame->queued--; s->got_frame = 1; - tmp->frame = NULL; + aframe.frame->frame = NULL; }; if (!picref) @@ -853,16 +849,14 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr default_tb, outlink->time_base); out_frame->queued++; - av_fifo_generic_write(s->async_fifo, &out_frame, sizeof(out_frame), NULL); - av_fifo_generic_write(s->async_fifo, &sync, sizeof(sync), NULL); - + aframe = (QSVAsyncFrame){ sync, out_frame }; + av_fifo_write(s->async_fifo, &aframe, 1); - if (qsv_fifo_size(s->async_fifo) > s->async_depth) { - av_fifo_generic_read(s->async_fifo, &tmp, sizeof(tmp), NULL); - av_fifo_generic_read(s->async_fifo, &sync, sizeof(sync), NULL); + if (av_fifo_can_read(s->async_fifo) > s->async_depth) { + av_fifo_read(s->async_fifo, &aframe, 1); do { - ret = MFXVideoCORE_SyncOperation(s->session, sync, 1000); + ret = MFXVideoCORE_SyncOperation(s->session, aframe.sync, 1000); } while (ret == MFX_WRN_IN_EXECUTION); filter_ret = s->filter_frame(outlink, tmp->frame); -- 2.33.0 _______________________________________________ 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".