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 153F84999E for ; Thu, 25 Apr 2024 05:18:34 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C759C68D332; Thu, 25 Apr 2024 08:18:30 +0300 (EEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF8E368D2AF for ; Thu, 25 Apr 2024 08:18:23 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714022310; x=1745558310; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=6WlKu4DCxzUw2VY15UQxPZKSPpPPdXMn1nC7SS6InhU=; b=FHHSdr1Sg0AQgkGjAm3BNMD+P6RQ/E81YzGfa9yVh5/bWSEhI2AyAkuv pbAhmTNPAACuZVWQ5FyPrr2lCJHyi+Uik4wGSibwez69M8psmyGVG1ErS TEGZVTlGYz90KvNc1pHAIVQLo2cQeusndct6xd68gwtCu/wUOdLQp6K41 kH53B2Wh3NOYsCLBrk+5X+1ncIq0oKNoAM488Yf8F3DudIZHjSZFwb4SP 0cC0M5ijpEN3B5I1hrr7btHheK8An1w5O1iHvc58KTzEegQmSdof7/cAe KEAPdVUY121Nxf7s7MkAFZvstR6GdLHM4CjAbPIZ7Q6bEpg2AzobcoD7X A==; X-CSE-ConnectionGUID: lqa9k/CTRSK30HXgEUgxuw== X-CSE-MsgGUID: Dj6MDqErRkCrmuDLTfvRbQ== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="27145184" X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="27145184" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 22:18:21 -0700 X-CSE-ConnectionGUID: +lTxod6lQbuf40RhZzER8w== X-CSE-MsgGUID: Rw1jXXFpQyi4q/9U6/h26g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,228,1708416000"; d="scan'208";a="29737871" Received: from unknown (HELO xhh-dg264.sh.intel.com) ([10.238.2.76]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 22:18:20 -0700 From: "Xiang, Haihao" To: ffmpeg-devel@ffmpeg.org Date: Thu, 25 Apr 2024 13:18:09 +0800 Message-Id: <20240425051809.283325-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavfi/qsv: Copy metadata fields from the given input 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 Currently it always copies the metadata fields from the last input when there are multiple inputs for the filter. For example, the metadata fields from input1 are copied to the output for overlay_qsv filter, however for regular overlay filters, the metadata fields from input0 are copied to the output. With this fix, we may copy the metadata fields from input0 to the ouput as well. Signed-off-by: Haihao Xiang --- libavfilter/qsvvpp.c | 29 +++++++++++------------------ libavfilter/qsvvpp.h | 2 +- libavfilter/vf_overlay_qsv.c | 9 ++++++--- libavfilter/vf_stack_qsv.c | 9 ++++++--- libavfilter/vf_vpp_qsv.c | 2 +- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 8c92fec0c1..10d970652e 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -441,11 +441,6 @@ static QSVFrame *submit_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *p av_frame_free(&qsv_frame->frame); return NULL; } - - if (av_frame_copy_props(qsv_frame->frame, picref) < 0) { - av_frame_free(&qsv_frame->frame); - return NULL; - } } else qsv_frame->frame = av_frame_clone(picref); @@ -494,12 +489,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink, const AVFr if (!out_frame->frame) return NULL; - ret = av_frame_copy_props(out_frame->frame, in); - if (ret < 0) { - av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from src to dst.\n"); - return NULL; - } - ret = av_hwframe_get_buffer(outlink->hw_frames_ctx, out_frame->frame, 0); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Can't allocate a surface.\n"); @@ -516,12 +505,6 @@ static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink, const AVFr if (!out_frame->frame) return NULL; - ret = av_frame_copy_props(out_frame->frame, in); - if (ret < 0) { - av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from src to dst.\n"); - return NULL; - } - ret = map_frame_to_surface(out_frame->frame, &out_frame->surface); if (ret < 0) @@ -958,7 +941,7 @@ int ff_qsvvpp_close(AVFilterContext *avctx) return 0; } -int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref) +int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref, AVFrame *propref) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; @@ -1015,6 +998,16 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr return AVERROR(EAGAIN); break; } + + if (propref) { + ret1 = av_frame_copy_props(out_frame->frame, propref); + if (ret1 < 0) { + av_frame_free(&out_frame->frame); + av_log(ctx, AV_LOG_ERROR, "Failed to copy metadata fields from src to dst.\n"); + return ret1; + } + } + out_frame->frame->pts = av_rescale_q(out_frame->surface.Data.TimeStamp, default_tb, outlink->time_base); diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 4eea7a46c7..3b9192b62e 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -131,7 +131,7 @@ int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param); int ff_qsvvpp_close(AVFilterContext *avctx); /* vpp filter frame and call the cb if needed */ -int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame); +int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame, AVFrame *propref); int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, const char *extra_string); diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c index 0f52c93245..059602fe03 100644 --- a/libavfilter/vf_overlay_qsv.c +++ b/libavfilter/vf_overlay_qsv.c @@ -228,13 +228,16 @@ static int process_frame(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; QSVVPPContext *qsv = fs->opaque; - AVFrame *frame = NULL; + AVFrame *frame = NULL, *propref = NULL; int ret = 0, i; for (i = 0; i < ctx->nb_inputs; i++) { ret = ff_framesync_get_frame(fs, i, &frame, 0); - if (ret == 0) - ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame); + if (ret == 0) { + if (i == 0) + propref = frame; + ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame, propref); + } if (ret < 0 && ret != AVERROR(EAGAIN)) break; } diff --git a/libavfilter/vf_stack_qsv.c b/libavfilter/vf_stack_qsv.c index abaf156915..d4c1ac997f 100644 --- a/libavfilter/vf_stack_qsv.c +++ b/libavfilter/vf_stack_qsv.c @@ -71,13 +71,16 @@ static int process_frame(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; QSVVPPContext *qsv = fs->opaque; - AVFrame *frame = NULL; + AVFrame *frame = NULL, *propref = NULL; int ret = 0; for (int i = 0; i < ctx->nb_inputs; i++) { ret = ff_framesync_get_frame(fs, i, &frame, 0); - if (ret == 0) - ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame); + if (ret == 0) { + if (i == 0) + propref = frame; + ret = ff_qsvvpp_filter_frame(qsv, ctx->inputs[i], frame, propref); + } if (ret < 0 && ret != AVERROR(EAGAIN)) break; } diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 598c85be09..6071c46ca1 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -748,7 +748,7 @@ static int activate(AVFilterContext *ctx) if (qsv->session) { if (in || qsv->eof) { - ret = ff_qsvvpp_filter_frame(qsv, inlink, in); + ret = ff_qsvvpp_filter_frame(qsv, inlink, in, in); av_frame_free(&in); if (ret == AVERROR(EAGAIN)) goto not_ready; -- 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".