From patchwork Wed Jan 24 08:16:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45776 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:120f:b0:199:de12:6fa6 with SMTP id v15csp1130172pzf; Wed, 24 Jan 2024 00:20:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG+UHzh42s6CEa75EToTbGQiqrwiKb2Hl2tQwvkD9m2Us2jW4lkOwXPj8vxm6YIvfPij8g0 X-Received: by 2002:a17:907:a642:b0:a2c:dfa:4f7 with SMTP id vu2-20020a170907a64200b00a2c0dfa04f7mr915477ejc.82.1706084417088; Wed, 24 Jan 2024 00:20:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706084417; cv=none; d=google.com; s=arc-20160816; b=BReUHJty+x+jvAWqzqIizTAcbbS/awBKMHxmFaKJKsHBBUqJHRRhXjMMEO60ahzCIO YwAsYeMuI1CKql/sXa1oXWOjcjb4WsxXLnvGKgaPgcaW3UKWF9xbr9reKFj6lUzD76cX LdrtK0Fkvs+BAx0Cox2y1JWKI3WZHR1ecn8EvFitEbTkYhfY+6nx4Rb2gmQB5WveUrpE fQxQsaLT3yXqImKFV33bzJ6lrfRIZRdRG/b1AeVNViKYZvQsb80SsmjzmnlgjckknH2S j74PTHQUlRq/GgJtc2kpZ4Bli3qT7EP3Vl/jAnsMo1UVYzJpVA16AmPRQBxZSndoVGxS Y/iw== 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:dkim-signature:delivered-to; bh=slPf6IHkJL5qjaCrdknCW+oJDxt7pYQQaYfwe5SYMcg=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=CBvv731TCBMXIG2XNT+xRrnv+Y2EhGbDvNMlmq+b8doIC0HVgeQ2ZUgBw1eEneFDnu zw2RbDxk1f9AnrUPU8OBHJCiyQhV2OGGcR+bkRtqMnTArB7B8ZsLGW6VkZ0FHthPXQsR J9YXvUJ3W6HAUHacbuSUgS4NnPgXGEOmpv9mjYb+oGKKGJGcvHk5TaMh21FLLNiaSnfL PCkx2LjuP+wAMfZwXABr9vaa8J9OXbXAjjMYWHraH74I3C00n5PgWGTa/ZXvxbjjvzMu UAqr9JMea086W6vw/hxMuPSqSG9n7VjcowNTta6InwLvQI9PQI/PwHUNPYAoW6NF7x4U 5cBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=JczsZf8v; 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 i6-20020a170906114600b00a2d0aaeaaf2si10622489eja.978.2024.01.24.00.20.16; Wed, 24 Jan 2024 00:20:17 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=JczsZf8v; 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 539AC68D11E; Wed, 24 Jan 2024 10:17:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C0AD68D103 for ; Wed, 24 Jan 2024 10:17:27 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=JczsZf8v; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 844681BB5 for ; Wed, 24 Jan 2024 09:17:24 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id rL2lBcxrTElU for ; Wed, 24 Jan 2024 09:17:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706084240; bh=vV0irvYH/je8QLtCLIFXP2khtEtiVO0jLtx8X0PL2To=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JczsZf8vkoNWAQU4l4Z0DEB3dklR58cLNe2NGwhovIyCbERSMPqVkuJI3b6O7xPAS df389qUNDICyDunmclxJVjwY2YGrblSfcZGXxloDBYYr+ZB+hfHeILrgdbCSjH2X/v 9IMbibQUbnZx9BTZBYFMUuYSIDDnPYoXQRFdg0saTWyrc05YWzVbdKNBnsHQX9+7eD UPLNEX2oKars4zjXUJwZ3Sp0ylQL4iSVh6NPuJqKGB9o1kfr7UQuTTqnByGz6Y5EX1 QnGHYPIoOGe0SUH7ZqEKHX0mvnFCW8L7IbQ5qv6dxo/Y6kUO6FIv6myNzhxZWtid/p Osdi5gttneb4A== 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 mail1.khirnov.net (Postfix) with ESMTPS id 389851BB8 for ; Wed, 24 Jan 2024 09:17:20 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2D25D3A054A for ; Wed, 24 Jan 2024 09:17:20 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Jan 2024 09:16:53 +0100 Message-ID: <20240124081702.4759-23-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240124081702.4759-1-anton@khirnov.net> References: <20240124081702.4759-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/31] fftools/ffmpeg_dec: eliminate InputStream use in hw_device_setup_for_decode() 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: 3/kL/tajRZTe The same information can also be obtained from the decoder itself. This is a step towards decoupling Decoder and InputStream. --- fftools/ffmpeg_dec.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 6c8f08d33e..ba261f4912 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -803,7 +803,8 @@ static HWDevice *hw_device_match_by_codec(const AVCodec *codec) } } -static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, +static int hw_device_setup_for_decode(DecoderPriv *dp, + const AVCodec *codec, const char *hwaccel_device) { const AVCodecHWConfig *config; @@ -858,7 +859,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (!dev) err = hw_device_init_from_type(type, NULL, &dev); } else { - dev = hw_device_match_by_codec(ist->dec); + dev = hw_device_match_by_codec(codec); if (!dev) { // No device for this codec, but not using generic hwaccel // and therefore may well not need one - ignore. @@ -869,12 +870,12 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (auto_device) { int i; - if (!avcodec_get_hw_config(ist->dec, 0)) { + if (!avcodec_get_hw_config(codec, 0)) { // Decoder does not support any hardware devices. return 0; } for (i = 0; !dev; i++) { - config = avcodec_get_hw_config(ist->dec, i); + config = avcodec_get_hw_config(codec, i); if (!config) break; type = config->device_type; @@ -886,7 +887,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, } } for (i = 0; !dev; i++) { - config = avcodec_get_hw_config(ist->dec, i); + config = avcodec_get_hw_config(codec, i); if (!config) break; type = config->device_type; @@ -921,7 +922,7 @@ static int hw_device_setup_for_decode(InputStream *ist, DecoderPriv *dp, if (!dev) { av_log(dp, AV_LOG_ERROR, "No device available " "for decoder: device type %s needed for codec %s.\n", - av_hwdevice_get_type_name(type), ist->dec->name); + av_hwdevice_get_type_name(type), codec->name); return err; } @@ -1010,7 +1011,7 @@ int dec_open(InputStream *ist, Scheduler *sch, unsigned sch_idx, av_dict_set(dec_opts, "flags", "+copy_opaque", AV_DICT_MULTIKEY); - ret = hw_device_setup_for_decode(ist, dp, o->hwaccel_device); + ret = hw_device_setup_for_decode(dp, codec, o->hwaccel_device); if (ret < 0) { av_log(dp, AV_LOG_ERROR, "Hardware device setup failed for decoder: %s\n",