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 113F4451F6 for ; Mon, 12 Jun 2023 08:16:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5289C68C39F; Mon, 12 Jun 2023 11:15:54 +0300 (EEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F001B68C1E4 for ; Mon, 12 Jun 2023 11:15:50 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686557751; x=1718093751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q8fRtJ/SK240Aj3mappn9hSLyPer2onVz48MFwpdKbk=; b=cata+7ZCYgVtwGAl1rZq7SgjPyJYkdVN/AJTXmNAoK/lx5GpMn2F4w4c hYzhfJUmRzBX6VZVhsE/PhZqlJYTUuOwOfUOuqkFigkR91sZ1nuNogcFx v793z06jxBeO0glss3R79frxcod6qgaJW3LrcxgB1RlEJAre+SIbEYSoT Yvg7qvnNxu1rL5xotx+KoC2H1lEaNIVObHw5QElHF4clbV7wSoujsAwuH 6owmNTQXc+4r734OGB03YA0ZA7Jm7s+5aiN+tuDkg+k/but/KzLpyYnZp mQ/+KUsTf2djyKM2Wp7yp1iKPXRwJ52Ls6SnkDxmdqZoOpoOh1erIk5bU Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="386360242" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="386360242" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 01:15:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="711111623" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="711111623" Received: from xhh-tgl64.sh.intel.com ([10.238.2.19]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 01:15:45 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Mon, 12 Jun 2023 16:14:47 +0800 Message-Id: <20230612081448.936570-5-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230612081448.936570-1-haihao.xiang@intel.com> References: <20230612081448.936570-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] lavfi/qsvvpp: postpone vpp session initialization 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 Cc: Haihao Xiang 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: From: Haihao Xiang So there is a chance to update vpp parameters per frame Signed-off-by: Haihao Xiang --- libavfilter/qsvvpp.c | 38 +++++++++++++++++++++++++++++++------- libavfilter/qsvvpp.h | 1 + 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index d168ab5d1d..f2e8e5fd73 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -835,6 +835,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) /* Print output memory mode */ ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP"); + /* Validate VPP params, but don't initial VPP session here */ ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); if (ret < 0) { ret = ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params"); @@ -842,13 +843,6 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param) } else if (ret > 0) ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); - ret = MFXVideoVPP_Init(s->session, &s->vpp_param); - if (ret < 0) { - ret = ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp"); - goto failed; - } else if (ret > 0) - ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp"); - return 0; failed: @@ -857,6 +851,31 @@ failed: return ret; } +static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) +{ + int ret; + + if (s->vpp_initted) + return 0; + + /* Query VPP params again, including params for frame */ + ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param); + if (ret < 0) + return ff_qsvvpp_print_error(avctx, ret, "Error querying VPP params"); + else if (ret > 0) + ff_qsvvpp_print_warning(avctx, ret, "Warning When querying VPP params"); + + ret = MFXVideoVPP_Init(s->session, &s->vpp_param); + if (ret < 0) + return ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp"); + else if (ret > 0) + ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp"); + + s->vpp_initted = 1; + + return 0; +} + int ff_qsvvpp_close(AVFilterContext *avctx) { QSVVPPContext *s = avctx->priv; @@ -865,6 +884,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx) MFXVideoVPP_Close(s->session); MFXClose(s->session); s->session = NULL; + s->vpp_initted = 0; } /* release all the resources */ @@ -920,6 +940,10 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr return AVERROR(ENOMEM); } + ret = qsvvpp_init_vpp_session(ctx, s); + if (ret) + return ret; + do { ret = MFXVideoVPP_RunFrameVPPAsync(s->session, &in_frame->surface, &out_frame->surface, NULL, &sync); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 073c89fe70..fba5f037d4 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -90,6 +90,7 @@ typedef struct QSVVPPContext { AVFifo *async_fifo; mfxVersion ver; + int vpp_initted; } QSVVPPContext; typedef struct QSVVPPCrop { -- 2.34.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".