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 A050E467EC for ; Fri, 18 Aug 2023 14:25:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E54868C654; Fri, 18 Aug 2023 17:25:44 +0300 (EEST) Received: from out203-205-221-190.mail.qq.com (unknown [203.205.221.190]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DC2568C529 for ; Fri, 18 Aug 2023 17:25:36 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1692368728; bh=uYZOlgsY9wuZbqlSjq0+PsFtjO5pcg4+YifBZz5CvxU=; h=From:To:Cc:Subject:Date; b=gJTW4PplQbDsb+ExSgfQlKiaADt56nTCxZGvFVdMxg1CYTvBi15dvnos+fo3C0Gv0 /4LRi+yRnCpG7xm3dMSPUIG5dfJ4e4le9jKWYNAi730TEVDK2GpkExnwxfqeTp7qwP J8slE68V3l9lAqHZf+p3t062ScLrDruzSSNoh98A= Received: from ZHILIZHAO-MB2.tencent.com ([119.147.10.200]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 6099E8C6; Fri, 18 Aug 2023 22:24:09 +0800 X-QQ-mid: xmsmtpt1692368649t1euqceqp Message-ID: X-QQ-XMAILINFO: MrYPaBQR8fEOWYlwJsMBt1aQj8R0TTxuGck6vkVfHc6TqDBzESSHkIveTWcMF/ VUjhablrQ/dGyhVJfhHqtPz+pWVWFL2ZunwJXOSRhgEXARIly8k9n1uXnEctAilGPWodpuFenKB1 hCwOgkfEbrawzlJAJ9DdEMnl2FM31vw1BQInYc2cMiHVqZGgloJ03aSfuqQe3H0iO19JV/NeL4uI u19BOA0YKMBgzYuGPH1fhHAC6Vn6Jdg59I6cQeoynMjTv81M9uJW/q567Xd/6Nc+bUlaJh52ADLp d0ydJshSLE7RF9SIMvqNN/ZBIXSxH8ZU3ncZbCgCjnG1hMKauYZ7rhx0sTy4TKh89OZhbucCSfXx 0gpiU6SwnZQQPmhR7WzPa52/1/R+vWKupcxeZdefVzdAJ1UBDc2txcBORcM0r7q4eYQLKjfTeHQY sD1IZAvsGos702gRTcvdbcI7RQYsg5gRXLKArnP+SiDrMpDpXgFlnx9hNUfeaoPUdCoWO9mQAssJ FH4BicyV+IJBxGu8O7gcj7uBaOS2/s+39Eaj0BxZZ5T/pO+8Mmue0kz/Zq86SzTcAl2dcqUtUp/l SJQ2G/c0PFY8QV+JlgOD8S4uVFNzsngwGr8bh5FrzktD0rZ1xc+YQVjtQkOR5HZ32N9sxhGnvGPw yuL3zYwh9y/QxCYdVe9fpR/KwS98aXkGNfJ5xz4+ldQFKMVUPvhrASVc/YZt42u9g13A7JS7VVBF uc4tcCc/ZT2fmc+ICtg+aUZ0cQE7iXZmvhu0WM671CzO+e6+NUh+cNRIfrPZnWlfLy1fKbCbU8xP gWBbo2L+/IUTlT1KpTtF2KzrMx1O3iLNDORRjvFDWMWrrI+064/DOZn26qO0Qrj5ZNSUt03HmmsR JRm3ryWPDA7ipzXD7gqRjsVruEt8XVV9ziUrlJ3caVmQn4ba6bjXGDSga8orPCBT6EP3N9uCrsvY Hja7OcPRthspgJd7qRlnDVs0eAGwIrMBS5TmaOMNWpU0rFGTRq/g== X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Aug 2023 22:24:06 +0800 X-OQ-MSGID: <20230818142408.74329-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_scale_vt: fix output frame dimension 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: Zhao Zhili 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: Zhao Zhili The output frame dimension is incorrect because it shares hardware frame context with input. Signed-off-by: Zhao Zhili --- libavfilter/vf_scale_vt.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c index d5b4f12291..af4a8b32c6 100644 --- a/libavfilter/vf_scale_vt.c +++ b/libavfilter/vf_scale_vt.c @@ -177,6 +177,8 @@ static int scale_vt_config_output(AVFilterLink *outlink) AVFilterContext *avctx = outlink->src; ScaleVtContext *s = avctx->priv; AVFilterLink *inlink = outlink->src->inputs[0]; + AVHWFramesContext *hw_frame_ctx_in; + AVHWFramesContext *hw_frame_ctx_out; err = ff_scale_eval_dimensions(s, s->w_expr, s->h_expr, inlink, outlink, &s->output_width, @@ -194,6 +196,28 @@ static int scale_vt_config_output(AVFilterLink *outlink) outlink->sample_aspect_ratio = inlink->sample_aspect_ratio; } + hw_frame_ctx_in = (AVHWFramesContext *)inlink->hw_frames_ctx->data; + + av_buffer_unref(&outlink->hw_frames_ctx); + outlink->hw_frames_ctx = av_hwframe_ctx_alloc(hw_frame_ctx_in->device_ref); + hw_frame_ctx_out = (AVHWFramesContext *)outlink->hw_frames_ctx->data; + hw_frame_ctx_out->format = AV_PIX_FMT_VIDEOTOOLBOX; + hw_frame_ctx_out->sw_format = hw_frame_ctx_in->sw_format; + hw_frame_ctx_out->width = outlink->w; + hw_frame_ctx_out->height = outlink->h; + + err = ff_filter_init_hw_frames(avctx, outlink, 1); + if (err < 0) + return err; + + err = av_hwframe_ctx_init(outlink->hw_frames_ctx); + if (err < 0) { + av_log(avctx, AV_LOG_ERROR, + "Failed to init videotoolbox frame context, %s\n", + av_err2str(err)); + return err; + } + return 0; } @@ -242,4 +266,5 @@ const AVFilter ff_vf_scale_vt = { FILTER_SINGLE_PIXFMT(AV_PIX_FMT_VIDEOTOOLBOX), .priv_class = &scale_vt_class, .flags = AVFILTER_FLAG_HWDEVICE, + .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, }; -- 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".