From patchwork Tue May 23 13:58:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41797 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp600434pzb; Tue, 23 May 2023 06:59:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6TL1FbvmKUuT7atL2ljD5yHDGy3foHy2+PxP/1S2kk7xqE+u+rmEMmpyzbj4HEnW10lf07 X-Received: by 2002:a17:907:970c:b0:96b:e92:4feb with SMTP id jg12-20020a170907970c00b0096b0e924febmr15646756ejc.60.1684850383692; Tue, 23 May 2023 06:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850383; cv=none; d=google.com; s=arc-20160816; b=lUuC6wyzhcJrueBmgfRUyB0EYXhKNx74NUoV4RJgmJ4XnlkwyoF+P+S8vLvdxdsHvu P5It1SiRlrfWqpRl/VC+kyMq8DrW5zTNhFXaAdzZGcnwR/OGh08FuxMO4A8SQs4XTGHO Z6mBSoUq7X5qYbpOywbxmW4AOlnk5YqY5JMmfz2tSAopHSwxvpYd4kuBDyf82/vyfPJ7 zu2qiqzJjyMuZZN4W8E3jGeM2dgLc/Mvr4CNpPTAQJHEifetnO3buoBegqGhhjdm7gtE W+T27KbGbWV7DbjCY+Frr3oOUX/gJZ3GTbihAMpYeR8pphqkMdAcdseAh/N4s8DdMUjE xm0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=PMrVQKjOcBvYxczqjfDDsmG06v/O4V1FAuADZlSKrRU=; b=q2YnS+pf01bRXNaA3U9XINgfouW2Jk9WLTTYGb0hiKj1doueJflKc5/RblEbuWf+17 VXcUWrzgVCd1u+tN7qNuCs/tzcMfRUU3r/ccJGxyMpetUfv1om/p+DjtcrqqGU29V4Iy gnridB9N2KKViBU+oUjV2M3D4w2RVmHD7foLuUEHbN2JExq0H2S6fevwgtroJYjqft5Z 6Cg16nfWAm3DOKkK/QMt+CT+Uued/rHLgOjGy1CrwI0RcNPUbbJUonfcLfg96RE7Ki3X Ad+o7qHn3+rQow0hew0t379eIKN9lfocYVo3CJUudUTaMsfbLuxAoSaN4u6zXtXa/+iM //0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ba30-20020a0564021ade00b0050bc3b4200csi856618edb.291.2023.05.23.06.59.43; Tue, 23 May 2023 06:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4D44C68C0F4; Tue, 23 May 2023 16:59:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9959A68C030 for ; Tue, 23 May 2023 16:58:50 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5D36A2404EE for ; Tue, 23 May 2023 15:58:50 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6RWKEhWvRuU6 for ; Tue, 23 May 2023 15:58:49 +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 746692404F5 for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 38D173A11B4 for ; Tue, 23 May 2023 15:58:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Tue, 23 May 2023 15:58:30 +0200 Message-Id: <20230523135842.20388-3-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230523135842.20388-1-anton@khirnov.net> References: <20230523135842.20388-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/15] fftools/ffmpeg_enc: use AVFrame.hw_frames_ctx for encoder hw setup 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: d22qwv8BNmX8 It should be the same as the one that can be extracted from the filter and does not require access to outside data. --- fftools/ffmpeg_enc.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c index 7d99d9270b..59e9466420 100644 --- a/fftools/ffmpeg_enc.c +++ b/fftools/ffmpeg_enc.c @@ -103,22 +103,18 @@ fail: return AVERROR(ENOMEM); } -static int hw_device_setup_for_encode(OutputStream *ost) +static int hw_device_setup_for_encode(OutputStream *ost, AVBufferRef *frames_ref) { const AVCodecHWConfig *config; HWDevice *dev = NULL; - AVBufferRef *frames_ref = NULL; int i; - if (ost->filter) { - frames_ref = av_buffersink_get_hw_frames_ctx(ost->filter->filter); - if (frames_ref && - ((AVHWFramesContext*)frames_ref->data)->format == - ost->enc_ctx->pix_fmt) { - // Matching format, will try to use hw_frames_ctx. - } else { - frames_ref = NULL; - } + if (frames_ref && + ((AVHWFramesContext*)frames_ref->data)->format == + ost->enc_ctx->pix_fmt) { + // Matching format, will try to use hw_frames_ctx. + } else { + frames_ref = NULL; } for (i = 0;; i++) { @@ -388,7 +384,7 @@ int enc_open(OutputStream *ost, AVFrame *frame) av_dict_set(&ost->encoder_opts, "flags", "+frame_duration", AV_DICT_MULTIKEY); - ret = hw_device_setup_for_encode(ost); + ret = hw_device_setup_for_encode(ost, frame ? frame->hw_frames_ctx : NULL); if (ret < 0) { av_log(ost, AV_LOG_ERROR, "Encoding hardware device setup failed: %s\n", av_err2str(ret));